-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Description
Description of the new feature
Description of the new feature / enhancement
I propose a refinement to the win32-input-mode (enabled via ^[[?9001h), originally introduced in spec 4999.
Currently, when this mode is active, all keyboard input is converted into generated CSI sequences (^[[Vk;Sc;Uc;Kd;Cs;Rc_). I request a modification (or a sub-parameter) to make this mode behave as a progressive enhancement, similar to how the kitty keyboard protocol or standard VT behavior works:
- Standard printable characters should remain as plain text.
- Standard signals (like
Ctrl+C) should be sent as signals/bytes (SIGINT/\x03), not as escape sequences. - Only complex keys (which cannot be represented by standard VT, e.g.,
Ctrl+Space,Shift+Enter, independent modifier presses, KeyUp events) should use thewin32-input-modeencoding.
Why is this needed? (The "Bricked Terminal" Problem)
This request is directly motivated by the refusal of shell maintainers (specifically fish-shell) to support the current protocol.
As discussed in fish-shell issue #11877, the current "all-or-nothing" approach creates a critical reliability issue:
"It also appears to send every key in the new encoding... so if it remains turned on (e.g. because of a crash in a program that turns it on), it renders the session unusable." — @faho (fish-shell maintainer)
The Scenario:
- A user launches a tool that enables
win32-input-mode. - The tool crashes or hangs without properly disabling the mode.
- The user is dropped back into the shell.
- The terminal becomes unusable. The user cannot type
resetto fix the terminal, because the shell receives complex escape sequences instead of the charactersr,e,s,e,t. EvenCtrl+Cis sent as a sequence, effectively preventing the user from interrupting the hung state via standard means.
Because of this risk, generic shells are unlikely to adopt win32-input-mode in its current form.
Current Adoption vs Potential
The protocol is already valuable and is used by specialized applications like:
However, wider adoption in the ecosystem (shells like fish, zsh, bash, and other CLI tools) depends on safety. If win32-input-mode sent standard keys as-is, it would allow shells to support rich input scenarios (like Ctrl+Alt+? or Shift+Enter bindings) without the risk of breaking the session in case of a crash.