From 887803cb674b0b8664b37a5dd7a279919e727047 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Mon, 15 Jul 2024 08:28:05 +0200 Subject: [PATCH] bindings: let the central numpad key (with Ctrl) center the current line When NumLock is off, let Ctrl plus the central key on the numeric keypad center the current line. (This binding is not advertised anywhere -- it's left as a little Easter egg.) --- src/definitions.h | 3 +++ src/global.c | 1 + src/winio.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/definitions.h b/src/definitions.h index 27777deb..68fc126d 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -227,6 +227,9 @@ #define PLANTED_A_COMMAND 0x4EC #define NO_SUCH_FUNCTION 0x4EF +/* A special keycode for Ctrl + the central key on the numeric keypad. */ +#define KEY_CENTER 0x4F0 + /* A special keycode to signal the beginning and end of a bracketed paste. */ #define BRACKETED_PASTE_MARKER 0x4FB diff --git a/src/global.c b/src/global.c index 0d642bd0..245087a8 100644 --- a/src/global.c +++ b/src/global.c @@ -1571,6 +1571,7 @@ void shortcut_init(void) #endif #ifndef NANO_TINY add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0); + add_to_sclist(MMAIN, "", KEY_CENTER, do_center, 0); add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile, 0); /* Catch and ignore bracketed paste marker keys. */ add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0); diff --git a/src/winio.c b/src/winio.c index 1d66770b..09ebbd69 100644 --- a/src/winio.c +++ b/src/winio.c @@ -660,6 +660,8 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed) return CONTROL_RIGHT; case 'D': /* Esc [ 1 ; 5 D == Ctrl-Left on xterm. */ return CONTROL_LEFT; + case 'E': /* Esc [ 1 ; 5 E == Ctrl-"Center" on xterm. */ + return KEY_CENTER; case 'F': /* Esc [ 1 ; 5 F == Ctrl-End on xterm. */ return CONTROL_END; case 'H': /* Esc [ 1 ; 5 H == Ctrl-Home on xterm. */