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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4192
Author: @lhecker
Created: 1/12/2020
Status: ✅ Merged
Merged: 4/7/2020
Merged by: @undefined

Base: master ← Head: input-handling-fixes


📝 Commits (2)

  • d566d68 Delegate all character input to the character event handler
  • 47f6c42 Addressed review comments

📊 Changes

12 files changed (+436 additions, -339 deletions)

View changed files

📝 src/cascadia/PublicTerminalCore/HwndTerminal.cpp (+12 -6)
📝 src/cascadia/PublicTerminalCore/HwndTerminal.hpp (+4 -4)
📝 src/cascadia/TerminalControl/TermControl.cpp (+3 -2)
📝 src/cascadia/TerminalCore/ITerminalInput.hpp (+1 -1)
📝 src/cascadia/TerminalCore/Terminal.cpp (+122 -43)
📝 src/cascadia/TerminalCore/Terminal.hpp (+14 -1)
📝 src/cascadia/UnitTests_TerminalCore/InputTest.cpp (+3 -2)
📝 src/cascadia/WpfTerminalControl/NativeMethods.cs (+2 -2)
📝 src/cascadia/WpfTerminalControl/TerminalContainer.cs (+4 -2)
📝 src/terminal/adapter/ut_adapter/inputTest.cpp (+139 -168)
📝 src/terminal/input/terminalInput.cpp (+130 -106)
📝 src/terminal/input/terminalInput.hpp (+2 -2)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4192 **Author:** [@lhecker](https://github.com/lhecker) **Created:** 1/12/2020 **Status:** ✅ Merged **Merged:** 4/7/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `input-handling-fixes` --- ### 📝 Commits (2) - [`d566d68`](https://github.com/microsoft/terminal/commit/d566d68b776dd5c15efa09bcdfb6b6acce558444) Delegate all character input to the character event handler - [`47f6c42`](https://github.com/microsoft/terminal/commit/47f6c4261803bd949a7d4bac4625d3c201fc2541) Addressed review comments ### 📊 Changes **12 files changed** (+436 additions, -339 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/PublicTerminalCore/HwndTerminal.cpp` (+12 -6) 📝 `src/cascadia/PublicTerminalCore/HwndTerminal.hpp` (+4 -4) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+3 -2) 📝 `src/cascadia/TerminalCore/ITerminalInput.hpp` (+1 -1) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+122 -43) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+14 -1) 📝 `src/cascadia/UnitTests_TerminalCore/InputTest.cpp` (+3 -2) 📝 `src/cascadia/WpfTerminalControl/NativeMethods.cs` (+2 -2) 📝 `src/cascadia/WpfTerminalControl/TerminalContainer.cs` (+4 -2) 📝 `src/terminal/adapter/ut_adapter/inputTest.cpp` (+139 -168) 📝 `src/terminal/input/terminalInput.cpp` (+130 -106) 📝 `src/terminal/input/terminalInput.hpp` (+2 -2) </details> ### 📄 Description 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:11:05 +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#25678