From 79c85ec59075b5ead415a4713bd72445546dcf8e Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Fri, 15 Mar 2019 10:07:14 +0000 Subject: lineedit: add a command to change backslashes to slashes When a path name is copied to a console application using drag and drop the path separator is backslash. To handle this situation in the shell add an editing command (Ctrl-Z) to convert all backslashes on the current line to slashes. See GitHub issue #149. Also remove some unused code from read_key(). --- libbb/lineedit.c | 7 +++++++ win32/termios.c | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 95f92aa75..abe2857b2 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -2607,6 +2607,13 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman case '\t': input_tab(&lastWasTab); break; +#endif +#if ENABLE_PLATFORM_MINGW32 + case CTRL('Z'): + command_ps[command_len] = '\0'; + convert_slashes(command_ps); + redraw(cmdedit_y, 0); + break; #endif case CTRL('K'): /* Control-k -- clear to end of line */ diff --git a/win32/termios.c b/win32/termios.c index fe6f0c546..25f2ea48c 100644 --- a/win32/termios.c +++ b/win32/termios.c @@ -71,12 +71,6 @@ int64_t FAST_FUNC read_key(int fd, char *buf UNUSED_PARAM, int timeout) continue; } } - if (state & (RIGHT_CTRL_PRESSED|LEFT_CTRL_PRESSED) && - (record.Event.KeyEvent.wVirtualKeyCode >= 'A' && - record.Event.KeyEvent.wVirtualKeyCode <= 'Z')) { - ret = record.Event.KeyEvent.wVirtualKeyCode & ~0x40; - break; - } switch (record.Event.KeyEvent.wVirtualKeyCode) { case VK_DELETE: ret = KEYCODE_DELETE; goto done; -- cgit v1.2.3-55-g6feb