-
Notifications
You must be signed in to change notification settings - Fork 164
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
Keys using escape sequences (arrow keys, home/end) don't work with Bash on Windows #82
Comments
Improve debugging for the case where SetConsoleMode fails. Apparently on Windows 7, the call fails, but the 0x200 flag is still enabled. A later GetConsoleMode call succeeds, but of course, further calls to SetConsoleMode will still fail unless they unset 0x200. Given that the 0x200 flag is undocumented and only respected in preview releases, I'm hesistant to clear the flag when --escape-input isn't set. Related to #82
winpty must decode sequences if it is to generate the key-up event records, though I suppose |
I've just tried winpty as a gateway between mintty and Ubuntu bash on Windows, see mintty/mintty#558 (comment). |
There isn't a way to do that now, but it'd be easy to add, and it would make sense to use that option with mintty. Most likely, in that new mode, winpty would not bother generating any KeyUp events. I don't think WSL bash cares about them. I suspect that mouse input still wouldn't work, though, unless the user manually passed |
When running Bash-on-Windows under winpty, keys encoded using escape sequences have no effect.
I tested with the latest Windows 10 preview release, 14342. It looks like there is a new, undocumented mode flag on the console input handle, 0x200. In that mode, most key-down and key-up key events are still generated as before, but for keys that use escape sequences on Ubuntu, the Windows console instead generates a series of
KEY_EVENT
records encoding the sequence.The escape sequence replaces the normal key-down record, which is not generated. The key-up record is generated as before. In the records, the
bKeyDown
andwRepeatCount
fields are TRUE and 1 (as before), and theUnicodeChar
has the appropriate character, but all other fields are zeroed. (In particular,wVirtualScanCode
andwVirtualKeyCode
are 0.)Example from
winpty-agent --show-input --escape-input
for Ctrl-Alt-Shift-UP:Obviously, if Windows is going to behave this way, then winpty needs to detect the 0x200 console mode and emit escape sequences.
The interesting design question is whether winpty should send its terminal input directly to Ubuntu, or whether it should continue decoding input, but reencode escape sequences.
It looks like Windows currently ignores modifier keys when escaping. If winpty were to match Windows' encoding, it would merely have to map virtual keys to an escape string. Keys include: ESC, F1-F12, INS, DEL, HOME, END, PGUP, PGDN, UP, DN, LEFT, RIGHT. That might be all of them.
The text was updated successfully, but these errors were encountered: