From df12f8de3485e4bbcbe112f2a2af050c58817ac6 Mon Sep 17 00:00:00 2001 From: Kevin Pulo Date: Sun, 7 Feb 2021 09:48:19 +0100 Subject: [PATCH] core: add options weechat.look.hotlist_update_on_buffer_switch and weechat.look.read_marker_update_on_buffer_switch Both default to "on" (no change to previous behavior). If hotlist_update_on_buffer_switch is "off", then when switching away from a buffer, the hotlist is not cleared. If read_marker_update_on_buffer_switch is "off", then when switching away from a buffer, the read marker is not set to the end of the buffer. This allows users to choose to have fully manual control over when hotlist counts and buffer read markers are reset. Fixes #992. --- src/core/wee-config.c | 14 ++++++++++++++ src/core/wee-config.h | 2 ++ src/gui/curses/gui-curses-window.c | 12 ++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 8c32f0008..d265fba8d 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -135,6 +135,7 @@ struct t_config_option *config_look_hotlist_short_names; struct t_config_option *config_look_hotlist_sort; struct t_config_option *config_look_hotlist_suffix; struct t_config_option *config_look_hotlist_unique_numbers; +struct t_config_option *config_look_hotlist_update_on_buffer_switch; struct t_config_option *config_look_input_cursor_scroll; struct t_config_option *config_look_input_share; struct t_config_option *config_look_input_share_overwrite; @@ -180,6 +181,7 @@ struct t_config_option *config_look_quote_time_format; struct t_config_option *config_look_read_marker; struct t_config_option *config_look_read_marker_always_show; struct t_config_option *config_look_read_marker_string; +struct t_config_option *config_look_read_marker_update_on_buffer_switch; struct t_config_option *config_look_save_config_on_exit; struct t_config_option *config_look_save_config_with_fsync; struct t_config_option *config_look_save_layout_on_exit; @@ -3099,6 +3101,12 @@ config_weechat_init_options () NULL, NULL, NULL, &config_change_buffer_content, NULL, NULL, NULL, NULL, NULL); + config_look_hotlist_update_on_buffer_switch = config_file_new_option ( + weechat_config_file, ptr_section, + "hotlist_update_on_buffer_switch", "boolean", + N_("update the hotlist when switching buffers"), + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_look_input_cursor_scroll = config_file_new_option ( weechat_config_file, ptr_section, "input_cursor_scroll", "integer", @@ -3524,6 +3532,12 @@ config_weechat_init_options () NULL, NULL, NULL, &config_change_read_marker, NULL, NULL, NULL, NULL, NULL); + config_look_read_marker_update_on_buffer_switch = config_file_new_option ( + weechat_config_file, ptr_section, + "read_marker_update_on_buffer_switch", "boolean", + N_("update the read marker when switching buffers"), + NULL, 0, 0, "on", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_look_save_config_on_exit = config_file_new_option ( weechat_config_file, ptr_section, "save_config_on_exit", "boolean", diff --git a/src/core/wee-config.h b/src/core/wee-config.h index 0467cacc4..ba4068ee7 100644 --- a/src/core/wee-config.h +++ b/src/core/wee-config.h @@ -188,6 +188,7 @@ 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_hotlist_suffix; extern struct t_config_option *config_look_hotlist_unique_numbers; +extern struct t_config_option *config_look_hotlist_update_on_buffer_switch; extern struct t_config_option *config_look_input_cursor_scroll; extern struct t_config_option *config_look_input_share; extern struct t_config_option *config_look_input_share_overwrite; @@ -233,6 +234,7 @@ extern struct t_config_option *config_look_quote_time_format; extern struct t_config_option *config_look_read_marker; extern struct t_config_option *config_look_read_marker_always_show; extern struct t_config_option *config_look_read_marker_string; +extern struct t_config_option *config_look_read_marker_update_on_buffer_switch; extern struct t_config_option *config_look_save_config_on_exit; extern struct t_config_option *config_look_save_config_with_fsync; extern struct t_config_option *config_look_save_layout_on_exit; diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 58f4ba241..6f90c0eee 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -1235,13 +1235,17 @@ gui_window_switch_to_buffer (struct t_gui_window *window, gui_buffer_visited_add (window->buffer); gui_buffer_visited_add (buffer); } - if (set_last_read) + if (set_last_read + && CONFIG_BOOLEAN(config_look_read_marker_update_on_buffer_switch)) { if (window->buffer->num_displayed == 0) { window->buffer->lines->last_read_line = window->buffer->lines->last_line; window->buffer->lines->first_line_not_read = 0; } + } + if (set_last_read) + { /* * if there is no line displayed after last read line, * then remove the read marker @@ -1260,8 +1264,12 @@ gui_window_switch_to_buffer (struct t_gui_window *window, gui_buffer_set_active_buffer (buffer); gui_buffer_compute_num_displayed (); - if (!weechat_upgrading && (old_buffer != buffer)) + if (!weechat_upgrading + && (old_buffer != buffer) + && CONFIG_BOOLEAN(config_look_hotlist_update_on_buffer_switch)) + { gui_hotlist_remove_buffer (buffer, 0); + } /* remove unused bars and add missing bars in window */ gui_bar_window_remove_unused_bars (window);