Skip to content

Commit

Permalink
Further renaming of winConsoleUIA -> WinConsoleUIA, and once again ex…
Browse files Browse the repository at this point in the history
…plicitly clear the word buffer when flushing queued chars.
  • Loading branch information
codeofdusk committed Jun 17, 2019
1 parent 039424b commit de686c5
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,15 @@ def move(self, unit, direction, endPoint=None):
wordStartDistance,
endPoint=endPoint)
else: # moving by a unit other than word
res = super(consoleUIATextInfo, self).move(unit, direction, endPoint)
res = super(consoleUIATextInfo, self).move(unit, direction,
endPoint)
if oldRange and (
self._rangeObj.CompareEndPoints(
UIAHandler.TextPatternRangeEndpoint_Start,
firstVisiRange,
UIAHandler.TextPatternRangeEndpoint_Start
) < 0
UIAHandler.TextPatternRangeEndpoint_Start, firstVisiRange,
UIAHandler.TextPatternRangeEndpoint_Start) < 0
or self._rangeObj.CompareEndPoints(
UIAHandler.TextPatternRangeEndpoint_Start,
lastVisiRange,
UIAHandler.TextPatternRangeEndpoint_End
) >= 0
):
UIAHandler.TextPatternRangeEndpoint_Start, lastVisiRange,
UIAHandler.TextPatternRangeEndpoint_End) >= 0):
self._rangeObj = oldRange
return 0
return res
Expand Down Expand Up @@ -218,7 +214,7 @@ def _reportNewText(self, line):
# This will need to be changed once #8110 is merged.
speech.curWordChars = []
self._queuedChars = []
super(winConsoleUIA, self)._reportNewText(line)
super(WinConsoleUIA, self)._reportNewText(line)

def event_typedCharacter(self, ch):
if ch == '\t':
Expand All @@ -230,26 +226,27 @@ def event_typedCharacter(self, ch):
and not config.conf['UIA']['winConsoleSpeakPasswords']):
self._queuedChars.append(ch)
else:
super(winConsoleUIA, self).event_typedCharacter(ch)
super(WinConsoleUIA, self).event_typedCharacter(ch)

def event_textChange(self):
while self._queuedChars:
ch = self._queuedChars.pop(0)
super(winConsoleUIA, self).event_typedCharacter(ch)
super(winConsoleUIA, self).event_textChange()
super(WinConsoleUIA, self).event_typedCharacter(ch)
super(WinConsoleUIA, self).event_textChange()

@script(gestures=[
"kb:enter", "kb:numpadEnter", "kb:tab", "kb:control+c", "kb:control+d",
"kb:control+pause"
])
def script_flush_queuedChars(self, gesture):
"""
Flushes the queue of typedCharacter events if present.
Flushes the typed word buffer and queue of typedCharacter events if present.
Since these gestures clear the current word/line, we should flush the
queue to avoid erroneously reporting these chars.
"""
gesture.send()
self._queuedChars = []
speech.curWordChars = []

def _getTextLines(self):
# Filter out extraneous empty lines from UIA
Expand All @@ -260,7 +257,7 @@ def _getTextLines(self):
def _calculateNewText(self, newLines, oldLines):
self._hasNewLines = (self._findNonBlankIndices(newLines) !=
self._findNonBlankIndices(oldLines))
return super(winConsoleUIA, self)._calculateNewText(newLines, oldLines)
return super(WinConsoleUIA, self)._calculateNewText(newLines, oldLines)

def _findNonBlankIndices(self, lines):
"""
Expand Down

0 comments on commit de686c5

Please sign in to comment.