From 5538578820550c1a62dc4d0e6451332229eeee75 Mon Sep 17 00:00:00 2001 From: Xavier G Date: Fri, 13 May 2016 01:26:33 +0200 Subject: Move utf8.{h,c} from fe-common/core to core. --- src/fe-text/term.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fe-text') diff --git a/src/fe-text/term.h b/src/fe-text/term.h index 9b726d82..0c7847f6 100644 --- a/src/fe-text/term.h +++ b/src/fe-text/term.h @@ -27,7 +27,7 @@ typedef struct _TERM_WINDOW TERM_WINDOW; #define TERM_TYPE_UTF8 1 #define TERM_TYPE_BIG5 2 -typedef guint32 unichar; +#include "utf8.h" extern TERM_WINDOW *root_window; extern int term_width, term_height; -- cgit v1.2.3 From 21c07c006066115af4604e26cd89cf60f94a7d53 Mon Sep 17 00:00:00 2001 From: Xavier G Date: Fri, 13 May 2016 02:27:19 +0200 Subject: Leverage string_policy(). --- src/fe-text/gui-entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/fe-text') diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 63dda34e..beea2273 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -367,7 +367,7 @@ static int scrlen_str(const char *str) g_return_val_if_fail(str != NULL, 0); str = stripped = strip_codes(str); - if (is_utf8() && g_utf8_validate(str, -1, NULL)) { + if (string_policy(str) == TREAT_STRING_AS_UTF8) { while (*str != '\0') { gunichar c; -- cgit v1.2.3 From 72064de9fe064a7536b501fc470edf75fc393314 Mon Sep 17 00:00:00 2001 From: Xavier G Date: Fri, 13 May 2016 04:19:38 +0200 Subject: Simplify scrlen_str() using string_width(). --- src/fe-text/gui-entry.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/fe-text') diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index beea2273..949a43d3 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -366,22 +366,8 @@ static int scrlen_str(const char *str) char *stripped; g_return_val_if_fail(str != NULL, 0); - str = stripped = strip_codes(str); - if (string_policy(str) == TREAT_STRING_AS_UTF8) { - - 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); - } - + stripped = strip_codes(str); + len = string_width(stripped, -1); g_free(stripped); return len; } -- cgit v1.2.3