mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-19 18:11:39 -05:00
Rewrite HighlightedTextControl and remove HighlightedText (#19130)
`HighlightedTextControl` is a XAML user control that contains a text block and takes vector of `HighlightedText`. `HighlightedText` uses tuples `(string, boolean)`. Allocating an entire object to store a string and an integer felt like a waste, especially when we were doing it thousands of times for the command palette _and just to pass them into another object that stores a string and a few more integers (`Run`)._ The new `HighlightedTextControl` is a standard templated control, and supports styling of both the inner text block and of the highlighted runs. It no longer takes a `HighlightedText`, but rather a standard string and a set of runs (tuple `(int start, int end)`); these can be stored more efficiently, and this change moves the construction of text and runs directly into `HighlightedTextControl` itself as an implementation detail rather than an API contract. ### XAML Properties - `Text`: the string to highlight - `HighlightedRuns`: a vector of `(start, end)` pairs, indicating which regions are intended to be highlighted. Can be empty (which indicates there is no highlight and that the entire string is styled normally.) - `TextBlockStyle`: the `Style` applied to the inner text block; optional; allows consumers to change how both normal and highlighted text looks. - `HighlightedRunStyle`: a `Style` applied only to the highlighted runs; optional; allows consumers to change how highlighted text looks. If left NULL, highlighted runs will be bold. `HighlightedRunStyle` is a little bodgy. It only applies to `Run` objects (which is fine, and XAML somewhat supports), but since `Run` is not a `FrameworkElement`, it _doesn't actually have a `Style` member._ We need to crack open the style and apply it manually, entry by entry. `FontWeight` is special because XAML is a special little flower.
This commit is contained in:
1
.github/actions/spelling/expect/expect.txt
vendored
1
.github/actions/spelling/expect/expect.txt
vendored
@@ -2,6 +2,7 @@ aaaaabbb
|
||||
aabbcc
|
||||
ABANDONFONT
|
||||
abbcc
|
||||
abcc
|
||||
abgr
|
||||
ABORTIFHUNG
|
||||
ACCESSTOKEN
|
||||
|
||||
Reference in New Issue
Block a user