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 3ce0607 commit d8d5867
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,15 @@ def move(self, unit, direction, endPoint=None):
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 @@ -217,7 +213,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 @@ -233,13 +229,13 @@ def event_typedCharacter(self, ch):
):
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",
Expand All @@ -251,11 +247,13 @@ def event_textChange(self):
])
def script_flush_queuedChars(self, gesture):
"""
Flushes the queue of typedCharacter events if present.
This is necessary to avoid speaking of passwords in the console if disabled.
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 @@ -268,7 +266,7 @@ def _calculateNewText(self, newLines, oldLines):
self._findNonBlankIndices(newLines)
!= self._findNonBlankIndices(oldLines)
)
return super(winConsoleUIA, self)._calculateNewText(newLines, oldLines)
return super(WinConsoleUIA, self)._calculateNewText(newLines, oldLines)

def _findNonBlankIndices(self, lines):
return [index for index, line in enumerate(lines) if line]
Expand Down

0 comments on commit d8d5867

Please sign in to comment.