shithub: orca

Download patch

ref: 9726a85360686e7f1d0033c3e520d87c6273b8bc
parent: c02b2618969584ea563f1df1608dc923de639af1
author: cancel <cancel@cancel.fm>
date: Mon Dec 10 23:54:06 EST 2018

Add rejection of invalid glyphs for tui input

--- a/tui_main.c
+++ b/tui_main.c
@@ -124,6 +124,25 @@
   return Glyph_class_unknown;
 }
 
+static bool is_valid_glyph(Glyph c) {
+  if (c >= '0' && c <= '9')
+    return true;
+  if (c >= 'A' && c <= 'Z')
+    return true;
+  if (c >= 'a' && c <= 'z')
+    return true;
+  switch (c) {
+  case '!':
+  case '.':
+  case '*':
+  case ':':
+  case ';':
+  case '#':
+    return true;
+  }
+  return false;
+}
+
 static int term_attrs_of_cell(Glyph g, Mark m) {
   Glyph_class gclass = glyph_class_of(g);
   int attr = A_normal;
@@ -1587,7 +1606,7 @@
       app_state.is_draw_dirty = true;
       break;
     default:
-      if (key >= '!' && key <= '~') {
+      if (key >= CHAR_MIN && key <= CHAR_MAX && is_valid_glyph((Glyph)key)) {
         app_input_character(&app_state, (char)key);
       }
       break;