Skip to content

vt, input: translate \0 as Ctrl+Space#899

Open
DHowett wants to merge 1 commit into
mainfrom
dev/duhowett/ctrl_space
Open

vt, input: translate \0 as Ctrl+Space#899
DHowett wants to merge 1 commit into
mainfrom
dev/duhowett/ctrl_space

Conversation

@DHowett

@DHowett DHowett commented Jul 23, 2026

Copy link
Copy Markdown
Member

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 without a scancode (indicating that it was generated by the console subsystem directly).

Supersedes #870

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).
@DHowett

DHowett commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

/cc @mgreenegit

@DHowett

DHowett commented Jul 23, 2026

Copy link
Copy Markdown
Member Author

No work was necessary in sys::unix::read_stdin, as it already read \0 into the buffer.

let ch = unsafe { event.uChar.UnicodeChar };
if event.bKeyDown != 0 && ch != 0 {
let sc = event.wVirtualScanCode;
if event.bKeyDown != 0 && (ch != 0 || sc == 0) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in line with the console's recommendation on how to handle VT input (ugly though it may be)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant