diff --git a/src/gui/curses/gui-curses-chat.c b/src/gui/curses/gui-curses-chat.c index 09f426830..57f4e5313 100644 --- a/src/gui/curses/gui-curses-chat.c +++ b/src/gui/curses/gui-curses-chat.c @@ -438,7 +438,8 @@ gui_chat_display_word (struct t_gui_window *window, while (ptr_data && ptr_data[0]) { /* insert spaces for aligning text under time/nick */ - length_align = gui_line_get_align (window->buffer, line, 0, 0); + length_align = gui_line_get_align (window->buffer, line, 0, 0, + GUI_WINDOW_OBJECTS(window)->force_prefix_for_line); if ((window->win_chat_cursor_x == 0) && (*lines_displayed > 0) /* FIXME: modify arbitraty value for non aligning messages on time/nick? */ @@ -739,8 +740,17 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window, } /* get prefix for display */ - gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length, - &ptr_prefix_color); + if (GUI_WINDOW_OBJECTS(window)->force_prefix_for_line) + { + ptr_prefix = line->data->prefix; + prefix_length = line->data->prefix_length; + ptr_prefix_color = NULL; + } + else + { + gui_line_get_prefix_for_display (line, &ptr_prefix, &prefix_length, + &ptr_prefix_color); + } if (ptr_prefix) { ptr_prefix2 = NULL; @@ -971,6 +981,17 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, if (!line) return 0; + if ((count == 0) && !GUI_WINDOW_OBJECTS(window)->first_line_with_prefix) + { + GUI_WINDOW_OBJECTS(window)->first_line_with_prefix = line; + GUI_WINDOW_OBJECTS(window)->force_prefix_for_line = 1; + } + else + { + if (line != GUI_WINDOW_OBJECTS(window)->first_line_with_prefix) + GUI_WINDOW_OBJECTS(window)->force_prefix_for_line = 0; + } + if (simulate) { x = window->win_chat_cursor_x; @@ -1055,7 +1076,8 @@ gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, { /* spaces + word too long for current line but ok for next line */ line_align = gui_line_get_align (window->buffer, line, 1, - (lines_displayed == 0) ? 1 : 0); + (lines_displayed == 0) ? 1 : 0, + GUI_WINDOW_OBJECTS(window)->force_prefix_for_line); if ((window->win_chat_cursor_x + word_length_with_spaces > gui_chat_get_real_width (window)) && (word_length <= gui_chat_get_real_width (window) - line_align)) { @@ -1310,6 +1332,8 @@ gui_chat_draw_formatted_buffer (struct t_gui_window *window) struct t_gui_line *ptr_line; int line_pos, count, old_scrolling, old_lines_after; + GUI_WINDOW_OBJECTS(window)->first_line_with_prefix = NULL; + /* display at position of scrolling */ if (window->scroll->start_line) { @@ -1326,6 +1350,7 @@ gui_chat_draw_formatted_buffer (struct t_gui_window *window) } count = 0; + GUI_WINDOW_OBJECTS(window)->first_line_with_prefix = NULL; if (line_pos > 0) { @@ -1343,6 +1368,7 @@ gui_chat_draw_formatted_buffer (struct t_gui_window *window) (ptr_line == gui_line_get_first_displayed (window->buffer)); /* display lines */ + GUI_WINDOW_OBJECTS(window)->first_line_with_prefix = NULL; while (ptr_line && (window->win_chat_cursor_y <= window->win_chat_height - 1)) { count = gui_chat_display_line (window, ptr_line, 0, 0); diff --git a/src/gui/curses/gui-curses-window.c b/src/gui/curses/gui-curses-window.c index 5569e058e..b62d3719d 100644 --- a/src/gui/curses/gui-curses-window.c +++ b/src/gui/curses/gui-curses-window.c @@ -2333,6 +2333,8 @@ void gui_window_objects_print_log (struct t_gui_window *window) { log_printf (" window specific objects for Curses:"); - log_printf (" win_chat. . . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->win_chat); - log_printf (" win_separator . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->win_separator); + log_printf (" win_chat. . . . . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->win_chat); + log_printf (" win_separator . . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->win_separator); + log_printf (" first_line_with_prefix: 0x%lx", GUI_WINDOW_OBJECTS(window)->first_line_with_prefix); + log_printf (" force_prefix_for_line : %d", GUI_WINDOW_OBJECTS(window)->force_prefix_for_line); } diff --git a/src/gui/curses/gui-curses.h b/src/gui/curses/gui-curses.h index 649803ecf..78b04a388 100644 --- a/src/gui/curses/gui-curses.h +++ b/src/gui/curses/gui-curses.h @@ -49,6 +49,10 @@ struct t_gui_window_curses_objects { WINDOW *win_chat; /* chat window (example: channel) */ WINDOW *win_separator; /* separation between 2 split (V) win */ + struct t_gui_line *first_line_with_prefix; + /* first (full) line displayed with a */ + /* prefix (for opt "prefix_same_nick") */ + int force_prefix_for_line; /* =1 if prefix is displayed for line */ }; struct t_gui_bar_window_curses_objects diff --git a/src/gui/gui-line.c b/src/gui/gui-line.c index 23399e822..074ba46aa 100644 --- a/src/gui/gui-line.c +++ b/src/gui/gui-line.c @@ -199,7 +199,7 @@ gui_line_get_prefix_for_display (struct t_gui_line *line, int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, - int with_suffix, int first_line) + int with_suffix, int first_line, int force_prefix_for_line) { int length_time, length_buffer, length_suffix, prefix_length; @@ -251,7 +251,10 @@ gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, return length_time + length_buffer; } - gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL); + if (force_prefix_for_line) + prefix_length = line->data->prefix_length; + else + gui_line_get_prefix_for_display (line, NULL, &prefix_length, NULL); if (CONFIG_INTEGER(config_look_prefix_align) == CONFIG_LOOK_PREFIX_ALIGN_NONE) { diff --git a/src/gui/gui-line.h b/src/gui/gui-line.h index 59ce95973..27c5b2937 100644 --- a/src/gui/gui-line.h +++ b/src/gui/gui-line.h @@ -72,7 +72,8 @@ extern void gui_line_get_prefix_for_display (struct t_gui_line *line, char **color); extern int gui_line_get_align (struct t_gui_buffer *buffer, struct t_gui_line *line, - int with_suffix, int first_line); + int with_suffix, int first_line, + int force_prefix_for_line); extern int gui_line_is_displayed (struct t_gui_line *line); extern struct t_gui_line *gui_line_get_first_displayed (struct t_gui_buffer *buffer); extern struct t_gui_line *gui_line_get_last_displayed (struct t_gui_buffer *buffer);