diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-25 17:00:37 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-12-25 17:00:37 +0100 |
commit | c9796a31415dee3ac3745f6b4c0792d7a9da313b (patch) | |
tree | c31160c4514ab562caefab8e060a26d729ef0b97 /src/gui | |
parent | 9bd6cbf4bdfc0e228628f56614ce98279a957bc6 (diff) | |
download | weechat-c9796a31415dee3ac3745f6b4c0792d7a9da313b.zip |
core: move `/input` jump actions to command `/buffer jump`
Actions moved to command `/buffer jump`:
* `/input jump_smart` -> `/buffer jump smart`
* `/input jump_previously_visited_buffer` -> `/buffer jump prev_visited`
* `/input jump_next_visited_buffer` -> `/buffer jump next_visited`
* `/input jump_last_buffer_displayed` -> `/buffer jump last_displayed`
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-key.c | 10 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 123 | ||||
-rw-r--r-- | src/gui/gui-buffer.h | 4 | ||||
-rw-r--r-- | src/gui/gui-input.c | 142 | ||||
-rw-r--r-- | src/gui/gui-input.h | 4 |
5 files changed, 132 insertions, 151 deletions
diff --git a/src/gui/curses/gui-curses-key.c b/src/gui/curses/gui-curses-key.c index 218940305..0d9ac53c6 100644 --- a/src/gui/curses/gui-curses-key.c +++ b/src/gui/curses/gui-curses-key.c @@ -133,7 +133,7 @@ gui_key_default_bindings (int context) BIND(/* ^<down> */ "meta-Ob", "/input history_global_next"); BIND(/* ^<down> */ "meta-OB", "/input history_global_next"); BIND(/* ^<down> */ "meta2-1;5B", "/input history_global_next"); - BIND(/* m-a */ "meta-a", "/input jump_smart"); + BIND(/* m-a */ "meta-a", "/buffer jump smart"); BIND(/* m-j,m-f */ "meta-jmeta-f", "/buffer -"); BIND(/* m-j,m-l */ "meta-jmeta-l", "/buffer +"); BIND(/* m-j,m-r */ "meta-jmeta-r", "/server raw"); @@ -220,9 +220,9 @@ gui_key_default_bindings (int context) BIND(/* m-7 */ "meta-7", "/buffer *7"); BIND(/* m-8 */ "meta-8", "/buffer *8"); BIND(/* m-9 */ "meta-9", "/buffer *9"); - BIND(/* m-< */ "meta-<", "/input jump_previously_visited_buffer"); - BIND(/* m-> */ "meta->", "/input jump_next_visited_buffer"); - BIND(/* m-/ */ "meta-/", "/input jump_last_buffer_displayed"); + BIND(/* m-< */ "meta-<", "/buffer jump prev_visited"); + BIND(/* m-> */ "meta->", "/buffer jump next_visited"); + BIND(/* m-/ */ "meta-/", "/buffer jump last_displayed"); BIND(/* m-l */ "meta-l", "/window bare"); BIND(/* m-m */ "meta-m", "/mute mouse toggle"); BIND(/* start paste */ "meta2-200~", "/input paste_start"); @@ -282,7 +282,7 @@ gui_key_default_bindings (int context) BIND("@chat:button1-gesture-left", "/window ${_window_number};/buffer -1"); BIND("@chat:button1-gesture-right", "/window ${_window_number};/buffer +1"); BIND("@chat:button1-gesture-left-long", "/window ${_window_number};/buffer 1"); - BIND("@chat:button1-gesture-right-long", "/window ${_window_number};/input jump_last_buffer"); + BIND("@chat:button1-gesture-right-long", "/window ${_window_number};/buffer +"); BIND("@chat:wheelup", "/window scroll_up -window ${_window_number}"); BIND("@chat:wheeldown", "/window scroll_down -window ${_window_number}"); BIND("@chat:ctrl-wheelup", "/window scroll_horiz -window ${_window_number} -10%"); diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index acfb2fe73..9e32c7f23 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -4441,6 +4441,129 @@ gui_buffer_visited_get_index_next () } /* + * Jumps to buffer with activity. + */ + +void +gui_buffer_jump_smart (struct t_gui_window *window) +{ + int scroll_to_bottom; + + if (!window) + return; + + scroll_to_bottom = 0; + + if (gui_hotlist) + { + if (!gui_hotlist_initial_buffer) + gui_hotlist_initial_buffer = window->buffer; + gui_window_switch_to_buffer (window, gui_hotlist->buffer, 1); + gui_hotlist_remove_buffer (window->buffer, 0); + scroll_to_bottom = 1; + } + else + { + if (gui_hotlist_initial_buffer) + { + if (CONFIG_BOOLEAN(config_look_jump_smart_back_to_buffer)) + { + gui_window_switch_to_buffer (window, + gui_hotlist_initial_buffer, 1); + scroll_to_bottom = 1; + } + gui_hotlist_initial_buffer = NULL; + } + else + { + gui_hotlist_initial_buffer = NULL; + } + } + + /* + * scroll to bottom if window was scrolled (except if scrolled + * beyond the end) + */ + if (scroll_to_bottom + && window->scroll + && window->scroll->start_line + && (window->scroll->start_line_pos >= 0)) + { + gui_window_scroll_bottom (window); + } +} + +/* + * Jumps to last buffer displayed (before last jump to a buffer). + */ + +void +gui_buffer_jump_last_buffer_displayed (struct t_gui_window *window) +{ + if (window && gui_buffer_last_displayed) + { + gui_buffer_switch_by_number (window, + gui_buffer_last_displayed->number); + } +} + +/* + * Jumps to a visited buffer by index (called by functions to jump to + * previously / next visited buffer). + */ + +void +gui_buffer_jump_visited_by_index (struct t_gui_window *window, int index) +{ + struct t_gui_buffer_visited *ptr_buffer_visited; + + if (!window || (index < 0)) + return; + + gui_buffers_visited_index = index; + + ptr_buffer_visited = + gui_buffer_visited_search_by_number (gui_buffers_visited_index); + if (ptr_buffer_visited) + { + gui_buffers_visited_frozen = 1; + gui_buffer_switch_by_number (window, + ptr_buffer_visited->buffer->number); + gui_buffers_visited_frozen = 0; + } +} + +/* + * Jumps to previously visited buffer (buffer displayed before current one). + */ + +void +gui_buffer_jump_previously_visited_buffer (struct t_gui_window *window) +{ + if (!window) + return; + + gui_buffer_jump_visited_by_index ( + window, + gui_buffer_visited_get_index_previous ()); +} + +/* + * Jumps to next visited buffer (buffer displayed after current one). + */ + +void +gui_buffer_jump_next_visited_buffer (struct t_gui_window *window) +{ + if (!window) + return; + + gui_buffer_jump_visited_by_index ( + window, + gui_buffer_visited_get_index_next ()); +} + +/* * Returns hdata for buffer. */ diff --git a/src/gui/gui-buffer.h b/src/gui/gui-buffer.h index d4b840e90..9fc329929 100644 --- a/src/gui/gui-buffer.h +++ b/src/gui/gui-buffer.h @@ -385,6 +385,10 @@ extern void gui_buffer_visited_remove_by_buffer (struct t_gui_buffer *buffer); extern struct t_gui_buffer_visited *gui_buffer_visited_add (struct t_gui_buffer *buffer); extern int gui_buffer_visited_get_index_previous (); extern int gui_buffer_visited_get_index_next (); +extern void gui_buffer_jump_smart (struct t_gui_window *window); +extern void gui_buffer_jump_last_buffer_displayed (struct t_gui_window *window); +extern void gui_buffer_jump_previously_visited_buffer (struct t_gui_window *window); +extern void gui_buffer_jump_next_visited_buffer (struct t_gui_window *window); extern struct t_hdata *gui_buffer_hdata_buffer_cb (const void *pointer, void *data, const char *hdata_name); diff --git a/src/gui/gui-input.c b/src/gui/gui-input.c index 6fb378575..3208ca08d 100644 --- a/src/gui/gui-input.c +++ b/src/gui/gui-input.c @@ -1461,148 +1461,6 @@ gui_input_history_global_next (struct t_gui_buffer *buffer) } /* - * Jumps to buffer with activity (default key: alt-a). - */ - -void -gui_input_jump_smart (struct t_gui_buffer *buffer) -{ - struct t_gui_window *window; - int scroll_to_bottom; - - scroll_to_bottom = 0; - window = gui_window_search_with_buffer (buffer); - if (window - && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) - { - if (gui_hotlist) - { - if (!gui_hotlist_initial_buffer) - gui_hotlist_initial_buffer = window->buffer; - gui_window_switch_to_buffer (window, gui_hotlist->buffer, 1); - gui_hotlist_remove_buffer (window->buffer, 0); - scroll_to_bottom = 1; - } - else - { - if (gui_hotlist_initial_buffer) - { - if (CONFIG_BOOLEAN(config_look_jump_smart_back_to_buffer)) - { - gui_window_switch_to_buffer (window, - gui_hotlist_initial_buffer, 1); - scroll_to_bottom = 1; - } - gui_hotlist_initial_buffer = NULL; - } - else - { - gui_hotlist_initial_buffer = NULL; - } - } - - /* - * scroll to bottom if window was scrolled (except if scrolled - * beyond the end) - */ - if (scroll_to_bottom - && window->scroll - && window->scroll->start_line - && (window->scroll->start_line_pos >= 0)) - { - gui_window_scroll_bottom (window); - } - } -} - -/* - * Jumps to last buffer displayed (before last jump to a buffer) (default key: - * alt-/). - */ - -void -gui_input_jump_last_buffer_displayed (struct t_gui_buffer *buffer) -{ - struct t_gui_window *window; - - window = gui_window_search_with_buffer (buffer); - if (window - && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) - { - if (gui_buffer_last_displayed) - gui_buffer_switch_by_number (window, - gui_buffer_last_displayed->number); - } -} - -/* - * Jumps to previously visited buffer (buffer displayed before current one) - * (default key: alt-<). - */ - -void -gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer) -{ - struct t_gui_window *window; - int index; - struct t_gui_buffer_visited *ptr_buffer_visited; - - window = gui_window_search_with_buffer (buffer); - if (window - && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) - { - index = gui_buffer_visited_get_index_previous (); - if (index >= 0) - { - gui_buffers_visited_index = index; - - ptr_buffer_visited = - gui_buffer_visited_search_by_number (gui_buffers_visited_index); - if (ptr_buffer_visited) - { - gui_buffers_visited_frozen = 1; - gui_buffer_switch_by_number (window, - ptr_buffer_visited->buffer->number); - gui_buffers_visited_frozen = 0; - } - } - } -} - -/* - * Jumps to next visited buffer (buffer displayed after current one) (default - * key: alt->). - */ - -void -gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer) -{ - struct t_gui_window *window; - int index; - struct t_gui_buffer_visited *ptr_buffer_visited; - - window = gui_window_search_with_buffer (buffer); - if (window - && (window->buffer->text_search == GUI_TEXT_SEARCH_DISABLED)) - { - index = gui_buffer_visited_get_index_next (); - if (index >= 0) - { - gui_buffers_visited_index = index; - - ptr_buffer_visited = gui_buffer_visited_search_by_number (gui_buffers_visited_index); - if (ptr_buffer_visited) - { - gui_buffers_visited_frozen = 1; - gui_buffer_switch_by_number (window, - ptr_buffer_visited->buffer->number); - gui_buffers_visited_frozen = 0; - } - } - } -} - -/* * Clears hotlist (default key: alt-h, alt-c). */ diff --git a/src/gui/gui-input.h b/src/gui/gui-input.h index 9aedf0ea1..49e6c1eb2 100644 --- a/src/gui/gui-input.h +++ b/src/gui/gui-input.h @@ -72,10 +72,6 @@ extern void gui_input_history_local_previous (struct t_gui_buffer *buffer); extern void gui_input_history_local_next (struct t_gui_buffer *buffer); extern void gui_input_history_global_previous (struct t_gui_buffer *buffer); extern void gui_input_history_global_next (struct t_gui_buffer *buffer); -extern void gui_input_jump_smart (struct t_gui_buffer *buffer); -extern void gui_input_jump_last_buffer_displayed (struct t_gui_buffer *buffer); -extern void gui_input_jump_previously_visited_buffer (struct t_gui_buffer *buffer); -extern void gui_input_jump_next_visited_buffer (struct t_gui_buffer *buffer); extern void gui_input_hotlist_clear (struct t_gui_buffer *buffer, const char *level_mask); extern void gui_input_hotlist_remove_buffer (struct t_gui_buffer *buffer); |