nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] bindings: hard-bind <Ctrl+Shift+Delete> to 'cutword


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
Date: Tue, 4 Sep 2018 14:12:15 +0200

(On FreeBSD and NetBSD this has the absurd effect of making
<Ctrl+Backspace> do a 'cutwordleft' by default, out of the box,
without needing any rebindings.  Weird, but wonderful, because
the ideal behavior.)

Also ensure that <Shift+Delete> always does a Backspace.

This makes that we have the following set of "congruent" keys:

  <Tab> moves text to the right,
  <Shift+Tab> moves text to the left,
  <Delete> "eats" a character to the right,
  <Shift+Delete> "eats" a character to the left,
  <Ctrl+Delete> "eats" a word to the right,
  <Shift+Ctrl+Delete> "eats" a word to the left.
---
 src/global.c | 2 +-
 src/nano.c   | 1 +
 src/proto.h  | 1 +
 src/winio.c  | 3 +++
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/global.c b/src/global.c
index 431a2097..475addbe 100644
--- a/src/global.c
+++ b/src/global.c
@@ -69,7 +69,7 @@ int didfind = 0;
                /* Whether the last search found something. */
 
 int controlleft, controlright, controlup, controldown, controlhome, controlend;
-int controldelete;
+int controldelete, controlshiftdelete;
 #ifndef NANO_TINY
 int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
 int shiftcontrolhome, shiftcontrolend;
diff --git a/src/nano.c b/src/nano.c
index cca042cb..c7e0ca2d 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -2580,6 +2580,7 @@ int main(int argc, char **argv)
        controlhome = get_keycode("kHOM5", CONTROL_HOME);
        controlend = get_keycode("kEND5", CONTROL_END);
        controldelete = get_keycode("kDC5", CONTROL_DELETE);
+       controlshiftdelete = get_keycode("kDC6", KEY_BACKSPACE);
 #ifndef NANO_TINY
        /* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
        shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
diff --git a/src/proto.h b/src/proto.h
index 3a1f5025..fd059b31 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -62,6 +62,7 @@ extern int controldown;
 extern int controlhome;
 extern int controlend;
 extern int controldelete;
+extern int controlshiftdelete;
 #ifndef NANO_TINY
 extern int shiftcontrolleft;
 extern int shiftcontrolright;
diff --git a/src/winio.c b/src/winio.c
index 6908ee1d..cf8e8376 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -540,6 +540,8 @@ int parse_kbinput(WINDOW *win)
                return CONTROL_END;
        else if (retval == controldelete)
                return CONTROL_DELETE;
+       else if (retval == controlshiftdelete)
+               return the_code_for(do_cut_prev_word, KEY_BACKSPACE);
 #ifndef NANO_TINY
        else if (retval == shiftcontrolleft) {
                shift_held = TRUE;
@@ -705,6 +707,7 @@ int parse_kbinput(WINDOW *win)
                        return KEY_NPAGE;
 #ifdef KEY_SDC  /* Slang doesn't support KEY_SDC. */
                case KEY_SDC:
+                               return KEY_BACKSPACE;
 #endif
                case DEL_CODE:
                        if (ISSET(REBIND_DELETE))
-- 
2.17.1




reply via email to

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