aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-13 15:55:37 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-13 15:55:37 +0200
commitb458fc1f9976efad8d332a275994d4d5ad982a05 (patch)
tree55c8f558b63ac0c629078e00624a02f5ba404418
parent0771c142fe8257aac22db7c02ca473b5fb4b13a1 (diff)
downloadjson-rpc-shell-b458fc1f9976efad8d332a275994d4d5ad982a05.tar.gz
json-rpc-shell-b458fc1f9976efad8d332a275994d4d5ad982a05.tar.xz
json-rpc-shell-b458fc1f9976efad8d332a275994d4d5ad982a05.zip
libedit: bind M-Enter to newline-insert as well
-rw-r--r--json-rpc-shell.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index b7c99a9..82ad5ea 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -643,6 +643,15 @@ input_el_on_run_editor (EditLine *editline, int key)
return CC_NORM;
}
+static unsigned char
+input_el_on_newline_insert (EditLine *editline, int key)
+{
+ (void) key;
+
+ el_insertstr (editline, "\n");
+ return CC_REFRESH;
+}
+
static void
input_el_install_prompt (struct input_el *self)
{
@@ -671,19 +680,17 @@ input_el_start (struct input *input, const char *program_name)
// Just what are you doing?
el_set (self->editline, EL_BIND, "^u", "vi-kill-line-prev", NULL);
- // It's probably better to handle this ourselves
+ // It's probably better to handle these ourselves
el_set (self->editline, EL_ADDFN,
"send-line", "Send line", input_el_on_return);
el_set (self->editline, EL_BIND, "\n", "send-line", NULL);
-
- // It's probably better to handle this ourselves
el_set (self->editline, EL_ADDFN,
"run-editor", "Run editor to edit line", input_el_on_run_editor);
el_set (self->editline, EL_BIND, "M-e", "run-editor", NULL);
el_set (self->editline, EL_ADDFN,
- "complete", "Complete word", input_el_on_complete);
- el_set (self->editline, EL_BIND, "\t", "complete", NULL);
+ "newline-insert", "Insert a newline", input_el_on_newline_insert);
+ el_set (self->editline, EL_BIND, "M-\n", "newline-insert", NULL);
// Source the user's defaults file
el_source (self->editline, NULL);