1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

core: force display of prefix on first line displayed in window (even if it should be hidden by option weechat.look.prefix_same_nick)

This commit is contained in:
Sebastien Helleu
2012-05-22 07:59:59 +02:00
parent 0d73475c52
commit 04e98c3f29
5 changed files with 45 additions and 9 deletions
+30 -4
View File
@@ -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);
+4 -2
View File
@@ -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);
}
+4
View File
@@ -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
+5 -2
View File
@@ -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)
{
+2 -1
View File
@@ -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);