From f55a3fabef52a219c8ef5213ba51b7b5258a00cf Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 5 Nov 2018 18:08:33 -0600 Subject: [PATCH] input: recognize some escape sequences for Also, hard-bind in the same way as . This fixes https://savannah.gnu.org/bugs/?54948, and fixes https://savannah.gnu.org/bugs/?54975. --- src/global.c | 2 ++ src/nano.h | 1 + src/winio.c | 13 +++++++++++-- syntax/nanohelp.nanorc | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/global.c b/src/global.c index c523818c..38f29672 100644 --- a/src/global.c +++ b/src/global.c @@ -1093,6 +1093,7 @@ void shortcut_init(void) add_to_sclist(MMOST, "Enter", KEY_ENTER, do_enter, 0); add_to_sclist(MMOST, "^H", 0, do_backspace, 0); add_to_sclist(MMOST, "Bsp", KEY_BACKSPACE, do_backspace, 0); + add_to_sclist(MMOST, "Sh-Del", SHIFT_DELETE, do_backspace, 0); add_to_sclist(MMOST, "^D", 0, do_delete, 0); add_to_sclist(MMOST, "Del", 0, do_delete, 0); /* Make ASCII DEL do a delete when requested, otherwise a backspace. */ @@ -1128,6 +1129,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0); add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0); + add_to_sclist(MHELP|MBROWSER, "Sh-Del", SHIFT_DELETE, do_page_up, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0); add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0); add_to_sclist(MHELP|MBROWSER, "Space", 0x20, do_page_down, 0); diff --git a/src/nano.h b/src/nano.h index 0497758b..281cd75e 100644 --- a/src/nano.h +++ b/src/nano.h @@ -607,6 +607,7 @@ enum #define SHIFT_END 0x456 #define SHIFT_PAGEUP 0x457 #define SHIFT_PAGEDOWN 0x458 +#define SHIFT_DELETE 0x45D #define SHIFT_TAB 0x45F #ifdef USE_SLANG diff --git a/src/winio.c b/src/winio.c index fb09a94d..c1819f09 100644 --- a/src/winio.c +++ b/src/winio.c @@ -602,6 +602,9 @@ int parse_kbinput(WINDOW *win) return SHIFT_TAB; shift_held = TRUE; } + /* Is Shift being held while Delete is pressed? */ + if (modifiers == 0x01 && retval == KEY_DC) + return SHIFT_DELETE; /* Are Ctrl and Shift being held while Delete is pressed? */ if (modifiers == 0x05 && retval == KEY_DC) return CONTROL_SHIFT_DELETE; @@ -722,8 +725,8 @@ int parse_kbinput(WINDOW *win) case KEY_C3: /* PageDown (3) on keypad with NumLock off. */ return KEY_NPAGE; #ifdef KEY_SDC /* Slang doesn't support KEY_SDC. */ - case KEY_SDC: /* Make a shifted key do a backspace. */ - return KEY_BACKSPACE; + case KEY_SDC: + return SHIFT_DELETE; #endif #ifdef KEY_SIC /* Slang doesn't support KEY_SIC. */ case KEY_SIC: @@ -1109,6 +1112,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) #ifndef NANO_TINY if (length > 4 && seq[2] == ';' && seq[4] == '~') { *consumed = 5; + if (seq[3] == '2') + /* Esc [ 3 ; 2 ~ == Shift-Delete on xterm/Terminal. */ + return SHIFT_DELETE; if (seq[3] == '3') /* Esc [ 3 ; 3 ~ == Alt-Delete on xterm/rxvt/Eterm/Terminal. */ return ALT_DELETE; @@ -1119,6 +1125,9 @@ int convert_sequence(const int *seq, size_t length, int *consumed) /* Esc [ 3 ; 6 ~ == Ctrl-Shift-Delete on xterm. */ return controlshiftdelete; } + if (length > 2 && seq[2] == '$') + /* Esc [ 3 $ == Shift-Delete on urxvt. */ + return SHIFT_DELETE; if (length > 2 && seq[2] == '^') /* Esc [ 3 ^ == Ctrl-Delete on urxvt. */ return CONTROL_DELETE; diff --git a/syntax/nanohelp.nanorc b/syntax/nanohelp.nanorc index 850c2492..fe7433f5 100644 --- a/syntax/nanohelp.nanorc +++ b/syntax/nanohelp.nanorc @@ -5,7 +5,7 @@ syntax nanohelp # Key combos: color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\" +color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Sh-\^?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>" # Quoted indicators: color brightred "'(\^|M-)'"