From 7866b06266339122a5894b39901cb64718d837a5 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg
Date: Tue, 16 Aug 2016 21:54:39 +0200 Subject: [PATCH] input: allow rebinding the Ctrl+Arrow key combos --- src/global.c | 17 ++++++++++++++++- src/winio.c | 16 ++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/global.c b/src/global.c index da404d2..43227ff 100644 --- a/src/global.c +++ b/src/global.c @@ -407,9 +407,20 @@ void assign_keyinfo(sc *s, const char *keystring) assert(strlen(keystring) > 1 && (!s->meta || strlen(keystring) > 2)); if (keystring[0] == '^') { - s->keycode = keystring[1] - 64; if (strcasecmp(keystring, "^Space") == 0) s->keycode = 0; +#ifndef NANO_TINY + else if (strcasecmp(keystring, "^Up") == 0) + s->keycode = CONTROL_UP; + else if (strcasecmp(keystring, "^Down") == 0) + s->keycode = CONTROL_DOWN; + else if (strcasecmp(keystring, "^Left") == 0) + s->keycode = CONTROL_LEFT; + else if (strcasecmp(keystring, "^Right") == 0) + s->keycode = CONTROL_RIGHT; +#endif + else + s->keycode = keystring[1] - 64; } else if (s->meta) { s->keycode = tolower((int)keystring[2]); if (strcasecmp(keystring, "M-Space") == 0) @@ -1116,7 +1127,9 @@ void shortcut_init(void) add_to_sclist(MMOST, "^F", do_right, 0); add_to_sclist(MMOST, "Right", do_right, 0); #ifndef NANO_TINY + add_to_sclist(MMAIN, "^Left", do_prev_word_void, 0); add_to_sclist(MMOST, "M-Space", do_prev_word_void, 0); + add_to_sclist(MMAIN, "^Right", do_next_word_void, 0); add_to_sclist(MMOST, "^Space", do_next_word_void, 0); #endif add_to_sclist((MMOST & ~MBROWSER), "^A", do_home, 0); @@ -1128,7 +1141,9 @@ void shortcut_init(void) add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", do_down_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", do_down_void, 0); #ifndef NANO_TINY + add_to_sclist(MMAIN, "^Up", do_prev_block, 0); add_to_sclist(MMAIN, "M-7", do_prev_block, 0); + add_to_sclist(MMAIN, "^Down", do_next_block, 0); add_to_sclist(MMAIN, "M-8", do_next_block, 0); #endif #ifndef DISABLE_JUSTIFY diff --git a/src/winio.c b/src/winio.c index 13ae8ca..c734635 100644 --- a/src/winio.c +++ b/src/winio.c @@ -497,13 +497,13 @@ int parse_kbinput(WINDOW *win) #ifndef NANO_TINY if (retval == controlleft) - return sc_seq_or(do_prev_word_void, 0); + return CONTROL_LEFT; else if (retval == controlright) - return sc_seq_or(do_next_word_void, 0); + return CONTROL_RIGHT; else if (retval == controlup) - return sc_seq_or(do_prev_block, 0); + return CONTROL_UP; else if (retval == controldown) - return sc_seq_or(do_next_block, 0); + return CONTROL_DOWN; #endif #if defined(__linux__) && !defined(NANO_TINY) @@ -515,13 +515,13 @@ int parse_kbinput(WINDOW *win) if (ioctl(0, TIOCLINUX, &modifiers) >= 0 && (modifiers & 0x04)) { if (retval == KEY_UP) - return sc_seq_or(do_prev_block, 0); + return CONTROL_UP; else if (retval == KEY_DOWN) - return sc_seq_or(do_next_block, 0); + return CONTROL_DOWN; else if (retval == KEY_LEFT) - return sc_seq_or(do_prev_word_void, 0); + return CONTROL_LEFT; else - return sc_seq_or(do_next_word_void, 0); + return CONTROL_RIGHT; } } #endif /* __linux__ && !NANO_TINY */ -- 2.9.2