-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Enable Word Navigation in UiaTextRange #3659
Conversation
Follow proper Constructor + RuntimeClassInitialize contract Add InhibitFtmBase (prevent agility) Clean up some issues with ownership that arose
Prevent building autoPeer if we know that it'll fail
Thanks Michael
Wasn't there a built in word delimiter list that was going to be used? |
- Add UIA Word Expansion to UTR
a1e5394
to
4b72ca4
Compare
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.
so I think these are nits but maybe they're not so
Tests got added in so we're good. Now we have...
|
Update your original PR comment at the top when you add things, please. |
* UIA Word Navigation: allow importing custom delimiters * Created constexpr for default word delimiters * switched to wstring_view
- add documentation - minor cleanup
* make member wstring (not view) * add comment * pascal case for DefaultWordDelimiters
I've closed and reopened the pull request to kick the CLA bot into gear. |
🎉 Handy links: |
Summary of the Pull Request
Enables support for word navigation when using an automation client (i.e.: Narrator, etc...). Specifically, adds this functionality to the UiaTextRange class. The only delimiter used is whitespace because that's how words are separated in English.
PR Checklist
Detailed Description of the Pull Request / Additional comments
General "Word Movement" Expectations
the resulting text range should include any word break characters that are present at the end of the word, but before the start of the next word. (Source)
Reusing our old code
Word Expansion
Since word selection is supposed to detect word delimiters already, I figured I'd reuse that code. I moved it from TerminalCore to the TextBuffer.
Then I built on top of it by adding an optional additional parameter that decides if you want to include...
It defaults to false so that we don't have to care when using it in selection. But we change it to true when using it in our UiaTextRange
UiaTextRange
The code is based on character movement. This allows us to actually work with boundary conditions.
The main thing to remember here is that each text range is recorded as a MoveState. The text range is most easily defined when you think about the
start
Endpoint and theend
Endpoint. AnEndpoint
is just a linear 1-dimensional indexing of the text buffer. Examples:Endpoint 0 --> (0,0)
Endpoint 79 --> (79,0) (when the buffer width is 80)
Endpoint 80 -->(0,1) (when the buffer width is 80)
When moving forward, the strategy is to focus on moving the
end
Endpoint. That way, we properly get the indexing for the "next" word (this also fixes a wrapping issue). Then, we update thestart
Endpoint. (This is reversed for moving backwards).When moving a specific Endpoint, we just have a few extra if statements to properly adjust for moving
start
vsend
.Hooking it up
All we really had to do is add an enum. This part was super easy :)
I originally wanted the delimiters to be able to be defined. I'm not so sure about that anymore. Either way, I hardcoded our delimiter into a variable so if we ever want to expand on it or make that customizable, we just modify that variable.
Validation Steps Performed
I'll be adding more tests for the kind of things that I was doing. If you really want to test it, I recommend you use Accessibility Insights. Click on the Terminal Control. On the bottom right, click on "Text Pattern Explore...". Then just mess around with any options that say "word" on it.
Concerns/Discussion Points
MoveByCharacter()
. I think it might be better to do all the refactoring in one big sweep, but I'm open to discussion on this.