From f66432e999ff0fca33f5da4999808012e066ffcd Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey <pooka109@gmail.com> Date: Tue, 12 Dec 2017 14:43:03 -0600 Subject: [PATCH] input: support backtab when Slang and/or --rebindkeypad is used The escape sequence "Esc [ Z" is a backtab on most supported terminals, so make sure convert_sequence() treats it as such. --- src/global.c | 4 +--- src/nano.h | 1 + src/winio.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/global.c b/src/global.c index 12c2cbc1..6a580899 100644 --- a/src/global.c +++ b/src/global.c @@ -1147,9 +1147,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0); add_to_sclist(MMAIN, "M-}", 0, do_indent, 0); add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0); -#ifdef KEY_BTAB - add_to_sclist(MMAIN, "S-Tab", KEY_BTAB, do_unindent, 0); -#endif + add_to_sclist(MMAIN, "S-Tab", SHIFT_TAB, do_unindent, 0); add_to_sclist(MMAIN, "M-:", 0, record_macro, 0); add_to_sclist(MMAIN, "M-;", 0, run_macro, 0); add_to_sclist(MMAIN, "M-U", 0, do_undo, 0); diff --git a/src/nano.h b/src/nano.h index 7ce36646..7e6d8f81 100644 --- a/src/nano.h +++ b/src/nano.h @@ -590,6 +590,7 @@ enum #define SHIFT_END 0x456 #define SHIFT_PAGEUP 0x457 #define SHIFT_PAGEDOWN 0x458 +#define SHIFT_TAB 0x45F #ifdef USE_SLANG #ifdef ENABLE_UTF8 diff --git a/src/winio.c b/src/winio.c index 3a64cd14..b6fd62e7 100644 --- a/src/winio.c +++ b/src/winio.c @@ -613,11 +613,9 @@ int parse_kbinput(WINDOW *win) #ifndef NANO_TINY /* Is Shift being held? */ if (modifiers & 0x01) { -#ifdef KEY_BTAB /* A shifted <Tab> is a back tab. */ if (retval == TAB_CODE) - return KEY_BTAB; -#endif + return SHIFT_TAB; shift_held = TRUE; } #endif @@ -769,6 +767,11 @@ int parse_kbinput(WINDOW *win) case KEY_SUSPEND: return the_code_for(do_suspend_void, KEY_SUSPEND); #endif +#ifdef KEY_BTAB + /* Slang doesn't support KEY_BTAB. */ + case KEY_BTAB: + return SHIFT_TAB; +#endif #ifdef PDCURSES case KEY_SHIFT_L: case KEY_SHIFT_R: @@ -1213,8 +1216,9 @@ int convert_sequence(const int *seq, size_t seq_len) return KEY_F(12); case 'Y': /* Esc [ Y == End on Mach console. */ return KEY_END; - case 'Z': /* Esc [ Z == F14 on FreeBSD console. */ - return KEY_F(14); + case 'Z': /* Esc [ Z == Shift-Tab on ANSI/Linux console/ + * FreeBSD console/xterm/rxvt/Terminal. */ + return SHIFT_TAB; case 'a': /* Esc [ a == Shift-Up on rxvt/Eterm. */ case 'b': /* Esc [ b == Shift-Down on rxvt/Eterm. */ case 'c': /* Esc [ c == Shift-Right on rxvt/Eterm. */ -- GitLab