Skip to content

Commit

Permalink
Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofdusk committed Jun 17, 2019
1 parent d8d5867 commit eca4a44
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@


class consoleUIATextInfo(UIATextInfo):
#: At least on Windows 10 1903, expanding then collapsing the text info
#: causes review to get stuck, so disable it.
_expandCollapseBeforeReview = False

def __init__(self, obj, position, _rangeObj=None):
Expand Down Expand Up @@ -138,6 +140,12 @@ def expand(self, unit):
return super(consoleUIATextInfo, self).expand(unit)

def _getCurrentOffsetInThisLine(self, lineInfo):
"""
Given a caret textInfo expanded to line, returns the index into the
line where the caret is located.
This is necessary since Uniscribe requires indices into the text to
find word boundaries, but UIA only allows for relative movement.
"""
charInfo = self.copy()
res = 0
chars = None
Expand Down Expand Up @@ -183,10 +191,10 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo):
class consoleUIAWindow(Window):
def _get_focusRedirect(self):
"""
Sometimes, attempting to interact with the console too quickly after
focusing the window can make NVDA unable to get any caret or review
information or receive new text events.
To work around this, we must redirect focus to the console text area.
Sometimes, attempting to interact with the console too quickly after
focusing the window can make NVDA unable to get any caret or review
information or receive new text events.
To work around this, we must redirect focus to the console text area.
"""
for child in self.children:
if isinstance(child, WinConsoleUIA):
Expand All @@ -201,7 +209,11 @@ class WinConsoleUIA(Terminal):
#: a lot of text.
STABILIZE_DELAY = 0.03
_TextInfo = consoleUIATextInfo
#: A queue of typed characters, to be dispatched on C{textChange}.
#: This queue allows NVDA to suppress typed passwords when needed.
_queuedChars = []
#: Whether the console got new text lines in its last update.
#: Used to determine if typed character/word buffers should be flushed.
_hasNewLines = False

def _reportNewText(self, line):
Expand Down Expand Up @@ -269,6 +281,10 @@ def _calculateNewText(self, newLines, oldLines):
return super(WinConsoleUIA, self)._calculateNewText(newLines, oldLines)

def _findNonBlankIndices(self, lines):
"""
Given a list of strings, returns a list of indices where the strings
are not empty.
"""
return [index for index, line in enumerate(lines) if line]

def findExtraOverlayClasses(obj, clsList):
Expand Down

0 comments on commit eca4a44

Please sign in to comment.