tAllow backspace in prompt - ve - a minimal text editor (work in progress) | |
git clone git://src.adamsgaard.dk/ve | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 571d507abc7fd2099ec09d42702e20d541759417 | |
parent 0bcce6ea7409b475034ddaf2e79439468b161869 | |
Author: Anders Damsgaard <[email protected]> | |
Date: Tue, 6 Aug 2019 21:13:31 +0200 | |
Allow backspace in prompt | |
Diffstat: | |
M input.c | 5 ++++- | |
1 file changed, 4 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/input.c b/input.c | |
t@@ -28,7 +28,10 @@ editor_prompt(char *prompt) | |
editor_refresh_screen(); | |
c = editor_read_key(); | |
- if (c == '\x1b') { /* detect escape */ | |
+ if (c == CTRL_KEY('h') || c == 127) { | |
+ if (buflen != 0) | |
+ buf[--buflen] = '\0'; | |
+ } else if (c == '\x1b') { /* detect escape */ | |
editor_set_status_message(""); | |
free(buf); | |
return NULL; |