[PR #4560] [MERGED] Move rect expansion to textbuffer; refactor selection code #25835

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4560
Author: @carlos-zamora
Created: 2/13/2020
Status: ✅ Merged
Merged: 2/28/2020
Merged by: @DHowett-MSFT

Base: master ← Head: dev/cazamor/acc/get-selection-rects


📝 Commits (10+)

  • 34837d7 Move common GetSelectionRects() functionality to TextBuffer
  • a160740 Convert all selection anchors to buffer coords
  • 9a27378 Fix Chunk Selection
  • 8b1b057 Fix Shift+Click (sorta)
  • d04a0ac fix annoying shift+click bug
  • 112ad5a fix line endings to CRLS
  • e14bcfe Merge branch 'master' into dev/cazamor/acc/get-selection-rects
  • da62e35 Fix static analysis issues
  • 26b3097 fix PublicTerminalCore
  • f5048fc fix tests

📊 Changes

18 files changed (+394 additions, -528 deletions)

View changed files

📝 src/buffer/out/textBuffer.cpp (+95 -0)
📝 src/buffer/out/textBuffer.hpp (+4 -0)
📝 src/cascadia/PublicTerminalCore/HwndTerminal.cpp (+2 -2)
📝 src/cascadia/TerminalControl/TermControl.cpp (+6 -6)
📝 src/cascadia/TerminalCore/Terminal.cpp (+3 -5)
📝 src/cascadia/TerminalCore/Terminal.hpp (+22 -21)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+131 -268)
📝 src/cascadia/TerminalCore/terminalrenderdata.cpp (+1 -1)
📝 src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp (+31 -31)
📝 src/host/renderData.cpp (+1 -1)
📝 src/host/renderData.hpp (+1 -1)
📝 src/host/selection.cpp (+13 -171)
📝 src/host/selection.hpp (+0 -9)
📝 src/host/ut_host/SelectionTests.cpp (+14 -9)
📝 src/host/ut_host/TextBufferTests.cpp (+67 -0)
📝 src/interactivity/win32/screenInfoUiaProvider.cpp (+1 -1)
📝 src/types/IUiaData.h (+1 -1)
📝 src/types/TermControlUiaProvider.cpp (+1 -1)

📄 Description

  • When performing chunk selection, the expansion now occurs at the time
    of the selection, not the rendering of the selection
  • GetSelectionRects() was moved to the TextBuffer and is now shared
    between ConHost and Windows Terminal
  • Some of the selection variables were renamed for clarity
  • Selection COORDs are now in the Text Buffer coordinate space
  • Fixes an issue with Shift+Click after performing a Multi-Click
    Selection

References

This also contributes to...

  • #4509: UIA Box Selection
  • #2447: UIA Signaling for Selection
  • #1354: UIA support for Wide Glyphs

Now that the expansion occurs at before render-time, the selection
anchors are an accurate representation of what is selected. We just need
to move GetText to the TextBuffer. Then we can have those three
issues just rely on code from the text buffer. This also means ConHost
gets some of this stuff for free 😀

TextBuffer

  • GetTextRects is the abstracted form of GetSelectionRects
  • _ExpandTextRow is still needed to handle wide glyphs properly

Terminal

  • Rename...
    • _boxSelection --> _blockSelection for consistency with ConHost
    • _selectionAnchor --> _selectionStart for consistency with UIA
    • _endSelectionPosition --> _selectionEnd for consistency with
      UIA
  • Selection anchors are in Text Buffer coordinates now
  • Really rely on SetSelectionEnd to accomplish appropriate chunk
    selection and shift+click actions

Validation Steps Performed

  • Shift+Click
  • Multi-Click --> Shift+Click
  • Chunk Selection at...
    • top of buffer
    • bottom of buffer
    • random region in scrollback

Closes #4465
Closes #4547


🔄 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/4560 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 2/13/2020 **Status:** ✅ Merged **Merged:** 2/28/2020 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `dev/cazamor/acc/get-selection-rects` --- ### 📝 Commits (10+) - [`34837d7`](https://github.com/microsoft/terminal/commit/34837d7771990bc2670600d25892b98c08a27062) Move common GetSelectionRects() functionality to TextBuffer - [`a160740`](https://github.com/microsoft/terminal/commit/a16074064c82bda33d383c65686eb1a07c4f4559) Convert all selection anchors to buffer coords - [`9a27378`](https://github.com/microsoft/terminal/commit/9a273788e3e617eac099bd5fc4f6e6d52cf0278c) Fix Chunk Selection - [`8b1b057`](https://github.com/microsoft/terminal/commit/8b1b05746f215b7c74a05a8ea28ad98e1775a186) Fix Shift+Click (sorta) - [`d04a0ac`](https://github.com/microsoft/terminal/commit/d04a0acee990afd5e61aa4b831f3fd6a3f15b726) fix annoying shift+click bug - [`112ad5a`](https://github.com/microsoft/terminal/commit/112ad5aaddf9286e40e6c8360b1fdff3d4ae556d) fix line endings to CRLS - [`e14bcfe`](https://github.com/microsoft/terminal/commit/e14bcfee1d0302b80069ce4c28c30da1129f872b) Merge branch 'master' into dev/cazamor/acc/get-selection-rects - [`da62e35`](https://github.com/microsoft/terminal/commit/da62e35c04c230b63be359592fd691961f4e4ba3) Fix static analysis issues - [`26b3097`](https://github.com/microsoft/terminal/commit/26b3097be5112b395c3555927931aaca235cec20) fix PublicTerminalCore - [`f5048fc`](https://github.com/microsoft/terminal/commit/f5048fc440abd1e26b78a000e3e563c8d7aa7ad6) fix tests ### 📊 Changes **18 files changed** (+394 additions, -528 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/textBuffer.cpp` (+95 -0) 📝 `src/buffer/out/textBuffer.hpp` (+4 -0) 📝 `src/cascadia/PublicTerminalCore/HwndTerminal.cpp` (+2 -2) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+6 -6) 📝 `src/cascadia/TerminalCore/Terminal.cpp` (+3 -5) 📝 `src/cascadia/TerminalCore/Terminal.hpp` (+22 -21) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+131 -268) 📝 `src/cascadia/TerminalCore/terminalrenderdata.cpp` (+1 -1) 📝 `src/cascadia/UnitTests_TerminalCore/SelectionTest.cpp` (+31 -31) 📝 `src/host/renderData.cpp` (+1 -1) 📝 `src/host/renderData.hpp` (+1 -1) 📝 `src/host/selection.cpp` (+13 -171) 📝 `src/host/selection.hpp` (+0 -9) 📝 `src/host/ut_host/SelectionTests.cpp` (+14 -9) 📝 `src/host/ut_host/TextBufferTests.cpp` (+67 -0) 📝 `src/interactivity/win32/screenInfoUiaProvider.cpp` (+1 -1) 📝 `src/types/IUiaData.h` (+1 -1) 📝 `src/types/TermControlUiaProvider.cpp` (+1 -1) </details> ### 📄 Description - When performing chunk selection, the expansion now occurs at the time of the selection, not the rendering of the selection - `GetSelectionRects()` was moved to the `TextBuffer` and is now shared between ConHost and Windows Terminal - Some of the selection variables were renamed for clarity - Selection COORDs are now in the Text Buffer coordinate space - Fixes an issue with Shift+Click after performing a Multi-Click Selection ## References This also contributes to... - #4509: UIA Box Selection - #2447: UIA Signaling for Selection - #1354: UIA support for Wide Glyphs Now that the expansion occurs at before render-time, the selection anchors are an accurate representation of what is selected. We just need to move `GetText` to the `TextBuffer`. Then we can have those three issues just rely on code from the text buffer. This also means ConHost gets some of this stuff for free 😀 ### TextBuffer - `GetTextRects` is the abstracted form of `GetSelectionRects` - `_ExpandTextRow` is still needed to handle wide glyphs properly ### Terminal - Rename... - `_boxSelection` --> `_blockSelection` for consistency with ConHost - `_selectionAnchor` --> `_selectionStart` for consistency with UIA - `_endSelectionPosition` --> `_selectionEnd` for consistency with UIA - Selection anchors are in Text Buffer coordinates now - Really rely on `SetSelectionEnd` to accomplish appropriate chunk selection and shift+click actions ## Validation Steps Performed - Shift+Click - Multi-Click --> Shift+Click - Chunk Selection at... - top of buffer - bottom of buffer - random region in scrollback Closes #4465 Closes #4547 --- <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:12: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#25835