aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2020-10-09 20:37:32 +0200
committerPřemysl Eric Janouch <p@janouch.name>2020-10-09 20:41:37 +0200
commit897a263ee772edc2211f46032b377eaf27edbb56 (patch)
tree1b59900c2fa64cadf589584d0645b35d79a12a96
parent84702fa47da5d2d4e872245a907a282fadccbc22 (diff)
downloadjson-rpc-shell-897a263ee772edc2211f46032b377eaf27edbb56.tar.gz
json-rpc-shell-897a263ee772edc2211f46032b377eaf27edbb56.tar.xz
json-rpc-shell-897a263ee772edc2211f46032b377eaf27edbb56.zip
Readline: make M-Enter insert a newline
Before, it was only possible with C-v C-j but it's too useful to require such an awkward method. There is a precedent in, e.g., zsh and fish for the new binding.
-rw-r--r--json-rpc-shell.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/json-rpc-shell.c b/json-rpc-shell.c
index 00b48c2..bd5888e 100644
--- a/json-rpc-shell.c
+++ b/json-rpc-shell.c
@@ -247,10 +247,22 @@ input_rl_on_run_editor (int count, int key)
}
static int
+input_rl_newline_insert (int count, int key)
+{
+ (void) count;
+ (void) key;
+
+ rl_insert_text ("\n");
+ return 0;
+}
+
+static int
input_rl_on_startup (void)
{
rl_add_defun ("run-editor", input_rl_on_run_editor, -1);
rl_bind_keyseq ("\\ee", rl_named_function ("run-editor"));
+ rl_add_defun ("newline-insert", input_rl_newline_insert, -1);
+ rl_bind_keyseq ("\\e\\r", rl_named_function ("newline-insert"));
return 0;
}