[PR #4192] Delegate all character input to the character event handler #25683

Open
opened 2026-01-31 09:11:07 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4192

State: closed
Merged: Yes


My basic idea was that WM_CHAR is just the better WM_KEYDOWN.
The latter fails to properly support common dead key sequences like in
#3516.

As such I added some logic to Terminal::SendKeyEvent to make it return
false if the pressed key represents a printable character.
This causes us to receive a character event with a (hopefully) correctly
composed code unit, which then gets sent to Terminal::SendCharEvent.
Terminal::SendCharEvent in turn had to be modified to support
potentially pressed modifier keys, since Terminal::SendKeyEvent isn't
doing that for us anymore.
Lastly TerminalInput had to be modified heavily to support character
events with modifier key states. In order to do so I merged its
HandleKey and HandleChar methods into a single one, that now handles
both cases.
Since key events will now contain character data and character events
key codes the decision logic in TerminalInput::HandleKey had to be
rewritten.

PR Checklist

  • CLA signed
  • Tests added/passed
  • I've discussed this with core contributors already.

Validation Steps Performed

  • See #3516.
  • I don't have any keyboard that generates surrogate characters. Due to
    this I modified TermControl::_SendPastedTextToConnection to send the
    data to _terminal->SendCharEvent() instead. I then pasted the test
    string ""𐐌𐐜𐐬" and ensured that the new TerminalInput::_SendChar
    method still correctly assembles surrogate pairs.

Closes #3516
Closes #3554 (obsoleted by this PR)
Potentially impacts #391, which sounds like a duplicate of #3516

**Original Pull Request:** https://github.com/microsoft/terminal/pull/4192 **State:** closed **Merged:** Yes --- My basic idea was that `WM_CHAR` is just the better `WM_KEYDOWN`. The latter fails to properly support common dead key sequences like in #3516. As such I added some logic to `Terminal::SendKeyEvent` to make it return false if the pressed key represents a printable character. This causes us to receive a character event with a (hopefully) correctly composed code unit, which then gets sent to `Terminal::SendCharEvent`. `Terminal::SendCharEvent` in turn had to be modified to support potentially pressed modifier keys, since `Terminal::SendKeyEvent` isn't doing that for us anymore. Lastly `TerminalInput` had to be modified heavily to support character events with modifier key states. In order to do so I merged its `HandleKey` and `HandleChar` methods into a single one, that now handles both cases. Since key events will now contain character data and character events key codes the decision logic in `TerminalInput::HandleKey` had to be rewritten. ## PR Checklist * [x] CLA signed * [x] Tests added/passed * [x] I've discussed this with core contributors already. ## Validation Steps Performed * See #3516. * I don't have any keyboard that generates surrogate characters. Due to this I modified `TermControl::_SendPastedTextToConnection` to send the data to `_terminal->SendCharEvent()` instead. I then pasted the test string ""𐐌𐐜𐐬" and ensured that the new `TerminalInput::_SendChar` method still correctly assembles surrogate pairs. Closes #3516 Closes #3554 (obsoleted by this PR) Potentially impacts #391, which sounds like a duplicate of #3516
claunia added the pull-request label 2026-01-31 09:11:07 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25683