diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-window.c | 12 | ||||
-rw-r--r-- | src/gui/gui-input.c | 31 |
2 files changed, 31 insertions, 12 deletions
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 */ |