diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-22 09:43:03 +1000 |
---|---|---|
committer | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2010-09-22 09:43:03 +1000 |
commit | 6e1050c254353471131672c0e8383c9e906d6fb5 (patch) | |
tree | a2586ceae2ab36c54e60cb4c69527d588c0e3a8e | |
parent | 1245a2ba817045d0a33baa5c86b69e54596b9199 (diff) | |
download | busybox-w32-6e1050c254353471131672c0e8383c9e906d6fb5.tar.gz busybox-w32-6e1050c254353471131672c0e8383c9e906d6fb5.tar.bz2 busybox-w32-6e1050c254353471131672c0e8383c9e906d6fb5.zip |
win32: lineedit: make read_key() pass Ctrl+<letter> to read_line_input
This makes ^C and ^D work properly regarding ash input handling
(i.e. does not crash ash). Pressing ^C in ash does not stop running
programs though.
-rw-r--r-- | libbb/lineedit.c | 2 | ||||
-rw-r--r-- | win32/termios.c | 6 |
2 files changed, 8 insertions, 0 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 413782d06..182dfac13 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1916,6 +1916,8 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li | |||
1916 | 1916 | ||
1917 | #if ENABLE_PLATFORM_MINGW32 | 1917 | #if ENABLE_PLATFORM_MINGW32 |
1918 | memset(initial_settings.c_cc, sizeof(initial_settings.c_cc), 0); | 1918 | memset(initial_settings.c_cc, sizeof(initial_settings.c_cc), 0); |
1919 | initial_settings.c_cc[VINTR] = CTRL('C'); | ||
1920 | initial_settings.c_cc[VEOF] = CTRL('D'); | ||
1919 | if (!isatty(0) || !isatty(1)) { | 1921 | if (!isatty(0) || !isatty(1)) { |
1920 | #else | 1922 | #else |
1921 | if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 | 1923 | if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 |
diff --git a/win32/termios.c b/win32/termios.c index e2dc96361..34a17bbfd 100644 --- a/win32/termios.c +++ b/win32/termios.c | |||
@@ -31,6 +31,12 @@ int64_t FAST_FUNC read_key(int fd, char *buf, int timeout UNUSED_PARAM) | |||
31 | continue; | 31 | continue; |
32 | if (!record.Event.KeyEvent.uChar.AsciiChar) { | 32 | if (!record.Event.KeyEvent.uChar.AsciiChar) { |
33 | DWORD state = record.Event.KeyEvent.dwControlKeyState; | 33 | DWORD state = record.Event.KeyEvent.dwControlKeyState; |
34 | |||
35 | if (state & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) && | ||
36 | (record.Event.KeyEvent.wVirtualKeyCode >= 'A' && | ||
37 | record.Event.KeyEvent.wVirtualKeyCode <= 'Z')) | ||
38 | return record.Event.KeyEvent.wVirtualKeyCode & ~0x40; | ||
39 | |||
34 | switch (record.Event.KeyEvent.wVirtualKeyCode) { | 40 | switch (record.Event.KeyEvent.wVirtualKeyCode) { |
35 | case VK_DELETE: return KEYCODE_DELETE; | 41 | case VK_DELETE: return KEYCODE_DELETE; |
36 | case VK_INSERT: return KEYCODE_INSERT; | 42 | case VK_INSERT: return KEYCODE_INSERT; |