mirror of
https://github.com/microsoft/terminal.git
synced 2026-07-09 02:26:45 +00:00
Add an efficient text stream write function (#14821)
This adds PR adds a couple foundational functions and classes to make our TextBuffer more performant and allow us to improve our Unicode correctness in the future, by getting rid of our dependence on `OutputCellIterator`. In the future we can then replace the simple UTF-16 code point iterator with a proper grapheme cluster iterator. While my focus is technically on Unicode correctness, the ~4x VT throughput increase in OpenConsole is pretty nice too. This PR adds: * A new, simpler ROW iterator (unused in this PR) * Cursor movement functions (`NavigateToPrevious`, `NavigateToNext`) They're based on functions that align the cursor to the start/end of the _current_ cell, so such functions can be added as well. * `ReplaceText` to write a raw string of text with the possibility to specify a right margin. * `CopyRangeFrom` will allow us to make reflow much faster, as it's able to bulk-copy already measured strings without re-measuring them. Related to #8000 ## Validation Steps Performed * enwik8.txt, zhwik8.txt, emoji-test.txt, all work with proper wide glyph reflow at the end of a row ✅ * This produces "a 咪" where only "a" has a white background: ```sh printf '\e7こん\e8\x1b[107ma\x1b[m\n' ``` * This produces "abん": ```sh stdbuf -o0 printf '\x1b7こん\x1b8a'; printf 'b\n' ``` * This produces "xy" at the end of the line: ```sh stdbuf -o0 printf '\e[999C\bこ\bx'; printf 'y\n' ``` * This produces red whitespace followed by "こ " in the default background color at the end of the line, and "ん" on the next line: ```sh printf '\e[41m\e[K\e[m\e[999C\e[2Dこん\n' ```
This commit is contained in:
@@ -190,7 +190,7 @@ class RunLengthEncodingTests
|
||||
|
||||
// We're testing replace() elsewhere, but this is special:
|
||||
// This ensures that even if we're default constructed we can add data.
|
||||
rle.replace(0, 0, { 1, 5 });
|
||||
rle.replace(0, 0, rle_type{ 1, 5 });
|
||||
VERIFY_ARE_EQUAL(5u, rle.size());
|
||||
VERIFY_IS_FALSE(rle.empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user