From 1ad38aa35b3318d0ba986c539025ce76a26ce572 Mon Sep 17 00:00:00 2001 From: Danny Robinson Date: Thu, 13 Oct 2022 00:17:39 +0100 Subject: [PATCH] Add ctrl-left/right keys to bestline --- third_party/linenoise/linenoise.c | 10 ++++++++++ tool/net/definitions.lua | 2 ++ tool/net/help.txt | 2 ++ 3 files changed, 14 insertions(+) diff --git a/third_party/linenoise/linenoise.c b/third_party/linenoise/linenoise.c index 18e392d9a..810073c30 100644 --- a/third_party/linenoise/linenoise.c +++ b/third_party/linenoise/linenoise.c @@ -47,6 +47,8 @@ │ ALT-> END OF HISTORY │ │ ALT-F FORWARD WORD │ │ ALT-B BACKWARD WORD │ +│ CTRL-RIGHT FORWARD WORD │ +│ CTRL-LEFT BACKWARD WORD │ │ CTRL-ALT-F FORWARD EXPR │ │ CTRL-ALT-B BACKWARD EXPR │ │ ALT-RIGHT FORWARD EXPR │ @@ -2173,6 +2175,14 @@ ssize_t linenoiseEdit(struct linenoiseState *l, const char *prompt, char **obuf, default: break; } + } else if (rc == 6 && seq[2] == '1' && + seq[3] == ';' && seq[4] == '5') { + switch (seq[5]) { + CASE('C', linenoiseEditRightWord(l)); // \e[1;5C ctrl-right + CASE('D', linenoiseEditLeftWord(l)); // \e[1;5D ctrl-left + default: + break; + } } } else { switch (seq[2]) { diff --git a/tool/net/definitions.lua b/tool/net/definitions.lua index fbb498369..07db54b35 100644 --- a/tool/net/definitions.lua +++ b/tool/net/definitions.lua @@ -108,6 +108,8 @@ KEYBOARD ALT-> END OF HISTORY ALT-F FORWARD WORD ALT-B BACKWARD WORD + CTRL-RIGHT FORWARD WORD + CTRL-LEFT BACKWARD WORD CTRL-K KILL LINE FORWARDS CTRL-U KILL LINE BACKWARDS ALT-H KILL WORD BACKWARDS diff --git a/tool/net/help.txt b/tool/net/help.txt index 8f2899fe3..50f825cdf 100644 --- a/tool/net/help.txt +++ b/tool/net/help.txt @@ -102,6 +102,8 @@ KEYBOARD ALT-> END OF HISTORY ALT-F FORWARD WORD ALT-B BACKWARD WORD + CTRL-RIGHT FORWARD WORD + CTRL-LEFT BACKWARD WORD CTRL-K KILL LINE FORWARDS CTRL-U KILL LINE BACKWARDS ALT-H KILL WORD BACKWARDS