From 252f14796ed04385f4f4bf29505dd5bbfe4f3110 Mon Sep 17 00:00:00 2001 From: Brand Huntsman Date: Wed, 24 Oct 2018 03:17:28 -0600 Subject: [PATCH] bindings: hard-bind the zap function to M-Del (Alt+Delete) So that the function is available in a default setup. Signed-off-by: Brand Huntsman --- doc/nano.texi | 1 + doc/nanorc.5 | 1 + src/global.c | 2 ++ src/nano.c | 1 + src/nano.h | 1 + src/proto.h | 1 + src/winio.c | 10 +++++++++- 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/doc/nano.texi b/doc/nano.texi index 9d28236e..76126523 100644 --- a/doc/nano.texi +++ b/doc/nano.texi @@ -1161,6 +1161,7 @@ current cursor position. @item zap Throw away the current line (or the marked region). +(This function is bound by default to .) @item cutwordleft Cuts from the cursor position to the beginning of the preceding word. diff --git a/doc/nanorc.5 b/doc/nanorc.5 index 971565e2..d5462d7a 100644 --- a/doc/nanorc.5 +++ b/doc/nanorc.5 @@ -512,6 +512,7 @@ current cursor position. .TP .B zap Throw away the current line (or the marked region). +(This function is bound by default to .) .TP .B cutwordleft Cuts from the cursor position to the beginning of the preceding word. diff --git a/src/global.c b/src/global.c index c6b9adb2..a7f0d6d0 100644 --- a/src/global.c +++ b/src/global.c @@ -76,6 +76,7 @@ int shiftleft, shiftright, shiftup, shiftdown; int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown; int shiftcontrolhome, shiftcontrolend; int altleft, altright, altup, altdown; +int altdelete; int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown; #endif @@ -1156,6 +1157,7 @@ void shortcut_init(void) add_to_sclist(MMAIN, "M-E", 0, do_redo, 0); add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, do_cut_prev_word, 0); add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, do_cut_next_word, 0); + add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0); #endif #ifdef ENABLE_WORDCOMPLETION add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0); diff --git a/src/nano.c b/src/nano.c index e1fa3af5..ef43657b 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2596,6 +2596,7 @@ int main(int argc, char **argv) altright = get_keycode("kRIT3", ALT_RIGHT); altup = get_keycode("kUP3", ALT_UP); altdown = get_keycode("kDN3", ALT_DOWN); + altdelete = get_keycode("kDC3", ALT_DELETE); shiftaltleft = get_keycode("kLFT4", SHIFT_ALT_LEFT); shiftaltright = get_keycode("kRIT4", SHIFT_ALT_RIGHT); diff --git a/src/nano.h b/src/nano.h index 70cd353c..db726b6a 100644 --- a/src/nano.h +++ b/src/nano.h @@ -594,6 +594,7 @@ enum #define ALT_RIGHT 0x422 #define ALT_UP 0x423 #define ALT_DOWN 0x424 +#define ALT_DELETE 0x427 #define SHIFT_ALT_LEFT 0x431 #define SHIFT_ALT_RIGHT 0x432 #define SHIFT_ALT_UP 0x433 diff --git a/src/proto.h b/src/proto.h index 5647a80b..b6c50e58 100644 --- a/src/proto.h +++ b/src/proto.h @@ -67,6 +67,7 @@ extern int shiftcontrolup, shiftcontroldown; extern int shiftcontrolhome, shiftcontrolend; extern int altleft, altright; extern int altup, altdown; +extern int altdelete; extern int shiftaltleft, shiftaltright; extern int shiftaltup, shiftaltdown; #endif diff --git a/src/winio.c b/src/winio.c index 5a98456d..d973c828 100644 --- a/src/winio.c +++ b/src/winio.c @@ -576,7 +576,10 @@ int parse_kbinput(WINDOW *win) return ALT_UP; else if (retval == altdown) return ALT_DOWN; - else if (retval == shiftaltleft) { + else if (retval == altdelete) { + meta_key = TRUE; + return ALT_DELETE; + } else if (retval == shiftaltleft) { shift_held = TRUE; return KEY_HOME; } else if (retval == shiftaltright) { @@ -609,6 +612,11 @@ int parse_kbinput(WINDOW *win) /* Are both Shift and Ctrl being held while Delete is pressed? */ if ((modifiers & 0x05) == 0x05 && retval == KEY_DC) return CONTROL_SHIFT_DELETE; + /* Is Meta being held while Delete is pressed? */ + if (modifiers == 0x08 && retval == KEY_DC) { + meta_key = TRUE; + return ALT_DELETE; + } #endif /* Is Ctrl being held? */ if (modifiers & 0x04) {