about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2018-02-09 22:48:55 +0000
committerJames Booth <boothj5@gmail.com>2018-02-09 22:48:55 +0000
commitad76495267c2a2f9a11130eda83a3c7a7b67470f (patch)
tree6769bceb089b4076baa4a5e12e0e69416a973134
parentd65fc24658c019601fc6f4365dde578a6b397e58 (diff)
downloadprofani-tty-ad76495267c2a2f9a11130eda83a3c7a7b67470f.tar.gz
Clear autocompletes on line edits
-rw-r--r--src/ui/inputwin.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ui/inputwin.c b/src/ui/inputwin.c
index c6403bad..0173a201 100644
--- a/src/ui/inputwin.c
+++ b/src/ui/inputwin.c
@@ -87,7 +87,7 @@ static char *inp_line = NULL;
 static gboolean get_password = FALSE;
 
 static void _inp_win_update_virtual(void);
-static int _inp_printable(const wint_t ch);
+static int _inp_edited(const wint_t ch);
 static void _inp_win_handle_scroll(void);
 static int _inp_offset_to_col(char *str, int offset);
 static void _inp_write(char *line, int offset);
@@ -301,8 +301,24 @@ _inp_write(char *line, int offset)
 }
 
 static int
-_inp_printable(const wint_t ch)
+_inp_edited(const wint_t ch)
 {
+    // backspace
+    if (ch == 127) {
+        return 1;
+    }
+
+    // ctrl-w
+    if (ch == 23) {
+        return 1;
+    }
+
+    // enter
+    if (ch == 13) {
+        return 1;
+    }
+
+    // printable
     char bytes[MB_CUR_MAX+1];
     size_t utf_len = wcrtomb(bytes, ch, (mbstate_t*)NULL);
     bytes[utf_len] = '\0';
@@ -472,7 +488,7 @@ _inp_rl_getc(FILE *stream)
 
     shift_tab = FALSE;
 
-    if (_inp_printable(ch)) {
+    if (_inp_edited(ch)) {
         ProfWin *window = wins_get_current();
         cmd_ac_reset(window);
     }