nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH 3/4] bindings: bind the zap function by default to M


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH 3/4] bindings: bind the zap function by default to M-Del (Alt+Delete)
Date: Sun, 28 Oct 2018 14:41:03 +0100

From: Brand Huntsman <address@hidden>

Signed-off-by: Brand Huntsman <address@hidden>
---
 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   | 14 ++++++++++++--
 7 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/doc/nano.texi b/doc/nano.texi
index 3cf71dc3..606d7cd8 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 <Meta+Delete>.)
 
 @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 e8a8532d..c441260e 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 <Meta+Delete>.)
 .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 89df838b..950c0fb9 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
 
@@ -1158,6 +1159,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 1aa8b276..d4597351 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2599,6 +2599,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 a2834606..63494981 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..c8bfc98b 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -390,7 +390,9 @@ int parse_kbinput(WINDOW *win)
                        retval = keycode;
                        break;
                case 1:
-                       if (keycode >= 0x80)
+                       if (keycode == KEY_DC)
+                               retval = ALT_DELETE;
+                       else if (keycode >= 0x80)
                                retval = keycode;
                        else if (keycode == TAB_CODE)
                                retval = SHIFT_TAB;
@@ -576,7 +578,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 +614,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) {
-- 
2.19.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]