diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2014-09-25 17:23:20 +0200 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2014-09-25 17:56:22 +0200 |
| commit | 4e60bd39282651d83d7b431239225b1371419b21 (patch) | |
| tree | b5f449d6d4c557402d6617dcee568520cd2e6274 | |
| parent | 830a19f6675fc0e18934afa98fbed0b0dfd48c6e (diff) | |
| download | vis-4e60bd39282651d83d7b431239225b1371419b21.tar.gz vis-4e60bd39282651d83d7b431239225b1371419b21.tar.xz | |
Exit command prompt if last character is deleted
| -rw-r--r-- | config.def.h | 1 | ||||
| -rw-r--r-- | vis.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/config.def.h b/config.def.h index 145c1f1..876e4a4 100644 --- a/config.def.h +++ b/config.def.h @@ -456,6 +456,7 @@ static KeyBinding vis_mode_readline[] = { }; static KeyBinding vis_mode_prompt[] = { + BACKSPACE( prompt_backspace, s, NULL ), { { KEY(ENTER) }, prompt_enter, { NULL } }, { { CONTROL('J') }, prompt_enter, { NULL } }, { { KEY(UP) }, prompt_up, { NULL } }, @@ -422,6 +422,8 @@ static void prompt_enter(const Arg *arg); /* cycle through past user inputs */ static void prompt_up(const Arg *arg); static void prompt_down(const Arg *arg); +/* exit command mode if the last char is deleted */ +static void prompt_backspace(const Arg *arg); /* blocks to read 3 consecutive digits and inserts the corresponding byte value */ static void insert_verbatim(const Arg *arg); /* scroll window content according to arg->i which can be either PAGE, PAGE_HALF, @@ -875,6 +877,15 @@ static void prompt_down(const Arg *arg) { } +static void prompt_backspace(const Arg *arg) { + char *cmd = editor_prompt_get(vis); + if (!cmd || !*cmd) + prompt_enter(NULL); + else + window_backspace_key(vis->win->win); + free(cmd); +} + static void insert_verbatim(const Arg *arg) { int value = 0; for (int i = 0; i < 3; i++) { |
