nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] input: make the Ctrl+Arrow keys work on a Linux con


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] input: make the Ctrl+Arrow keys work on a Linux console
Date: Fri, 29 Jul 2016 10:52:20 +0200

---
 src/winio.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/winio.c b/src/winio.c
index b912290..eaad466 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -23,6 +23,8 @@
 #include "proto.h"
 #include "revision.h"
 
+#include <sys/ioctl.h>
+
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
@@ -35,6 +37,8 @@
 #define BRANDING PACKAGE_STRING
 #endif
 
+#define KEYMOD_CONTROL  (1<<2)
+
 static int *key_buffer = NULL;
        /* The keystroke buffer, containing all the keystrokes we
         * haven't handled yet at a given point. */
@@ -497,6 +501,24 @@ int parse_kbinput(WINDOW *win)
            }
     }
 
+    /* For the arrow keys, check whether Ctrl is being held. */
+    if (retval == KEY_UP || retval == KEY_DOWN ||
+               retval == KEY_LEFT || retval == KEY_RIGHT) {
+       unsigned char modifiers = 6;
+
+       if (ioctl(0, TIOCLINUX, &modifiers) >= 0 &&
+                               (modifiers & KEYMOD_CONTROL)) {
+           if (retval == KEY_UP)
+               retval = CONTROL_UP;
+           else if (retval == KEY_DOWN)
+               retval = CONTROL_DOWN;
+           else if (retval == KEY_LEFT)
+               retval = CONTROL_LEFT;
+           else
+               retval = CONTROL_RIGHT;
+       }
+    }
+
     if (retval != ERR) {
        switch (retval) {
 #ifdef KEY_SLEFT
-- 
2.9.2




reply via email to

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