From 93f311a4385cb322a5b70bc7aa938a4626a31964 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey 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 backtab on most supported terminals, so make sure convert_sequence() handles it as such. --- src/global.c | 4 +--- src/nano.h | 1 + src/winio.c | 12 +++++++++--- 3 files changed, 11 insertions(+), 6 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..1792cb4f 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 0x459 #ifdef USE_SLANG #ifdef ENABLE_UTF8 diff --git a/src/winio.c b/src/winio.c index ea067761..ac5b9119 100644 --- a/src/winio.c +++ b/src/winio.c @@ -625,7 +625,7 @@ int parse_kbinput(WINDOW *win) #ifdef KEY_BTAB /* A shifted is a back tab. */ if (retval == TAB_CODE) - return KEY_BTAB; + return SHIFT_TAB; #endif shift_held = TRUE; } @@ -778,6 +778,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: @@ -1222,8 +1227,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. */ -- 2.14.1