summaryrefslogtreecommitdiff
path: root/src/gui/gtk
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-05-08 13:26:08 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-05-08 13:26:08 +0000
commit93e69f5b3efec9ddc9198e7bb4d5f06af19bad28 (patch)
treea08da159aaad979702e350a5dae21c77683437a7 /src/gui/gtk
parentbeb846884c0699220009cde0749f4e2f7590de3e (diff)
downloadweechat-93e69f5b3efec9ddc9198e7bb4d5f06af19bad28.zip
Fixed UTF-8 display bug with chars using more than one cell on screen (bug #16356)
Diffstat (limited to 'src/gui/gtk')
-rw-r--r--src/gui/gtk/gui-gtk-chat.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c
index 15ed9dc63..90624a000 100644
--- a/src/gui/gtk/gui-gtk-chat.c
+++ b/src/gui/gtk/gui-gtk-chat.c
@@ -191,10 +191,14 @@ gui_chat_draw_title (t_gui_buffer *buffer, int erase)
*/
char *
-gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string, int apply_style)
+gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string,
+ int apply_style, int *width_screen)
{
- char str_fg[3], str_bg[3];
- int fg, bg, weechat_color;
+ char str_fg[3], str_bg[3], utf_char[16];
+ int fg, bg, weechat_color, char_size;
+
+ if (width_screen)
+ *width_screen = 0;
while (string[0])
{
@@ -344,7 +348,16 @@ gui_chat_word_get_next_char (t_gui_window *window, unsigned char *string, int ap
if (string[0] < 32)
string++;
else
- return utf8_next_char ((char *)string);
+ {
+ char_size = utf8_char_size ((char *) string);
+ if (width_screen)
+ {
+ memcpy (utf_char, string, char_size);
+ utf_char[char_size] = '\0';
+ *width_screen = utf8_width_screen (utf_char);
+ }
+ return (char *)string + char_size;
+ }
}
}
@@ -416,7 +429,9 @@ gui_chat_get_word_info (t_gui_window *window,
leading_spaces = 1;
while (data && data[0])
{
- next_char = gui_chat_word_get_next_char (window, (unsigned char *)data, 0);
+ next_char = gui_chat_word_get_next_char (window,
+ (unsigned char *)data,
+ 0, NULL);
if (next_char)
{
prev_char = utf8_prev_char (data, next_char);