mirror of
https://github.com/irssi/irssi.git
synced 2026-08-20 09:02:13 +02:00
Simplify scrlen_str() using string_width().
This commit is contained in:
parent
29beafcf6f
commit
72064de9fe
1 changed files with 2 additions and 16 deletions
|
|
@ -366,22 +366,8 @@ static int scrlen_str(const char *str)
|
||||||
char *stripped;
|
char *stripped;
|
||||||
g_return_val_if_fail(str != NULL, 0);
|
g_return_val_if_fail(str != NULL, 0);
|
||||||
|
|
||||||
str = stripped = strip_codes(str);
|
stripped = strip_codes(str);
|
||||||
if (string_policy(str) == TREAT_STRING_AS_UTF8) {
|
len = string_width(stripped, -1);
|
||||||
|
|
||||||
while (*str != '\0') {
|
|
||||||
gunichar c;
|
|
||||||
|
|
||||||
c = g_utf8_get_char(str);
|
|
||||||
str = g_utf8_next_char(str);
|
|
||||||
|
|
||||||
len += unichar_isprint(c) ? mk_wcwidth(c) : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
len = strlen(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free(stripped);
|
g_free(stripped);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue