[PR #4578] [MERGED] Abstract GetTextForClipboard() for UIA #25845

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4578
Author: @carlos-zamora
Created: 2/14/2020
Status: ✅ Merged
Merged: 3/9/2020
Merged by: @carlos-zamora

Base: master ← Head: dev/cazamor/acc/get-text


📝 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

13 files changed (+353 additions, -166 deletions)

View changed files

📝 src/buffer/out/textBuffer.cpp (+60 -40)
📝 src/buffer/out/textBuffer.hpp (+5 -5)
📝 src/cascadia/TerminalApp/TerminalPage.cpp (+1 -1)
📝 src/cascadia/TerminalControl/TermControl.cpp (+5 -6)
📝 src/cascadia/TerminalControl/TermControl.h (+1 -1)
📝 src/cascadia/TerminalControl/TermControl.idl (+1 -1)
📝 src/cascadia/TerminalCore/TerminalSelection.cpp (+14 -13)
📝 src/host/ut_host/ClipboardTests.cpp (+2 -4)
📝 src/host/ut_host/TextBufferTests.cpp (+213 -2)
📝 src/interactivity/win32/Clipboard.cpp (+21 -30)
📝 src/interactivity/win32/clipboard.hpp (+1 -5)
📝 src/types/UiaTextRangeBase.cpp (+28 -57)
📝 src/types/UiaTextRangeBase.hpp (+1 -1)

📄 Description

Summary of the Pull Request

GetTextForClipboard already exists in the TextBuffer. It makes sense to use that for UIA as well. This changes the behavior or GetText() such that it does not remove leading/trailing whitespace anymore. That is more of an expected behavior.

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 😀

PR Checklist

  • CLA signed.
  • Tests added/passed

Detailed Description of the Pull Request / Additional comments

  • TextBuffer::GetTextForClipboard() --> GetText()
  • TextBuffer::GetText() no longer requires GetForegroundColor/GetBackgroundColor. If either of these are not defined, we return a TextAndColor with only the text field populated.
  • renamed a few parameters for copying text to the clipboard for clarity
  • Updated UiaTextRange::GetText() to use TextBuffer::GetText()
    • ⚠ NOTE: This will conflict with PR #4495 but I'm ready.

Validation Steps Performed

Manual tests for UIA using accessibility insights and Windows Terminal's copy action (w/ and w/out shift)

Added tests as well.


🔄 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/4578 **Author:** [@carlos-zamora](https://github.com/carlos-zamora) **Created:** 2/14/2020 **Status:** ✅ Merged **Merged:** 3/9/2020 **Merged by:** [@carlos-zamora](https://github.com/carlos-zamora) **Base:** `master` ← **Head:** `dev/cazamor/acc/get-text` --- ### 📝 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 **13 files changed** (+353 additions, -166 deletions) <details> <summary>View changed files</summary> 📝 `src/buffer/out/textBuffer.cpp` (+60 -40) 📝 `src/buffer/out/textBuffer.hpp` (+5 -5) 📝 `src/cascadia/TerminalApp/TerminalPage.cpp` (+1 -1) 📝 `src/cascadia/TerminalControl/TermControl.cpp` (+5 -6) 📝 `src/cascadia/TerminalControl/TermControl.h` (+1 -1) 📝 `src/cascadia/TerminalControl/TermControl.idl` (+1 -1) 📝 `src/cascadia/TerminalCore/TerminalSelection.cpp` (+14 -13) 📝 `src/host/ut_host/ClipboardTests.cpp` (+2 -4) 📝 `src/host/ut_host/TextBufferTests.cpp` (+213 -2) 📝 `src/interactivity/win32/Clipboard.cpp` (+21 -30) 📝 `src/interactivity/win32/clipboard.hpp` (+1 -5) 📝 `src/types/UiaTextRangeBase.cpp` (+28 -57) 📝 `src/types/UiaTextRangeBase.hpp` (+1 -1) </details> ### 📄 Description ## Summary of the Pull Request `GetTextForClipboard` already exists in the TextBuffer. It makes sense to use that for UIA as well. This changes the behavior or `GetText()` such that it does not remove leading/trailing whitespace anymore. That is more of an expected behavior. ## 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 😀 ## PR Checklist * [X] CLA signed. * [X] Tests added/passed ## Detailed Description of the Pull Request / Additional comments - `TextBuffer::GetTextForClipboard()` --> `GetText()` - `TextBuffer::GetText()` no longer requires GetForegroundColor/GetBackgroundColor. If either of these are not defined, we return a `TextAndColor` with only the `text` field populated. - renamed a few parameters for copying text to the clipboard for clarity - Updated `UiaTextRange::GetText()` to use `TextBuffer::GetText()` - ⚠ NOTE: This will conflict with PR #4495 but I'm ready. ## Validation Steps Performed Manual tests for UIA using accessibility insights and Windows Terminal's copy action (w/ and w/out shift) Added tests as well. --- <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:12 +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#25845