diff mbox series

ui/ncurses: Handle arrow key variants

Message ID 20171120044447.32199-1-sam@mendozajonas.com
State Accepted
Headers show
Series ui/ncurses: Handle arrow key variants | expand

Commit Message

Sam Mendoza-Jonas Nov. 20, 2017, 4:44 a.m. UTC
In the vt100 'application' cursor mode arrow keys produce ^[Ox rather
than the usual ^[[x. Add this pattern to our defined keys so we don't
accidentally catch the escape key.

For reference:
http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-21.html

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 ui/ncurses/nc-cui.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox series

Patch

diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c
index 8060510..64b1f64 100644
--- a/ui/ncurses/nc-cui.c
+++ b/ui/ncurses/nc-cui.c
@@ -98,8 +98,18 @@  static void cui_start(void)
 	define_key("\x1b\x4f\x46", KEY_END);
 	define_key("OH", KEY_HOME);
 	define_key("OF", KEY_END);
+
+	/* Arrow keys in normal cursor mode */
 	define_key("\x1b\x5b\x41", KEY_UP);
 	define_key("\x1b\x5b\x42", KEY_DOWN);
+	define_key("\x1b\x5b\x43", KEY_RIGHT);
+	define_key("\x1b\x5b\x44", KEY_LEFT);
+	/* Arrow keys in "application" cursor mode */
+	define_key("\x1b\x4f\x41", KEY_UP);
+	define_key("\x1b\x4f\x42", KEY_DOWN);
+	define_key("\x1b\x4f\x43", KEY_RIGHT);
+	define_key("\x1b\x4f\x44", KEY_LEFT);
+
 	define_key("\x1b\x5b\x33\x7e", KEY_DC);
 
 	while (getch() != ERR)		/* flush stdin */