working on esc backspace

This commit is contained in:
Kyle Isom 2020-02-18 07:45:52 -08:00
parent 2fa985dc25
commit 63319f3d35
1 changed files with 19 additions and 1 deletions

View File

@ -713,7 +713,7 @@ editor_prompt(char *prompt, void (*cb)(char *, int16_t))
if (buflen != 0) { if (buflen != 0) {
buf[--buflen] = '\0'; buf[--buflen] = '\0';
} }
} else if (c == ESC_KEY) { } else if (c == ESC_KEY || c == CTRL_KEY('g')) {
editor_set_status(""); editor_set_status("");
if (cb) { if (cb) {
cb(buf, c); cb(buf, c);
@ -1058,6 +1058,10 @@ process_normal(int16_t c)
void void
process_escape(int16_t c) process_escape(int16_t c)
{ {
struct erow *row = &editor.row[editor.cury];
editor_set_status("hi");
switch (c) { switch (c) {
case '>': case '>':
editor.cury = editor.nrows; editor.cury = editor.nrows;
@ -1066,6 +1070,20 @@ process_escape(int16_t c)
case '<': case '<':
editor.cury = 0; editor.cury = 0;
editor.curx = 0; editor.curx = 0;
break;
case BACKSPACE:
if (isalnum(row->line[editor.curx])) {
editor_set_status("is alnum");
while (editor.curx > 0 && isalnum(row->line[editor.curx])) {
process_normal(BACKSPACE);
}
} else {
editor_set_status("not alnum");
process_normal(BACKSPACE);
}
break;
default:
editor_set_status("unknown ESC key: %04x", c);
} }
} }