Fix display bug with some weird UTF-8 chars (bugs #19687 and #23943)

This commit is contained in:
Sebastien Helleu 2008-07-28 18:20:13 +02:00
parent 8218151c31
commit 43029de8f5
4 changed files with 36 additions and 25 deletions

View File

@ -1,10 +1,11 @@
WeeChat - Wee Enhanced Environment for Chat WeeChat - Wee Enhanced Environment for Chat
=========================================== ===========================================
ChangeLog - 2008-07-06 ChangeLog - 2008-07-28
Version 0.2.7 (under dev!): Version 0.2.7 (under dev!):
* fix display bug with some weird UTF-8 chars (bug #19687)
* fix bug with wide chars in input (bug #16356) * fix bug with wide chars in input (bug #16356)
* add number of lines remaining after last line displayed in "-MORE-" * add number of lines remaining after last line displayed in "-MORE-"
indicator (task #6702) indicator (task #6702)

View File

@ -787,6 +787,8 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
snprintf (utf_char, sizeof (utf_char), "."); snprintf (utf_char, sizeof (utf_char), ".");
size_on_screen = utf8_char_size_screen (utf_char); size_on_screen = utf8_char_size_screen (utf_char);
if (size_on_screen > 0)
{
if (*x + size_on_screen > bar_window->width) if (*x + size_on_screen > bar_window->width)
{ {
if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_VERTICAL) if (CONFIG_INTEGER(gui_bar_get_option_filling (bar_window->bar)) == GUI_BAR_FILLING_VERTICAL)
@ -802,8 +804,8 @@ gui_bar_window_print_string (struct t_gui_bar_window *bar_window,
(output) ? output : utf_char); (output) ? output : utf_char);
if (output) if (output)
free (output); free (output);
*x += size_on_screen; *x += size_on_screen;
}
string = next_char; string = next_char;
} }

View File

@ -446,19 +446,22 @@ gui_chat_display_word_raw (struct t_gui_window *window, const char *string,
utf_char[next_char - string] = '\0'; utf_char[next_char - string] = '\0';
if (gui_window_utf_char_valid (utf_char)) if (gui_window_utf_char_valid (utf_char))
{ {
size_on_screen = utf8_strlen_screen (utf_char);
if (max_chars_on_screen > 0) if (max_chars_on_screen > 0)
{ {
size_on_screen = utf8_strlen_screen (utf_char);
if (chars_displayed + size_on_screen > max_chars_on_screen) if (chars_displayed + size_on_screen > max_chars_on_screen)
return; return;
chars_displayed += size_on_screen; chars_displayed += size_on_screen;
} }
if (size_on_screen > 0)
{
output = string_iconv_from_internal (NULL, utf_char); output = string_iconv_from_internal (NULL, utf_char);
wprintw (GUI_CURSES(window)->win_chat, wprintw (GUI_CURSES(window)->win_chat,
"%s", (output) ? output : utf_char); "%s", (output) ? output : utf_char);
if (output) if (output)
free (output); free (output);
} }
}
else else
{ {
if (max_chars_on_screen > 0) if (max_chars_on_screen > 0)

View File

@ -121,7 +121,7 @@ gui_chat_prefix_build ()
int int
gui_chat_strlen_screen (const char *string) gui_chat_strlen_screen (const char *string)
{ {
int length; int length, size_on_screen;
length = 0; length = 0;
while (string && string[0]) while (string && string[0])
@ -129,7 +129,9 @@ gui_chat_strlen_screen (const char *string)
string = gui_chat_string_next_char (NULL, (unsigned char *)string, 0); string = gui_chat_string_next_char (NULL, (unsigned char *)string, 0);
if (string) if (string)
{ {
length += utf8_char_size_screen (string); size_on_screen = utf8_char_size_screen (string);
if (size_on_screen > 0)
length += size_on_screen;
string = utf8_next_char (string); string = utf8_next_char (string);
} }
} }
@ -167,6 +169,7 @@ int
gui_chat_string_real_pos (const char *string, int pos) gui_chat_string_real_pos (const char *string, int pos)
{ {
const char *real_pos, *ptr_string; const char *real_pos, *ptr_string;
int size_on_screen;
if (pos <= 0) if (pos <= 0)
return 0; return 0;
@ -180,7 +183,9 @@ gui_chat_string_real_pos (const char *string, int pos)
0); 0);
if (ptr_string) if (ptr_string)
{ {
pos -= utf8_char_size_screen (ptr_string); size_on_screen = utf8_char_size_screen (ptr_string);
if (size_on_screen > 0)
pos -= size_on_screen;
ptr_string = utf8_next_char (ptr_string); ptr_string = utf8_next_char (ptr_string);
real_pos = ptr_string; real_pos = ptr_string;
} }