1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-25 04:16:38 +02:00

core: fix display bug with prefix when length is greater than max and prefix is ending with a wide char (bug #36032)

This commit is contained in:
Sebastien Helleu
2012-03-29 16:36:51 +02:00
parent ae2c97b8cb
commit 10df976e53
2 changed files with 57 additions and 28 deletions
+2
View File
@@ -7,6 +7,8 @@ v0.3.8-dev, 2012-03-29
Version 0.3.8 (under dev!)
--------------------------
* core: fix display bug with prefix when length is greater than max and prefix
is ending with a wide char (bug #36032)
* core: add option weechat.look.prefix_same_nick (hide or change prefix on
messages whose nick is the same as previous message) (task #11965)
* core: convert tabs to spaces in text pasted (bug #25028)
+55 -28
View File
@@ -395,9 +395,10 @@ gui_chat_display_word_raw (struct t_gui_window *window, struct t_gui_line *line,
/*
* gui_chat_display_word: display a word on chat buffer
* return number of chars displayed on screen
*/
void
int
gui_chat_display_word (struct t_gui_window *window,
struct t_gui_line *line,
const char *word, const char *word_end,
@@ -406,23 +407,25 @@ gui_chat_display_word (struct t_gui_window *window,
int apply_style_inactive)
{
char *data, *ptr_data, *end_line, saved_char, str_space[] = " ";
int pos_saved_char, chars_to_display, num_displayed;
int chars_displayed, pos_saved_char, chars_to_display, num_displayed;
int length_align;
attr_t attrs;
attr_t *ptr_attrs;
short pair;
short *ptr_pair;
chars_displayed = 0;
if (!word ||
((!simulate) && (window->win_chat_cursor_y >= window->win_chat_height)))
return;
return chars_displayed;
if (!simulate && (window->win_chat_cursor_y < window->coords_size))
window->coords[window->win_chat_cursor_y].line = line;
data = strdup (word);
if (!data)
return;
return chars_displayed;
end_line = data + strlen (data);
@@ -463,15 +466,18 @@ gui_chat_display_word (struct t_gui_window *window,
gui_window_save_style ();
gui_window_set_weechat_color (GUI_WINDOW_OBJECTS(window)->win_chat,
GUI_COLOR_CHAT_PREFIX_SUFFIX);
gui_chat_display_word_raw (window, line,
CONFIG_STRING(config_look_prefix_suffix),
0, 1, apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
CONFIG_STRING(config_look_prefix_suffix),
0, 1,
apply_style_inactive);
}
window->win_chat_cursor_x += gui_chat_strlen_screen (CONFIG_STRING(config_look_prefix_suffix));
if (!simulate)
{
gui_chat_display_word_raw (window, line, str_space, 0, 1,
apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
str_space,
0, 1,
apply_style_inactive);
}
window->win_chat_cursor_x += gui_chat_strlen_screen (str_space);
if (!simulate)
@@ -497,13 +503,17 @@ gui_chat_display_word (struct t_gui_window *window,
ptr_data[pos_saved_char] = '\0';
if ((count == 0) || (*lines_displayed >= num_lines - count))
{
gui_chat_display_word_raw (window, line, ptr_data, 0, 1,
apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
ptr_data,
0, 1,
apply_style_inactive);
}
else
{
gui_chat_display_word_raw (window, line, ptr_data, 0, 0,
apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
ptr_data,
0, 0,
apply_style_inactive);
}
ptr_data[pos_saved_char] = saved_char;
}
@@ -516,13 +526,17 @@ gui_chat_display_word (struct t_gui_window *window,
{
if ((count == 0) || (*lines_displayed >= num_lines - count))
{
gui_chat_display_word_raw (window, line, ptr_data, 0, 1,
apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
ptr_data,
0, 1,
apply_style_inactive);
}
else
{
gui_chat_display_word_raw (window, line, ptr_data, 0, 0,
apply_style_inactive);
chars_displayed += gui_chat_display_word_raw (window, line,
ptr_data,
0, 0,
apply_style_inactive);
}
}
ptr_data += strlen (ptr_data);
@@ -544,6 +558,8 @@ gui_chat_display_word (struct t_gui_window *window,
}
free (data);
return chars_displayed;
}
/*
@@ -561,7 +577,8 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
char str_space[] = " ", str_plus[] = "+";
char *prefix_no_color, *prefix_highlighted, *ptr_prefix;
const char *short_name;
int i, length, length_allowed, num_spaces, prefix_length;
int i, length, length_allowed, num_spaces, prefix_length, extra_spaces;
int chars_displayed;
struct t_gui_lines *mixed_lines;
if (!simulate)
@@ -804,19 +821,22 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
window->coords[window->win_chat_cursor_y].prefix_x1 = window->win_chat_cursor_x;
/* not enough space to display full prefix? => truncate it! */
extra_spaces = 0;
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (num_spaces < 0))
{
gui_chat_display_word (window, line,
(prefix_highlighted) ? prefix_highlighted : ptr_prefix,
(prefix_highlighted) ?
prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted,
length_allowed) :
ptr_prefix + gui_chat_string_real_pos (ptr_prefix,
length_allowed),
1, num_lines, count, lines_displayed,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
chars_displayed = gui_chat_display_word (window, line,
(prefix_highlighted) ? prefix_highlighted : ptr_prefix,
(prefix_highlighted) ?
prefix_highlighted + gui_chat_string_real_pos (prefix_highlighted,
length_allowed) :
ptr_prefix + gui_chat_string_real_pos (ptr_prefix,
length_allowed),
1, num_lines, count, lines_displayed,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
if (chars_displayed < length_allowed)
extra_spaces = length_allowed - chars_displayed;
}
else
{
@@ -876,6 +896,13 @@ gui_chat_display_time_to_prefix (struct t_gui_window *window,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
}
}
for (i = 0; i < extra_spaces; i++)
{
gui_chat_display_word (window, line, str_space,
NULL, 1, num_lines, count, lines_displayed,
simulate,
CONFIG_BOOLEAN(config_look_color_inactive_prefix));
}
if ((CONFIG_INTEGER(config_look_prefix_align) != CONFIG_LOOK_PREFIX_ALIGN_NONE)
&& (CONFIG_STRING(config_look_prefix_suffix)
&& CONFIG_STRING(config_look_prefix_suffix)[0]))