Support multi-code-point characters in TerminalInput::HandleKey #3986

Open
opened 2026-01-30 23:34:56 +00:00 by claunia · 1 comment
Owner

Originally created by @lhecker on GitHub (Sep 23, 2019).

Description of the new feature/enhancement

Starting with #2836 key events containing combinations like Shift. (here: US keyboard layout) will be mapped to their matching, potentially non-ASCII, counterparts (here: >).
This is achieved using the ToUnicodeEx method.

But this leads to a problem: ToUnicodeEx can potentially return multiple code points.
TerminalInput::HandleKey and its KeyEvent parameter only accept a single code point though.

👉 TerminalInput and KeyEvent should be modified to accommodate multi-code-point characters (i.e. e.g. by replacing wchar_t with std::wstring).

Originally created by @lhecker on GitHub (Sep 23, 2019). # Description of the new feature/enhancement Starting with #2836 key events containing combinations like <kbd>Shift</kbd><kbd>.</kbd> (here: US keyboard layout) will be mapped to their matching, potentially non-ASCII, counterparts (here: <kbd>></kbd>). This is achieved using the [`ToUnicodeEx` method](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-tounicodeex). But this leads to a problem: `ToUnicodeEx` can potentially return multiple code points. [`TerminalInput::HandleKey`](https://github.com/microsoft/terminal/blob/8afc5b2f596335b47ecc89172ccd9820ec510579/src/terminal/input/terminalInput.cpp#L364) and its [`KeyEvent`](https://github.com/microsoft/terminal/blob/8afc5b2f596335b47ecc89172ccd9820ec510579/src/types/inc/IInputEvent.hpp#L120) parameter only accept a single code point though. 👉 `TerminalInput` and `KeyEvent` should be modified to accommodate multi-code-point characters (i.e. e.g. by replacing `wchar_t` with `std::wstring`).
claunia added the Issue-FeatureProduct-ConhostArea-InputProduct-Terminal labels 2026-01-30 23:34:56 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Sep 23, 2019):

This is good and righteous work that needs a design -- a lot of the key input stuff that comes through TerminalInput is that way for compatibility with the ReadConsoleInput API. That API can only transit WCHARs 😄

@DHowett-MSFT commented on GitHub (Sep 23, 2019): This is good and righteous work that needs a design -- a lot of the key input stuff that comes through `TerminalInput` is that way for _compatibility with the ReadConsoleInput API_. That API can only transit WCHARs :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#3986