[PR #10824] [MERGED] Implement Keyboard Selection #28247

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10824
Author: @carlos-zamora
Created: 7/30/2021
Status: Merged
Merged: 9/23/2021
Merged by: @carlos-zamora

Base: mainHead: dev/cazamor/keyboard-selection


📝 Commits (10+)

📊 Changes

12 files changed (+306 additions, -51 deletions)

View changed files

📝 doc/cascadia/profiles.schema.json (+1 -1)
📝 src/buffer/out/textBuffer.cpp (+7 -3)
📝 src/buffer/out/textBuffer.hpp (+1 -1)
📝 src/cascadia/PublicTerminalCore/HwndTerminal.cpp (+2 -2)
📝 src/cascadia/TerminalControl/ControlCore.cpp (+20 -11)
📝 src/cascadia/TerminalCore/Terminal.hpp (+24 -6)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+230 -7)
📝 src/cascadia/TerminalCore/terminalrenderdata.cpp (+1 -1)
📝 src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp (+17 -17)
📝 src/host/ut_host/TextBufferTests.cpp (+1 -1)
📝 src/renderer/dx/DxRenderer.cpp (+1 -0)
📝 src/types/UiaTextRangeBase.cpp (+1 -1)

📄 Description

Summary of the Pull Request

Implements the following keyboard selection non-configurable key bindings:

  • shift+arrow --> move endpoint by character
  • ctrl+shift+left/right --> move endpoint by word
  • shift+home/end --> move to beginning/end of line
  • ctrl+shift+home/end --> move to beginning/end of buffer

This was purposefully done in the ControlCore layer to make keyboard selection an innate part of how the terminal functions (aka a shared component across terminal consumers).

References

#715 - Keyboard Selection
#2840 - Spec

Detailed Description of the Pull Request / Additional comments

The most relevant section is TerminalSelection.cpp, where we define how each movement operates. It's basically a giant embedded switch-case statement. We leverage a lot of the work done in a11y to perform the movements.

Validation Steps Performed

  • General cases:
    • test all of the key bindings added
  • Corner cases:
    • char: wide glyph support
    • word: move towards, away, and across the selection pivot
    • automatically scroll viewport
    • ESC (and other key combos) are still clearing the selection properly

🔄 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/10824 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 7/30/2021 **Status:** ✅ Merged **Merged:** 9/23/2021 **Merged by:** [@carlos-zamora](https://github.com/carlos-zamora) **Base:** `main` ← **Head:** `dev/cazamor/keyboard-selection` --- ### 📝 Commits (10+) - [`428dec9`](https://github.com/microsoft/terminal/commit/428dec97028d3c9f8337c5f3c31ff7f485ac36e9) Implement Keyboard Selection - [`bcbf01e`](https://github.com/microsoft/terminal/commit/bcbf01e8cb3ac6127c74ddf737814b49ed2059be) apply feedback from zadji - [`a0e4f2d`](https://github.com/microsoft/terminal/commit/a0e4f2dd051f77bcb17b8494af80875107bf31c7) fix schema - [`8a64613`](https://github.com/microsoft/terminal/commit/8a646138f4216a4e6ca6d2676645f5c0059df21e) fix build (primarily PublicTerminalCore) - [`724cd2c`](https://github.com/microsoft/terminal/commit/724cd2c2ca7e09c9559532441f37901dcc27fc06) fix build - [`bf0cf5f`](https://github.com/microsoft/terminal/commit/bf0cf5f0d25da02da329069a4fc9f4111fd8b641) add TODO GH behind for duplicate enum - [`b13b8a7`](https://github.com/microsoft/terminal/commit/b13b8a78964f43d45c34e5a504ac0f1e003fc710) remove unnecessary explicit namespace - [`118d1cd`](https://github.com/microsoft/terminal/commit/118d1cdc023f33a06fb88e160d8f4defb5b14e39) remove configurability - [`30009eb`](https://github.com/microsoft/terminal/commit/30009eb0eb278a432c23a30b0dfa493eb4cd87bc) polish and fix build - [`b784262`](https://github.com/microsoft/terminal/commit/b7842624a05d54b8af488c74cbb2326ca8ff797f) address Leonard's comments ### 📊 Changes **12 files changed** (+306 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `doc/cascadia/profiles.schema.json` (+1 -1) 📝 `src/buffer/out/textBuffer.cpp` (+7 -3) 📝 `src/buffer/out/textBuffer.hpp` (+1 -1) 📝 `src/cascadia/PublicTerminalCore/HwndTerminal.cpp` (+2 -2) 📝 `src/cascadia/TerminalControl/ControlCore.cpp` (+20 -11) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+24 -6) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+230 -7) 📝 `src/cascadia/TerminalCore/terminalrenderdata.cpp` (+1 -1) 📝 `src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp` (+17 -17) 📝 `src/host/ut_host/TextBufferTests.cpp` (+1 -1) 📝 `src/renderer/dx/DxRenderer.cpp` (+1 -0) 📝 `src/types/UiaTextRangeBase.cpp` (+1 -1) </details> ### 📄 Description ## Summary of the Pull Request Implements the following keyboard selection non-configurable key bindings: - shift+arrow --> move endpoint by character - ctrl+shift+left/right --> move endpoint by word - shift+home/end --> move to beginning/end of line - ctrl+shift+home/end --> move to beginning/end of buffer This was purposefully done in the ControlCore layer to make keyboard selection an innate part of how the terminal functions (aka a shared component across terminal consumers). ## References #715 - Keyboard Selection #2840 - Spec ## Detailed Description of the Pull Request / Additional comments The most relevant section is `TerminalSelection.cpp`, where we define how each movement operates. It's basically a giant embedded switch-case statement. We leverage a lot of the work done in a11y to perform the movements. ## Validation Steps Performed - General cases: - test all of the key bindings added - Corner cases: - `char`: wide glyph support - `word`: move towards, away, and across the selection pivot - automatically scroll viewport - ESC (and other key combos) are still clearing the selection properly --- <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:27:17 +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#28247