From 4e60bd39282651d83d7b431239225b1371419b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 25 Sep 2014 17:23:20 +0200 Subject: Exit command prompt if last character is deleted --- config.def.h | 1 + vis.c | 11 +++++++++++ 2 files changed, 12 insertions(+) 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 } }, diff --git a/vis.c b/vis.c index 4f59622..eaba6b8 100644 --- a/vis.c +++ b/vis.c @@ -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++) { -- cgit v1.2.3