diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config.c | 4 | ||||
-rw-r--r-- | src/gui/curses/gui-curses-main.c | 30 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 7 | ||||
-rw-r--r-- | src/gui/gui-filter.c | 2 | ||||
-rw-r--r-- | src/gui/gui-line.c | 47 | ||||
-rw-r--r-- | src/gui/gui-line.h | 2 |
6 files changed, 64 insertions, 28 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c index a7218a0dd..e536d3a0f 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -412,9 +412,9 @@ config_compute_prefix_max_length_all_buffers () ptr_buffer = ptr_buffer->next_buffer) { if (ptr_buffer->own_lines) - gui_line_compute_prefix_max_length (ptr_buffer->own_lines); + ptr_buffer->own_lines->prefix_max_length_refresh = 1; if (ptr_buffer->mixed_lines) - gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines); + ptr_buffer->mixed_lines->prefix_max_length_refresh = 1; } } diff --git a/src/gui/curses/gui-curses-main.c b/src/gui/curses/gui-curses-main.c index 0cc13acee..5377d88eb 100644 --- a/src/gui/curses/gui-curses-main.c +++ b/src/gui/curses/gui-curses-main.c @@ -51,6 +51,7 @@ #include "../gui-filter.h" #include "../gui-input.h" #include "../gui-layout.h" +#include "../gui-line.h" #include "../gui-history.h" #include "../gui-mouse.h" #include "../gui-nicklist.h" @@ -311,6 +312,35 @@ gui_main_refreshs () gui_color_buffer_refresh_needed = 0; } + /* compute max length for prefix/buffer if needed */ + for (ptr_buffer = gui_buffers; ptr_buffer; + ptr_buffer = ptr_buffer->next_buffer) + { + /* compute buffer/prefix max length for own_lines */ + if (ptr_buffer->own_lines) + { + if (ptr_buffer->own_lines->buffer_max_length_refresh) + { + gui_line_compute_buffer_max_length (ptr_buffer, + ptr_buffer->own_lines); + } + if (ptr_buffer->own_lines->prefix_max_length_refresh) + gui_line_compute_prefix_max_length (ptr_buffer->own_lines); + } + + /* compute buffer/prefix max length for mixed_lines */ + if (ptr_buffer->mixed_lines) + { + if (ptr_buffer->mixed_lines->buffer_max_length_refresh) + { + gui_line_compute_buffer_max_length (ptr_buffer, + ptr_buffer->mixed_lines); + } + if (ptr_buffer->mixed_lines->prefix_max_length_refresh) + gui_line_compute_prefix_max_length (ptr_buffer->mixed_lines); + } + } + /* refresh window if needed */ if (gui_window_refresh_needed) { diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index 2f8352eb4..5b33a8c58 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -1013,7 +1013,7 @@ gui_buffer_set_short_name (struct t_gui_buffer *buffer, const char *short_name) strdup (short_name) : NULL; if (buffer->mixed_lines) - gui_line_compute_buffer_max_length (buffer, buffer->mixed_lines); + buffer->mixed_lines->buffer_max_length_refresh = 1; gui_buffer_ask_chat_refresh (buffer, 1); hook_signal_send ("buffer_renamed", @@ -2741,9 +2741,8 @@ gui_buffer_unmerge (struct t_gui_buffer *buffer, int number) if (ptr_new_active_buffer) { - gui_line_compute_prefix_max_length (ptr_new_active_buffer->mixed_lines); - gui_line_compute_buffer_max_length (ptr_new_active_buffer, - ptr_new_active_buffer->mixed_lines); + ptr_new_active_buffer->mixed_lines->prefix_max_length_refresh = 1; + ptr_new_active_buffer->mixed_lines->buffer_max_length_refresh = 1; } gui_window_ask_refresh (1); diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index 25f60a74a..9a4330d71 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -180,7 +180,7 @@ gui_filter_buffer (struct t_gui_buffer *buffer, } if (line_data) - gui_line_compute_prefix_max_length (line_data->buffer->lines); + line_data->buffer->lines->prefix_max_length_refresh = 1; if (buffer->lines->lines_hidden != lines_hidden) { diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 33bc86d55..a283312e0 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -68,7 +68,9 @@ gui_lines_alloc () new_lines->first_line_not_read = 0; new_lines->lines_hidden = 0; new_lines->buffer_max_length = 0; + new_lines->buffer_max_length_refresh = 0; new_lines->prefix_max_length = CONFIG_INTEGER(config_look_prefix_align_min); + new_lines->prefix_max_length_refresh = 0; } return new_lines; @@ -711,6 +713,7 @@ gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer, const char *short_name; lines->buffer_max_length = 0; + for (ptr_buffer = gui_buffers; ptr_buffer; ptr_buffer = ptr_buffer->next_buffer) { @@ -722,6 +725,8 @@ gui_line_compute_buffer_max_length (struct t_gui_buffer *buffer, lines->buffer_max_length = length; } } + + lines->buffer_max_length_refresh = 0; } /* @@ -749,6 +754,8 @@ gui_line_compute_prefix_max_length (struct t_gui_lines *lines) lines->prefix_max_length = prefix_length; } } + + lines->prefix_max_length_refresh = 0; } /* @@ -792,7 +799,7 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, { struct t_gui_window *ptr_win; struct t_gui_window_scroll *ptr_scroll; - int update_prefix_max_length, prefix_length, prefix_is_nick; + int prefix_length, prefix_is_nick; for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window) { @@ -815,8 +822,8 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, &prefix_is_nick); if (prefix_is_nick) prefix_length += config_length_nick_prefix_suffix; - update_prefix_max_length = - (prefix_length == lines->prefix_max_length); + if (prefix_length == lines->prefix_max_length) + lines->prefix_max_length_refresh = 1; /* move read marker if it was on line we are removing */ if (lines->last_read_line == line) @@ -853,10 +860,6 @@ gui_line_remove_from_list (struct t_gui_buffer *buffer, lines->lines_count--; free (line); - - /* compute "prefix_max_length" if needed */ - if (update_prefix_max_length) - gui_line_compute_prefix_max_length (lines); } /* @@ -1360,11 +1363,9 @@ gui_line_mix_buffers (struct t_gui_buffer *buffer) } } - /* compute "prefix_max_length" for mixed lines */ - gui_line_compute_prefix_max_length (new_lines); - - /* compute "buffer_max_length" for mixed lines */ - gui_line_compute_buffer_max_length (buffer, new_lines); + /* ask refresh of prefix/buffer max length for mixed lines */ + new_lines->prefix_max_length_refresh = 1; + new_lines->buffer_max_length_refresh = 1; /* free old mixed lines */ if (ptr_buffer_found->mixed_lines) @@ -1407,7 +1408,9 @@ gui_line_hdata_lines_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_lines, first_line_not_read, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_lines, lines_hidden, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_lines, buffer_max_length, INTEGER, 0, NULL, NULL); + HDATA_VAR(struct t_gui_lines, buffer_max_length_refresh, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_lines, prefix_max_length, INTEGER, 0, NULL, NULL); + HDATA_VAR(struct t_gui_lines, prefix_max_length_refresh, INTEGER, 0, NULL, NULL); } return hdata; } @@ -1506,7 +1509,7 @@ gui_line_hdata_line_data_update_cb (void *data, hdata_set (hdata, pointer, "prefix", value); line_data->prefix_length = (line_data->prefix) ? gui_chat_strlen_screen (line_data->prefix) : 0; - gui_line_compute_prefix_max_length (line_data->buffer->lines); + line_data->buffer->lines->prefix_max_length_refresh = 1; rc++; update_coords = 1; } @@ -1654,13 +1657,15 @@ gui_lines_print_log (struct t_gui_lines *lines) { if (lines) { - log_printf (" first_line. . . . . . : 0x%lx", lines->first_line); - log_printf (" last_line . . . . . . : 0x%lx", lines->last_line); - log_printf (" last_read_line. . . . : 0x%lx", lines->last_read_line); - log_printf (" lines_count . . . . . : %d", lines->lines_count); - log_printf (" first_line_not_read . : %d", lines->first_line_not_read); - log_printf (" lines_hidden. . . . . : %d", lines->lines_hidden); - log_printf (" buffer_max_length . . : %d", lines->buffer_max_length); - log_printf (" prefix_max_length . . : %d", lines->prefix_max_length); + log_printf (" first_line . . . . . . . : 0x%lx", lines->first_line); + log_printf (" last_line. . . . . . . . : 0x%lx", lines->last_line); + log_printf (" last_read_line . . . . . : 0x%lx", lines->last_read_line); + log_printf (" lines_count. . . . . . . : %d", lines->lines_count); + log_printf (" first_line_not_read. . . : %d", lines->first_line_not_read); + log_printf (" lines_hidden . . . . . . : %d", lines->lines_hidden); + log_printf (" buffer_max_length. . . . : %d", lines->buffer_max_length); + log_printf (" buffer_max_length_refresh: %d", lines->buffer_max_length_refresh); + log_printf (" prefix_max_length. . . . : %d", lines->prefix_max_length); + log_printf (" prefix_max_length_refresh: %d", lines->prefix_max_length_refresh); } } diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h index d09009380..483e53fce 100644 --- a/src/gui/gui-line.h +++ b/src/gui/gui-line.h @@ -60,7 +60,9 @@ struct t_gui_lines int lines_hidden; /* 1 if at least one line is hidden */ int buffer_max_length; /* max length for buffer name (for */ /* mixed lines only) */ + int buffer_max_length_refresh; /* refresh asked for buffer max len. */ int prefix_max_length; /* max length for prefix align */ + int prefix_max_length_refresh; /* refresh asked for prefix max len. */ }; /* line functions */ |