diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/inputwin.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c index 6dff64ac..cec6ef7d 100644 --- a/src/ui/inputwin.c +++ b/src/ui/inputwin.c @@ -260,6 +260,24 @@ inp_put_back(void) _inp_win_update_virtual(); } +static int +_get_display_length(void) +{ + int len = 0; + gchar *curr = g_utf8_offset_to_pointer(line, 0); + while (*curr != '\0') { + gunichar curru = g_utf8_get_char(curr); + if (g_unichar_iswide(curru)) { + len += 2; + } else { + len ++; + } + curr = g_utf8_next_char(curr); + } + + return len; +} + void inp_replace_input(const char * const new_input) { @@ -304,7 +322,6 @@ _handle_edit(int key_type, const wint_t ch) char *next = NULL; int inp_x = getcurx(inp_win); int next_ch; - int display_size = _get_display_length(); // CTRL-LEFT @@ -785,14 +802,4 @@ _printable(const wint_t ch) bytes[utf_len] = '\0'; gunichar unichar = g_utf8_get_char(bytes); return g_unichar_isprint(unichar) && (ch != KEY_MOUSE); -} - -static int -_get_display_length(void) -{ - if (input_len_bytes != 0) { - return g_utf8_strlen(input, input_len_bytes); - } else { - return 0; - } -} +} \ No newline at end of file |