summaryrefslogtreecommitdiff
path: root/src/gui/gui-chat.c
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-09-21 13:54:36 +0200
committerSébastien Helleu <flashcode@flashtux.org>2019-09-21 13:54:36 +0200
commite1a461279731877ad66298d9c0576997474453af (patch)
treedeb81f9f0b023a969e3592d15936aecdec3907cc /src/gui/gui-chat.c
parentde456363882d54f18d6fd8614c6d5431d7402824 (diff)
downloadweechat-e1a461279731877ad66298d9c0576997474453af.zip
core: ignore color codes in ${length:xxx} and ${lengthscr:xxx}
Diffstat (limited to 'src/gui/gui-chat.c')
-rw-r--r--src/gui/gui-chat.c24
1 files changed, 24 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).
*/