summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui-chat.c24
-rw-r--r--src/gui/gui-chat.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/gui/gui-chat.c b/src/gui/gui-chat.c
index 687e17686..fe2f07504 100644
--- a/src/gui/gui-chat.c
+++ b/src/gui/gui-chat.c
@@ -167,6 +167,30 @@ gui_chat_char_size_screen (const char *utf_char)
}
/*
+ * Returns number of char in a string (special chars like colors/attributes are
+ * ignored).
+ */
+
+int
+gui_chat_strlen (const char *string)
+{
+ int length;
+
+ length = 0;
+ while (string && string[0])
+ {
+ string = gui_chat_string_next_char (NULL, NULL,
+ (unsigned char *)string, 0, 0, 0);
+ if (string)
+ {
+ length++;
+ string = utf8_next_char (string);
+ }
+ }
+ return length;
+}
+
+/*
* Returns number of char needed on screen to display a word (special chars like
* colors/attributes are ignored).
*/
diff --git a/src/gui/gui-chat.h b/src/gui/gui-chat.h
index b72e21b83..2f4f9ae03 100644
--- a/src/gui/gui-chat.h
+++ b/src/gui/gui-chat.h
@@ -69,6 +69,7 @@ extern int gui_chat_display_tags;
extern void gui_chat_init ();
extern void gui_chat_prefix_build ();
extern int gui_chat_utf_char_valid (const char *utf_char);
+extern int gui_chat_strlen (const char *string);
extern int gui_chat_strlen_screen (const char *string);
extern const char *gui_chat_string_add_offset (const char *string, int offset);
extern const char *gui_chat_string_add_offset_screen (const char *string,