about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-07 20:31:24 +0000
committerJames Booth <boothj5@gmail.com>2013-01-07 20:31:24 +0000
commit268a2f553b748e05f8d452b5a22ebc988f730479 (patch)
tree072ef5f7f112671a8c0814b92ca65c3218d1e6d4
parent8f5826b25613555cdf8d22d484609be5b1687c42 (diff)
downloadprofani-tty-268a2f553b748e05f8d452b5a22ebc988f730479.tar.gz
Revert "Temp fix for handling printable characters"
This reverts commit 8f5826b25613555cdf8d22d484609be5b1687c42.
-rw-r--r--src/input_win.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/input_win.c b/src/input_win.c
index b7325c57..554f939e 100644
--- a/src/input_win.c
+++ b/src/input_win.c
@@ -51,6 +51,7 @@ static int rows, cols;
 
 static int _handle_edit(const wint_t ch, char *input, int *size);
 static int _printable(const wint_t ch);
+static gboolean _special_key(const wint_t ch);
 static void _clear_input(void);
 static void _go_to_end(int display_size);
 
@@ -464,10 +465,19 @@ _go_to_end(int display_size)
 static int
 _printable(const wint_t ch)
 {
-    char bytes[MB_CUR_MAX+1];
-    size_t utf_len = wcrtomb(bytes, ch, NULL);
-    bytes[utf_len] = '\0';
+   return (ch != ERR && ch != '\n' &&
+            ch != KEY_PPAGE && ch != KEY_NPAGE && ch != KEY_MOUSE &&
+            ch != KEY_F(1) && ch != KEY_F(2) && ch != KEY_F(3) &&
+            ch != KEY_F(4) && ch != KEY_F(5) && ch != KEY_F(6) &&
+            ch != KEY_F(7) && ch != KEY_F(8) && ch != KEY_F(9) &&
+            ch != KEY_F(10) && ch!= KEY_F(11) && ch != KEY_F(12) &&
+            ch != KEY_IC && ch != KEY_EIC && ch != KEY_RESIZE &&
+            !_special_key(ch));
+}
 
-    gunichar unichar = g_utf8_get_char(bytes);
-    return g_unichar_isprint(unichar) && (ch != KEY_MOUSE);
+static gboolean
+_special_key(const wint_t ch)
+{
+    char *str = unctrl(ch);
+    return ((strlen(str) > 1) && g_str_has_prefix(str, "^"));
 }