-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash-on-Windows input handling doesn't account for alternate terminal modes #90
Comments
It looks like the |
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A terminal can be placed into alternate modes where some keypresses generate alternate input escape sequences. For example, xterm/mintty typically generates
\e[A
for Up, but if I first output\e[?1h
, then Up instead generates\eOA
. Outputting\e[?1l
restores the normal mode.The Windows console (as of 14393 at least), implements this mode-switching behavior. When I tested, the console modes reported by
GetConsoleMode
(input and output) did not change as the terminal arrow key mode was toggled.This issue affects Ubuntu 14.04's Midnight Commander, which apparently expects the "O" versions of the arrow key escapes. The arrow keys have no effect, other than to suppress all keyboard input for a moment while mc discards the input buffer.
Aside: While it looks like mc should also be OK with the normal escapes, at least in Ubuntu 14.04, the program's config file handling is buggy, so it doesn't work. (See here and here). When it iterates over the profile keys, it does so by string value, so it sees
up
twice, but looks up the\\eOA
value both times. I tried to expose the bug more easily by swapping the two lines around in a normal, working configuration, but that didn't expose the failure. I had noticed that mc also reads a terminal database somehow (ncurses / SLang?), where it also finds the "O" escapes. I assume that explains it.Maybe it's possible to fix this issue by sending some keys to the console HWND rather than calling
WriteConsoleInput
. I think winpty would have to send the keys synchronously. It already uses the synchronousSendMessage
for freezing/unfreezing. I don't think it can do that for all keys, because the console will interpret some of them. I think it's OK to send a key even if the console input buffer is non-empty; the console should append the new key.The text was updated successfully, but these errors were encountered: