diff --git a/src/global.c b/src/global.c index 606dc3c9..3c92e4f2 100644 --- a/src/global.c +++ b/src/global.c @@ -77,6 +77,7 @@ int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown; int shiftcontrolhome, shiftcontrolend; int altleft, altright, altup, altdown; int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; +int shifttab; #endif #ifdef ENABLED_WRAPORJUSTIFY @@ -1147,6 +1148,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); + 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.c b/src/nano.c index 0da1bd5a..94bad289 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2528,6 +2528,8 @@ int main(int argc, char **argv) shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT); shiftaltup = get_keycode("kUP4", SHIFT_ALT_UP); shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN); + /* Ask for the code for Shift+Tab. */ + shifttab = get_keycode("kcbt", SHIFT_TAB); #endif #ifdef HAVE_SET_ESCDELAY 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/proto.h b/src/proto.h index 2232e269..c8ab854f 100644 --- a/src/proto.h +++ b/src/proto.h @@ -77,6 +77,7 @@ extern int shiftaltleft; extern int shiftaltright; extern int shiftaltup; extern int shiftaltdown; +extern int shifttab; #endif #ifdef ENABLED_WRAPORJUSTIFY diff --git a/src/winio.c b/src/winio.c index f3d548a0..59bf3ccb 100644 --- a/src/winio.c +++ b/src/winio.c @@ -621,8 +621,12 @@ int parse_kbinput(WINDOW *win) if (console && ioctl(0, TIOCLINUX, &modifiers) >= 0) { #ifndef NANO_TINY /* Is Shift being held? */ - if (modifiers & 0x01) + if (modifiers & 0x01) { + /* A shifted is a back tab. */ + if (retval == TAB_CODE) + return SHIFT_TAB; shift_held = TRUE; + } #endif /* Is Ctrl being held? */ if (modifiers & 0x04) { @@ -655,6 +659,16 @@ int parse_kbinput(WINDOW *win) } #endif /* __linux__ */ +#ifndef NANO_TINY + /* When is pressed while the mark is on, do an indent. */ + if (retval == TAB_CODE && openfile->mark && currmenu == MMAIN) { + const sc *command = first_sc_for(MMAIN, do_indent); + + meta_key = command->meta; + return command->keycode; + } +#endif + switch (retval) { #ifdef KEY_SLEFT /* Slang doesn't support KEY_SLEFT. */ @@ -762,6 +776,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: @@ -1206,8 +1225,8 @@ 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 Linux console. */ + 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. */