terminal/src/host
Carlos Zamora a0e5085b49
Expose Text Attributes to UI Automation (#10336)
## 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
2021-07-09 23:21:35 +00:00
..
exe Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ft_fuzzer Add a Fuzzing configuration and a version of conhost that can be fuzzed (#9604) 2021-03-29 14:23:30 +00:00
ft_host Merged PR 6140256: Migrate OSS up to 94d39b758 2021-06-09 23:03:04 +00:00
ft_integrity Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
ft_uia Change TAEF nuget package to use new Microsoft.Taef name; Update to 10.58 release build version. (#9656) 2021-03-30 10:58:11 +00:00
lib Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
proxy Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
ut_host Prefer FMT_COMPILE for string formatting in VtRenderer (#10426) 2021-06-22 15:39:16 +00:00
ut_lib Unify and clean up the common build properties (#3429) 2019-11-05 14:29:11 -08:00
_output.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_output.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
_stream.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
_stream.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
alias.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
alias.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ApiRoutines.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
cmdline.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
cmdline.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandListPopup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
CommandListPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CommandNumberPopup.cpp WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
CommandNumberPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
conapi.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conareainfo.cpp Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conareainfo.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
conattrs.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
conddkrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
conhost.rcv Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conhostv2_traceviewpp.tvpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
conimeinfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
conimeinfo.h Replace basic_string_view<T> with span<const T> (#6921) 2020-07-15 16:40:42 +00:00
conserv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
ConsoleArguments.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
ConsoleArguments.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
consoleInformation.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
conv.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
convarea.cpp Make sure we don't hide the cursor until the IME starts (#7673) 2020-09-18 19:25:39 +00:00
conwinuserrefs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyFromCharPopup.hpp Add explicit identifier to some constructors (#5652) 2020-04-29 16:50:47 -07:00
CopyToCharPopup.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CopyToCharPopup.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
CursorBlinker.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
CursorBlinker.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
dbcs.cpp Replace gsl::at with a new til::at(span) for pre-checked bounds (#6925) 2020-07-15 10:29:36 -07:00
dbcs.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
directio.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
directio.h Switch all DSR responses to appending instead of prepending (#7583) 2020-09-09 23:55:22 +00:00
dirs Merged PR 5677497: [Git2Git] Merged PR 5655213: Allow conhost to handoff to registered default app handler 2021-02-11 21:07:50 +00:00
getset.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
getset.h OSC 8 support for conhost and terminal (#7251) 2020-09-03 13:52:39 -04:00
globals.cpp Implement a pair of shims for cls, Clear-Host in conpty mode (#5627) 2020-04-30 21:53:31 +00:00
globals.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
handle.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
handle.h Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
history.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
history.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
host-common.vcxitems Implement Default Terminal (#7489) 2021-03-26 17:09:49 -05:00
IIoProvider.hpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
init.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
init.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
input.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
input.h Replace macros with constexpr part 2 (#3416) 2019-11-04 07:37:47 -06:00
inputBuffer.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputBuffer.hpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
inputKeyInfo.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
inputReadHandleData.cpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
inputReadHandleData.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
misc.cpp #10497: Do not force the font on output codepage change (#10591) 2021-07-08 21:10:35 +00:00
misc.h WriteCharsLegacy: Add some notes in comments and rename WC_ECHO (#9605) 2021-03-24 16:26:50 -05:00
ntprivapi.cpp Change NULL to nullptr since they are pointers (#4960) 2020-03-20 20:35:12 +00:00
ntprivapi.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
output.cpp Add support for double-width/double-height lines in conhost (#8664) 2021-02-18 05:44:50 +00:00
output.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
outputStream.cpp Fix the cursor blink VT sequence being ignored (#10589) 2021-07-09 18:45:16 +00:00
outputStream.hpp Revert "Prevent the virtual viewport bottom being moved up unintentionally (#9770)" 2021-04-28 12:45:09 -05:00
popup.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
popup.h Improve the legacy color conversions (#6358) 2020-06-08 19:05:06 +00:00
precomp.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
precomp.h Reduce Transient Allocations during Bulk Text Output (#8617) 2021-01-05 18:06:06 +00:00
PtySignalInputThread.cpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
PtySignalInputThread.hpp Fix startup race of resizing ConPTY (#10449) 2021-06-22 19:23:16 +00:00
readData.cpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
readData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataCooked.cpp Merged PR 6142815: OS build fixes on top of 94d39b758 2021-06-10 15:52:14 +00:00
readDataCooked.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataDirect.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
readDataRaw.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
registry.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
registry.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
renderData.cpp Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
renderData.hpp Expose Text Attributes to UI Automation (#10336) 2021-07-09 23:21:35 +00:00
renderFontDefaults.cpp Allow FontInfo{,Base,Desired} to store a font name > 32 wch (#3107) 2019-10-14 21:23:45 -07:00
renderFontDefaults.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
res.rc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
resource.h add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
runft.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runtests.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
runut.bat Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
ScreenBufferRenderTarget.cpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
ScreenBufferRenderTarget.hpp Fix TerminalControl crash on exit (#10031) 2021-05-04 21:17:37 +00:00
screenInfo.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
screenInfo.hpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
scrolling.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
scrolling.hpp Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
selection.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
selection.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
selectionInput.cpp Fix color selection operations in conhost (#8577) 2020-12-14 19:45:49 +00:00
selectionState.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
server.h Eliminate more transient allocations: Titles and invalid rectangles and bitmap runs and utf8 conversions (#8621) 2021-02-16 20:52:33 +00:00
settings.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
settings.hpp Add support for the "blink" graphic rendition attribute (#7490) 2020-09-21 23:21:33 +00:00
sources.inc Merged PR 5445070: [Git2Git] Update the Windows build for some shell changes 2020-12-16 01:32:35 +00:00
sources.test.inc Initial release of the Windows Terminal source code 2019-05-02 15:29:04 -07:00
srvinit.cpp Skip accessibility notifier and all event calculations when we're in PTY mode (#10569) 2021-07-09 18:45:44 +00:00
srvinit.h Persist inbox conhost; delegate control activities to it via a pipe (#10415) 2021-06-16 19:23:37 +00:00
stream.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
stream.h Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
telemetry.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
tracing.cpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
tracing.hpp Reflect recent OS build changes, incl. a version of GH-10166 2021-06-09 22:57:38 +00:00
utf8ToWideCharParser.cpp Fix a bunch of spelling errors across the project (#4295) 2020-02-10 20:40:01 +00:00
utf8ToWideCharParser.hpp add clang-format conf to the project, format the c++ code (#1141) 2019-06-11 13:27:09 -07:00
utils.cpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
utils.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtInputThread.cpp Add names to threads to make debugging a slight bit easier (#9801) 2021-04-14 10:56:52 +00:00
VtInputThread.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
VtIo.cpp [Conpty] Pass through request for mouse mode to the Terminal (#9970) 2021-05-07 02:46:11 +00:00
VtIo.hpp Change backslashes in include statements to forward slashes (#8205) 2020-11-25 21:02:10 +00:00
writeData.cpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00
writeData.hpp Merged PR 6034984: Fix a crash caused by improper buffer management w/ multiple clients 2021-05-11 16:56:43 +00:00