tAllow backspace in prompt - ve - a minimal text editor (work in progress)
HTML git clone git://src.adamsgaard.dk/ve
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 571d507abc7fd2099ec09d42702e20d541759417
DIR parent 0bcce6ea7409b475034ddaf2e79439468b161869
HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
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(-)
---
DIR 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;