summaryrefslogtreecommitdiff
path: root/src/gui/gui-chat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui-chat.c')
-rw-r--r--src/gui/gui-chat.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 3d4bfd5ba..6e72682ba 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -121,7 +121,7 @@ gui_chat_prefix_build ()
int
gui_chat_strlen_screen (const char *string)
{
- int length;
+ int length, size_on_screen;
length = 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);
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);
}
}
@@ -167,6 +169,7 @@ int
gui_chat_string_real_pos (const char *string, int pos)
{
const char *real_pos, *ptr_string;
+ int size_on_screen;
if (pos <= 0)
return 0;
@@ -180,7 +183,9 @@ gui_chat_string_real_pos (const char *string, int pos)
0);
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);
real_pos = ptr_string;
}