summaryrefslogtreecommitdiffstats
path: root/linenoise
diff options
context:
space:
mode:
Diffstat (limited to 'linenoise')
-rw-r--r--linenoise/linenoise.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c
index b43a15a0..b94a9a6d 100644
--- a/linenoise/linenoise.c
+++ b/linenoise/linenoise.c
@@ -171,6 +171,7 @@ enum key_action {
CTRL_P = 16,
CTRL_T = 20,
CTRL_U = 21,
+ CTRL_V = 22,
CTRL_W = 23,
ESC = 27,
BACKSPACE = 127
@@ -777,6 +778,8 @@ static void edit_delete_prev_word(struct lino_state *l) {
* The function returns the length of the current buffer. */
static int edit(lino_t *l, const char *prompt)
{
+ int verbatim = 0;
+
/* Populate the linenoise state that we pass to functions implementing
* specific editing functionalities. */
l->prompt = prompt;
@@ -804,6 +807,12 @@ static int edit(lino_t *l, const char *prompt)
if (nread <= 0)
return l->len ? (int) l->len : -1;
+ if (verbatim) {
+ if (edit_insert(l,c)) return -1;
+ verbatim = 0;
+ continue;
+ }
+
/* Only autocomplete when the callback is set. It returns < 0 when
* there was an error reading from fd. Otherwise it will return the
* character that should be handled next. */
@@ -928,6 +937,9 @@ static int edit(lino_t *l, const char *prompt)
l->dpos = l->dlen = 0;
refresh_line(l);
break;
+ case CTRL_V: /* insert next char verbatim */
+ verbatim = 1;
+ break;
case CTRL_K: /* delete from current to end of line. */
l->data[l->dpos] = '\0';
l->dlen = l->dpos;