-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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 text based cursor movement helpers #15779
Add text based cursor movement helpers #15779
Conversation
@@ -441,11 +441,16 @@ void TextBuffer::_PrepareForDoubleByteSequence(const DbcsAttribute dbcsAttribute | |||
} | |||
} | |||
|
|||
void TextBuffer::ConsumeGrapheme(std::wstring_view& chars) noexcept | |||
size_t TextBuffer::GraphemeNext(const std::wstring_view& chars, size_t position) 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.
Now, what is position
. A column or a string index?
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.
Ah, good point. I forgot to add function documentation. 🙂
(It's a string index, since it's for text-based navigation.)
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 am weirded out that they're in TextBuffer but I think i understand why
Once the implementation for these gets beyond simple surrogate pairs, it'll probably be more obvious. 😅 After all, both |
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.
Approving. Please be sure to add the function comment though.
COOKED_READ_DATA
is a little special and requires cursor navigationbased on the raw (buffered) text contents instead of what's in the
text buffer. This requires the introduction of new helper functions
to implement such cursor navigation. They're made part of
TextBuffer
as these helpers will get support graphemes in the future.
It also helps keeping it close to
TextBuffer
as the cursornavigation should optimally behave identical between the two.
Part of #8000.