about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2015-02-03 21:04:51 +0000
committerJames Booth <boothj5@gmail.com>2015-02-03 21:04:51 +0000
commit836fdd2eb1fdba1dab6bd2b93ad65deb64185dd5 (patch)
tree6e59d0ff391c786351311c1918c4bd60397bd84a /src
parent1c157b04df75a71672d97ba970fc1a24a2f10a3c (diff)
downloadprofani-tty-836fdd2eb1fdba1dab6bd2b93ad65deb64185dd5.tar.gz
Remove state passed to wide char len check
Diffstat (limited to 'src')
-rw-r--r--src/ui/inputwin.c40
1 files changed, 19 insertions, 21 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index 02278adf..9321706a 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -334,26 +334,6 @@ inp_win_resize(void)
     _inp_win_update_virtual();
 }
 
-static int
-offset_to_col(char *str, int offset)
-{
-    int i = 0;
-    int col = 0;
-    mbstate_t internal;
-
-    while (i != offset && str[i] != '\n') {
-        gunichar uni = g_utf8_get_char(&str[i]);
-        size_t ch_len = mbrlen(&str[i], 4, &internal);
-        i += ch_len;
-        col++;
-        if (g_unichar_iswide(uni)) {
-            col++;
-        }
-    }
-
-    return col;
-}
-
 void
 inp_nonblocking(gboolean reset)
 {
@@ -406,6 +386,25 @@ inp_win_handle_scroll(void)
     }
 }
 
+int
+offset_to_col(char *str, int offset)
+{
+    int i = 0;
+    int col = 0;
+
+    while (i < offset && str[i] != '\0') {
+        gunichar uni = g_utf8_get_char(&str[i]);
+        size_t ch_len = mbrlen(&str[i], 4, NULL);
+        i += ch_len;
+        col++;
+        if (g_unichar_iswide(uni)) {
+            col++;
+        }
+    }
+
+    return col;
+}
+
 void
 inp_write(char *line, int offset)
 {
@@ -437,7 +436,6 @@ inp_readline(void)
         }
 
         ui_reset_idle_time();
-        cons_show("");
         inp_write(rl_line_buffer, rl_point);
         inp_nonblocking(TRUE);
     } else {