diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config.c | 14 | ||||
-rw-r--r-- | src/core/wee-config.h | 9 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 12 | ||||
-rw-r--r-- | src/gui/gui-input.c | 31 |
4 files changed, 51 insertions, 15 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c index c4d4a235f..d1e4504b0 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -90,6 +90,7 @@ struct t_config_option *config_look_hotlist_names_merged_buffers; struct t_config_option *config_look_hotlist_short_names; struct t_config_option *config_look_hotlist_sort; struct t_config_option *config_look_input_share; +struct t_config_option *config_look_input_share_overwrite; struct t_config_option *config_look_input_undo_max; struct t_config_option *config_look_item_time_format; struct t_config_option *config_look_jump_current_to_previous_buffer; @@ -1347,9 +1348,16 @@ config_weechat_init_options () 0, 0, "group_time_asc", NULL, 0, NULL, NULL, &config_change_hotlist, NULL, NULL, NULL); config_look_input_share = config_file_new_option ( weechat_config_file, ptr_section, - "input_share", "boolean", - N_("if set, there is only one input shared on all buffers (but still " - "local history for each buffer)"), + "input_share", "integer", + N_("share commands, text, or both in input for all buffers (there is " + "still local history for each buffer)"), + "none|commands|text|all", + 0, 0, "none", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); + config_look_input_share_overwrite = config_file_new_option ( + weechat_config_file, ptr_section, + "input_share_overwrite", "boolean", + N_("if set and input is shared, always overwrite input in target " + "buffer"), NULL, 0, 0, "off", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL); config_look_input_undo_max = config_file_new_option ( weechat_config_file, ptr_section, diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 24c3e0421..362f1c3c5 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -68,6 +68,14 @@ enum t_config_look_hotlist_sort CONFIG_LOOK_HOTLIST_SORT_NUMBER_DESC, }; +enum t_config_look_input_share +{ + CONFIG_LOOK_INPUT_SHARE_NONE = 0, + CONFIG_LOOK_INPUT_SHARE_COMMANDS, + CONFIG_LOOK_INPUT_SHARE_TEXT, + CONFIG_LOOK_INPUT_SHARE_ALL, +}; + enum t_config_look_read_marker { CONFIG_LOOK_READ_MARKER_NONE = 0, @@ -112,6 +120,7 @@ extern struct t_config_option *config_look_hotlist_names_merged_buffers; extern struct t_config_option *config_look_hotlist_short_names; extern struct t_config_option *config_look_hotlist_sort; extern struct t_config_option *config_look_input_share; +extern struct t_config_option *config_look_input_share_overwrite; extern struct t_config_option *config_look_input_undo_max; extern struct t_config_option *config_look_item_time_format; extern struct t_config_option *config_look_jump_current_to_previous_buffer; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 10003758d..865d1c488 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -576,11 +576,7 @@ gui_window_switch_to_buffer (struct t_gui_window *window, window->buffer->lines->last_read_line = window->buffer->lines->last_line; } - if (CONFIG_BOOLEAN(config_look_input_share) - && (old_buffer != window->buffer)) - { - gui_input_move_to_buffer (old_buffer, window->buffer); - } + gui_input_move_to_buffer (old_buffer, window->buffer); hook_signal_send ("buffer_switch", WEECHAT_HOOK_SIGNAL_POINTER, buffer); @@ -615,11 +611,7 @@ gui_window_switch (struct t_gui_window *window) gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - if (CONFIG_BOOLEAN(config_look_input_share) - && (old_window->buffer != window->buffer)) - { - gui_input_move_to_buffer (old_window->buffer, window->buffer); - } + gui_input_move_to_buffer (old_window->buffer, window->buffer); } /* diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 9e61d65ad..074093a1e 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -248,8 +248,35 @@ void gui_input_move_to_buffer (struct t_gui_buffer *from_buffer, struct t_gui_buffer *to_buffer) { - /* only possible for two different buffers */ - if (!from_buffer || !to_buffer || (from_buffer == to_buffer)) + int is_command; + + /* + * move of input is allowed if: + * - 2 buffers are different + * - input_share is not set to "none" + * - input buffer in first buffer is not empty + */ + if (!from_buffer || !to_buffer || (from_buffer == to_buffer) + || (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_NONE) + || !from_buffer->input_buffer || !from_buffer->input_buffer[0]) + return; + + /* + * if input is command and that only text is allowed, + * or if input is text and that only command is allowed, + * then do nothing + */ + is_command = (string_input_for_buffer (from_buffer->input_buffer) == NULL) ? 1 : 0; + if ((is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_TEXT)) + || (!is_command && (CONFIG_INTEGER(config_look_input_share) == CONFIG_LOOK_INPUT_SHARE_COMMANDS))) + return; + + /* + * if overwrite is off and that input of target buffer is not empty, + * then do nothing + */ + if ((!CONFIG_BOOLEAN(config_look_input_share_overwrite)) + && to_buffer->input_buffer && to_buffer->input_buffer[0]) return; /* move input_buffer */ |