Skip to content

Commit

Permalink
Use UIATextInfo in FORMATTED consoles. (#12669)
Browse files Browse the repository at this point in the history
Summary of the issue:
Before recent upstream work, NVDA needed a custom TextInfo implementation including workarounds for the console. Notably, it was necessary to restrict the text range to visible content, as the console contained thousands of empty lines which both slowed down diffing and disorientated the user. This is no longer necessary as the console's UIA text range now ends at the last actual character (i.e. no more extraneous empty lines).

This bounding to the visible ranges can sometimes lead to choppy speech output, as full screen refreshes (such as in pagers or full-screen editors) cause text discontinuity, resulting in the diff algorithms losing context about which parts of the text are new. It breaks precedent from the rest of NVDA: in Word or web documents, for instance, the review cursor is not bounded to the visible text and the entire document can be freely explored. Despite the documentation of the scrolling commands in the user guide, the need to scroll consoles in particular, in strict contrast to the behaviour in other applications, has caused user confusion (microsoft/terminal#6453 and private correspondance with various users) and the commands don't work consistently in any case. In microsoft/terminal#6453 (comment) it was pointed out that consoles can have text that appears below the visible content, which is currently inaccessible to NVDA due to bounding.

Description of how this pull request fixes the issue:
Switches consoles where apiLevel is FORMATTED to use the default TextInfo implementation (i.e. no customization at the UIA text range level). Also use UIATextInfo in Windows Terminal as it never contained thousands of empty lines, making the overrides unnecessary there.
  • Loading branch information
codeofdusk committed Jul 22, 2021
1 parent 5407954 commit f6984e3
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


class ConsoleUIATextInfo(UIATextInfo):
"A TextInfo implementation for consoles with an IMPROVED, but not FORMATTED, API level."
def __init__(self, obj, position, _rangeObj=None):
collapseToEnd = None
# We want to limit textInfos to just the visible part of the console.
Expand Down Expand Up @@ -376,11 +377,12 @@ def _get_TextInfo(self):
ConsoleUIATextInfo bounds review to the visible text.
ConsoleUIATextInfoWorkaroundEndInclusive fixes expand/collapse and implements
word movement."""
return (
ConsoleUIATextInfo
if self.apiLevel >= WinConsoleAPILevel.IMPROVED
else ConsoleUIATextInfoWorkaroundEndInclusive
)
if self.apiLevel >= WinConsoleAPILevel.FORMATTED:
return UIATextInfo # No TextInfo workarounds needed
elif self.apiLevel >= WinConsoleAPILevel.IMPROVED:
return ConsoleUIATextInfo
else:
return ConsoleUIATextInfoWorkaroundEndInclusive

def _get_devInfo(self):
info = super().devInfo
Expand Down Expand Up @@ -408,5 +410,4 @@ def findExtraOverlayClasses(obj, clsList):


class WinTerminalUIA(EnhancedTermTypedCharSupport):
def _get_TextInfo(self):
return ConsoleUIATextInfo
pass

0 comments on commit f6984e3

Please sign in to comment.