New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an efficient text stream write function #14821
base: main
Are you sure you want to change the base?
Conversation
db90593
to
1a24ff3
Compare
This comment has been minimized.
This comment has been minimized.
1a24ff3
to
a6c5e7a
Compare
This comment has been minimized.
This comment has been minimized.
| uint16_t column = 0; | ||
| for (const auto& ch : std::wstring_view{ L"AB\u304bC\u304dDE " }) | ||
| { | ||
| const uint16_t width = ch >= 0x80 ? 2 : 1; | ||
| pRow->ReplaceCharacters(column, width, { &ch, 1 }); | ||
| column += width; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot why I made this change... But it's much shorter now, so there's that at least.
| @@ -65,6 +68,65 @@ constexpr OutIt copy_n_small(InIt first, Diff count, OutIt dest) | |||
| return dest; | |||
| } | |||
|
|
|||
| RowTextIterator::RowTextIterator(std::span<const wchar_t> chars, std::span<const uint16_t> charOffsets, uint16_t offset) noexcept : | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RowTextIterator isn't used anywhere yet, but I did use it during development as a debug aid. I expect this struct to be used in the future for things like CHAR_INFO reads.

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 simpleUTF-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:
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.
Writeto write a raw string of text with the possibility tospecify a right margin.
WriteWithOffsetswill allow us to make reflow much faster,as it's able to bulk-copy already measured strings extremely fast
without re-measuring them.
Related to #8000
Validation Steps Performed
wide glyph reflow at the end of a row