diff options
author | Simmo Saan <simmo.saan@gmail.com> | 2019-04-13 14:45:53 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-04-13 14:45:53 +0200 |
commit | 97e90469187d1a03d8abbb636f0c30f40d07c713 (patch) | |
tree | e6e3961dbb5f51a02c7674a0f45245897ed86375 /src/gui | |
parent | 63c992922cb386b203680b05d4f1d24ed3442bca (diff) | |
download | weechat-97e90469187d1a03d8abbb636f0c30f40d07c713.zip |
core: add option weechat.look.buffer_time_same (closes #1127)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/curses/gui-curses-chat.c | 76 |
1 files changed, 70 insertions, 6 deletions
diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 91b180ef7..0e255bf47 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -682,6 +682,33 @@ gui_chat_display_day_changed (struct t_gui_window *window, } /* + * Checks if time on line is the same as time on previous line. + * + * Returns: + * 1: time is same as time on previous line + * 0: time is different from time on previous line + */ + +int +gui_chat_line_time_is_same_as_previous (struct t_gui_line *line) +{ + struct t_gui_line *prev_line; + + /* previous line is not found => display standard time */ + prev_line = gui_line_get_prev_displayed (line); + if (!prev_line) + return 0; + + /* previous line has no time => display standard time */ + if (!line->data->str_time || !prev_line->data->str_time) + return 0; + + /* time can be hidden/replaced if times are equal */ + return (strcmp (line->data->str_time, prev_line->data->str_time) == 0) ? + 1 : 0; +} + +/* * Displays time, buffer name (for merged buffers) and prefix for a line. */ @@ -719,12 +746,49 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, { if (window->win_chat_cursor_y < window->coords_size) window->coords[window->win_chat_cursor_y].time_x1 = window->win_chat_cursor_x; - gui_chat_display_word (window, line, line->data->str_time, - NULL, 1, num_lines, count, - pre_lines_displayed, lines_displayed, - simulate, - CONFIG_BOOLEAN(config_look_color_inactive_time), - 0); + + if (CONFIG_STRING(config_look_buffer_time_same) + && CONFIG_STRING(config_look_buffer_time_same)[0] + && gui_chat_line_time_is_same_as_previous (line)) + { + length_allowed = gui_chat_time_length; + num_spaces = length_allowed - gui_chat_strlen_screen ( + config_buffer_time_same_evaluated); + gui_chat_display_word ( + window, line, config_buffer_time_same_evaluated, + (num_spaces < 0) ? + config_buffer_time_same_evaluated + + gui_chat_string_real_pos (config_buffer_time_same_evaluated, + length_allowed, + 1) : + NULL, + 1, num_lines, count, + pre_lines_displayed, lines_displayed, + simulate, + CONFIG_BOOLEAN(config_look_color_inactive_time), + 0); + for (i = 0; i < num_spaces; i++) + { + gui_chat_display_word ( + window, line, str_space, + NULL, 1, num_lines, count, + pre_lines_displayed, lines_displayed, + simulate, + CONFIG_BOOLEAN(config_look_color_inactive_time), + 0); + } + } + else + { + gui_chat_display_word ( + window, line, line->data->str_time, + NULL, 1, num_lines, count, + pre_lines_displayed, lines_displayed, + simulate, + CONFIG_BOOLEAN(config_look_color_inactive_time), + 0); + } + if (window->win_chat_cursor_y < window->coords_size) window->coords[window->win_chat_cursor_y].time_x2 = window->win_chat_cursor_x - 1; |