-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Feature Idea: Find/Extract Text Attributes for Accessibility #2161
Comments
Could this be prioritized for 21H1? NVDA definitely can get colours from UIA. |
I'm averse to scoping additional things into 21H1 while the team is heads-down on Terminal v1. 😄 Sorry. |
With the additional three months, could this issue be reconsidered for 21H1 (just exposing colours, not necessarily #3567)? Thanks! |
The discussion on #7691 reminded me of this issue. I think it might be worth reconsidering as well to enable support for more text attributes besides links. It also seems that the console supports bold/italic/underlined text, could these also be mapped onto UIA formatting attributes? (colours would definitely be a good start though!) If I have spare cycles and want to look into this, where might I start? Where are colours/formatting attributes exposed? Is it just a matter of creating a mapping from conhost attributes to UIA ones? |
It seems like most of the work would be mapping the TextBuffer attributes to UIA ones. I took a quick look at #7251 since that adds a new text attribute and uses it. Here's some useful files too:
Most of the work of finding and exposing TextAttributes already seems to be done in TextBuffer. |
Some text attributes that we can expose:
*not sure if these are worth adding |
Are these customizable by the user or can they otherwise differ? If so, please add them. If the terminal always uses the same font and size, no need.
Probably not super necessary as the console always has keyboard focus?
Probably good for i18n.
Please add. |
## Summary of the Pull Request This implements `GetAttributeValue` and `FindAttribute` for `UiaTextRangeBase` (the shared `ITextRangeProvider` for Conhost and Windows Terminal). This also updates `UiaTracing` to collect more useful information on these function calls. ## References #7000 - Epic [Text Attribute Identifiers](https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-textattribute-ids) [ITextRangeProvider::GetAttributeValue](https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nf-uiautomationcore-itextrangeprovider-getattributevalue) [ITextRangeProvider::FindAttribute](https://docs.microsoft.com/en-us/windows/win32/api/uiautomationcore/nf-uiautomationcore-itextrangeprovider-findattribute) ## PR Checklist * [X] Closes #2161 * [X] Tests added/passed ## Detailed Description of the Pull Request / Additional comments - `TextBuffer`: - Exposes a new `TextBufferCellIterator` that takes in an end position. This simplifies the logic drastically as we can now use this iterator to navigate through the text buffer. The iterator can also expose the position in the buffer. - `UiaTextRangeBase`: - Shared logic & helper functions: - Most of the text attributes are stored as `TextAttribute`s in the text buffer. To extract them, we generate an attribute verification function via `_getAttrVerificationFn()`, then use that to verify if a given cell has the desired attribute. - A few attributes are special (i.e. font name, font size, and "is read only"), in that they are (1) acquired differently and (2) consistent across the entire text buffer. These are handled separate from the attribute verification function. - `GetAttributeValue`: Retrieve the attribute verification of the first cell in the range. Then, verify that the entire range has that attribute by iterating through the text range. If a cell does not have that attribute, return the "reserved mixed attribute value". - `FindAttribute`: Iterate through the text range and leverage the attribute verification function to find the first contiguous range with that attribute. Then, make the end exclusive and output a `UiaTextRangeBase`. This function must be able to perform a search backwards, so we abstract the "start" and "end" into `resultFirstAnchor` and `resultSecondAnchor`, then perform post processing to output a valid `UiaTextRangeBase`. - `UiaTracing`: - `GetAttributeValue`: Log uia text range, desired attribute, resulting attribute metadata, and the type of the result. - `FindAttribute`: Log uia text range, desired attribute and attribute metadata, if we were searching backwards, the type of the result, and the resulting text range. - `AttributeType` is a nice way to understand/record if the result was either of the reserved UIA values, a normal result, or an error. - `UiaTextRangeTests`: - `GetAttributeValue`: - verify that we know which attributes we support - test each of the known text attributes (expecting 100% code coverage for `_getAttrVerificationFn()`) - `FindAttribute`: - test each of the known _special_ text attributes - test `IsItalic`. NOTE: I'm explicitly only testing one of the standard text attributes because the logic is largely the same between all of them and they leverage `_getAttrVerificationFn()`. ## Validation Steps Performed - @codeofdusk has been testing this Conhost build - Tests added for Conhost and shared implementation - Windows Terminal changes were manually verified using accessibility insights and NVDA
🎉This issue was addressed in #10336, which has now been successfully released as Handy links: |
Description of the new feature/enhancement
ITextRangeProvider
s can have support for aFindAttribute()
function (link). They support a ton of different text attributes.We definitely can support background/foreground color. This might be a good opportunity to enhance our accessibility as a terminal. But we need to do some research as to how automation clients (i.e.: narrator) make use of this.
This would also expand as we support more text attributes in the future.
Proposed technical implementation details (optional)
This would go in the shared code for
UIATextRange
and would require some changes to propagate toXamlUiaTextRange
in Windows Terminal.The text was updated successfully, but these errors were encountered: