commit 826be439db7987cacd5612ef8d0399ccbee44f88
parent 8bffc8ea53a51565327f7de6dab8102c0549b119
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 5 Oct 2018 19:50:41 +0200
bindings: make the Shift+arrow keys work by default on more terminals
Ask ncurses for the codes for the Shift+arrow keys, so that also
<Shift+Up> and <Shift+Down> can be recognized, for which ncurses
doesn't have standard codes.
This fixes https://savannah.gnu.org/bugs/?54790.
Reported-by: Javier Valencia <javiervalencia80@gmail.com>
Diffstat:
5 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/src/global.c b/src/global.c
@@ -71,6 +71,7 @@ int didfind = 0;
int controlleft, controlright, controlup, controldown, controlhome, controlend;
int controldelete, controlshiftdelete;
#ifndef NANO_TINY
+int shiftleft, shiftright, shiftup, shiftdown;
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int altleft, altright, altup, altdown;
diff --git a/src/nano.c b/src/nano.c
@@ -2579,6 +2579,11 @@ int main(int argc, char **argv)
#ifndef NANO_TINY
controldelete = get_keycode("kDC5", CONTROL_DELETE);
controlshiftdelete = get_keycode("kDC6", CONTROL_SHIFT_DELETE);
+ /* Ask for the codes for Shift+Left/Right/Up/Down. */
+ shiftleft = get_keycode("kLFT", SHIFT_LEFT);
+ shiftright = get_keycode("kRIT", SHIFT_RIGHT);
+ shiftup = get_keycode("kUP", SHIFT_UP);
+ shiftdown = get_keycode("kDN", SHIFT_DOWN);
/* Ask for the codes for Shift+Control+Left/Right/Up/Down. */
shiftcontrolleft = get_keycode("kLFT6", SHIFT_CONTROL_LEFT);
shiftcontrolright = get_keycode("kRIT6", SHIFT_CONTROL_RIGHT);
diff --git a/src/nano.h b/src/nano.h
@@ -597,6 +597,10 @@ enum
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
+#define SHIFT_LEFT 0x451
+#define SHIFT_RIGHT 0x452
+#define SHIFT_UP 0x453
+#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
diff --git a/src/proto.h b/src/proto.h
@@ -64,6 +64,10 @@ extern int controlend;
#ifndef NANO_TINY
extern int controldelete;
extern int controlshiftdelete;
+extern int shiftleft;
+extern int shiftright;
+extern int shiftup;
+extern int shiftdown;
extern int shiftcontrolleft;
extern int shiftcontrolright;
extern int shiftcontrolup;
diff --git a/src/winio.c b/src/winio.c
@@ -543,7 +543,19 @@ int parse_kbinput(WINDOW *win)
return CONTROL_DELETE;
else if (retval == controlshiftdelete)
return CONTROL_SHIFT_DELETE;
- else if (retval == shiftcontrolleft) {
+ else if (retval == shiftleft) {
+ shift_held = TRUE;
+ return KEY_LEFT;
+ } else if (retval == shiftright) {
+ shift_held = TRUE;
+ return KEY_RIGHT;
+ } else if (retval == shiftup) {
+ shift_held = TRUE;
+ return KEY_UP;
+ } else if (retval == shiftdown) {
+ shift_held = TRUE;
+ return KEY_DOWN;
+ } else if (retval == shiftcontrolleft) {
shift_held = TRUE;
return CONTROL_LEFT;
} else if (retval == shiftcontrolright) {