From c915ec56a54c9fbad8fde65631f8343a588398b3 Mon Sep 17 00:00:00 2001 From: Christopher Wellons Date: Tue, 12 Jan 2021 11:24:11 -0500 Subject: win32: handle various Alt key modifiers in termios This patch restores support for Bash-stle Alt commands present in the original BusyBox: * Alt-b, Alt-LeftArrow backward word * Alt-f, Alt-RightArrow forward word * Alt-BackSpace delete word backward * Alt-d delete word forward --- win32/termios.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/win32/termios.c b/win32/termios.c index 25f2ea48c..708acfa9f 100644 --- a/win32/termios.c +++ b/win32/termios.c @@ -61,9 +61,7 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) case VK_END: case VK_DOWN: case VK_NEXT: - case VK_LEFT: case VK_CLEAR: - case VK_RIGHT: case VK_HOME: case VK_UP: case VK_PRIOR: @@ -82,6 +80,10 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) ret = KEYCODE_CTRL_RIGHT; goto done; } + if (state & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) { + ret = KEYCODE_ALT_RIGHT; + goto done; + } ret = KEYCODE_RIGHT; goto done; case VK_LEFT: @@ -89,6 +91,10 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) ret = KEYCODE_CTRL_LEFT; goto done; } + if (state & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) { + ret = KEYCODE_ALT_LEFT; + goto done; + } ret = KEYCODE_LEFT; goto done; case VK_HOME: ret = KEYCODE_HOME; goto done; @@ -111,6 +117,14 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) } ret = record.Event.KeyEvent.uChar.AsciiChar; #endif + if (state & (RIGHT_ALT_PRESSED|LEFT_ALT_PRESSED)) { + switch (ret) { + case '\b': ret = KEYCODE_ALT_BACKSPACE; goto done; + case 'b': ret = KEYCODE_ALT_LEFT; goto done; + case 'd': ret = KEYCODE_ALT_D; goto done; + case 'f': ret = KEYCODE_ALT_RIGHT; goto done; + } + } break; } done: -- cgit v1.2.3-55-g6feb