vt, input: translate \0 as Ctrl+Space#899
Open
DHowett wants to merge 1 commit into
Open
Conversation
There exists an ambiguous control character in standard 7-bit ASCII
terminals, `\0`, which is the traditional encoding for Ctrl+Space and
Ctrl+Shift+2 (or Ctrl+@ on US-104 keyboards).
```
Space 0x20 0b00100000
@ 0x40 0b01000000
^^^^^
control character bits 0b00000
```
Anyway, edit didn't support it. We also had a bug in the Windows
KEY_EVENT parser where we would disregard otherwise acceptable inputs
such as `\0` with a scancode indicating that it came from a keypress
(such as, well, Ctrl+Space).
Member
Author
|
/cc @mgreenegit |
Member
Author
|
No work was necessary in |
DHowett
commented
Jul 23, 2026
| let ch = unsafe { event.uChar.UnicodeChar }; | ||
| if event.bKeyDown != 0 && ch != 0 { | ||
| let sc = event.wVirtualScanCode; | ||
| if event.bKeyDown != 0 && (ch != 0 || sc == 0) { |
Member
Author
There was a problem hiding this comment.
this is in line with the console's recommendation on how to handle VT input (ugly though it may be)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There exists an ambiguous control character in standard 7-bit ASCII terminals,
\0, which is the traditional encoding for Ctrl+Space and Ctrl+Shift+2 (or Ctrl+@ on US-104 keyboards).Anyway, edit didn't support it. We also had a bug in the Windows KEY_EVENT parser where we would disregard otherwise acceptable inputs such as
\0without a scancode (indicating that it was generated by the console subsystem directly).Supersedes #870