How should applications behave when running under Windows Terminal if they want to maximize functionality? #22472

Open
opened 2026-01-31 08:14:25 +00:00 by claunia · 0 comments
Owner

Originally created by @marchelzo on GitHub (Oct 30, 2024).

Hi, I'm working on a cross-platform readline-esque library and one of the goals is to take full advantage of the capabilities of whatever terminal emulator is being used.

From what I understood reading the Console API docs on MSDN, Windows Terminal seems to be trying to move away from the Win32 Console API and behave more like terminals on other platforms, supporting various CSI and DCS escape sequences etc., but I have some questions:

  • Since termios and ioctl don't exist in Windows, do we still use the Console API for things like getting Windows Terminal out of line-input mode, or requesting the window size?

  • I made a small test program which sets the console mode to ENABLE_VIRTUAL_TERMINAL_INPUT | ENABLE_PROCESSED_INPUT and then reads KEY_EVENT_RECORDs using ReadConsoleInputA(). Under conhost.exe, the KeyEvent.dwControlKeyState field seems to be populated correctly, but under Windows Terminal it's always zero. Is there a way for applications to handle arbitrary keyboard input in Windows Terminal? If not, what approach should we be using to handle a many different key events as possible?

Sorry if this is all documented somewhere and I missed it. Any links to further reading would be appreciated!

Originally created by @marchelzo on GitHub (Oct 30, 2024). Hi, I'm working on a cross-platform readline-esque library and one of the goals is to take full advantage of the capabilities of whatever terminal emulator is being used. From what I understood reading the Console API docs on MSDN, Windows Terminal seems to be trying to move away from the Win32 Console API and behave more like terminals on other platforms, supporting various CSI and DCS escape sequences etc., but I have some questions: - Since `termios` and `ioctl` don't exist in Windows, do we still use the Console API for things like getting Windows Terminal out of line-input mode, or requesting the window size? - I made a small test program which sets the console mode to `ENABLE_VIRTUAL_TERMINAL_INPUT | ENABLE_PROCESSED_INPUT ` and then reads `KEY_EVENT_RECORD`s using `ReadConsoleInputA()`. Under `conhost.exe`, the `KeyEvent.dwControlKeyState` field seems to be populated correctly, but under Windows Terminal it's always zero. Is there a way for applications to handle arbitrary keyboard input in Windows Terminal? If not, what approach should we be using to handle a many different key events as possible? Sorry if this is all documented somewhere and I missed it. Any links to further reading would be appreciated!
claunia added the Issue-QuestionNeeds-Tag-Fix labels 2026-01-31 08:14:25 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22472