commit e6429e782a09092eb87305d5d4cd2831c7129ad7
parent 3270aac7dbc00aeb7ba608983fde1771cd3d9986
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 3 Sep 2018 16:11:00 +0200
bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
On FreeBSD and NetBSD (when reached through ssh from a Linux machine)
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.
Diffstat:
4 files changed, 6 insertions(+), 1 deletion(-)
diff --git 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
@@ -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
@@ -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
@@ -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))