Skip to content

Commit

Permalink
UI Automation in Windows Console: remove the isTyping logic from UIA …
Browse files Browse the repository at this point in the history
…consoles (#9673)

* Remove the isTyping logic from UIA consoles.

This makes autoread work with more console programs at the cost of a few typed characters possibly being echoed/doubled.

* Meeting actions.

* Fix Liblouis submodule maybe?
  • Loading branch information
codeofdusk authored and michaelDCurran committed Jun 17, 2019
1 parent 7b2861f commit 535c938
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
38 changes: 24 additions & 14 deletions source/NVDAObjects/UIA/winConsoleUIA.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,28 +201,25 @@ def _get_focusRedirect(self):
class winConsoleUIA(Terminal):
STABILIZE_DELAY = 0.03
_TextInfo = consoleUIATextInfo
_isTyping = False
_lastCharTime = 0
_queuedChars = []
_TYPING_TIMEOUT = 1
_hasNewLines = False

def _reportNewText(self, line):
# Additional typed character filtering beyond that in LiveText
if (
self._isTyping
and time.time() - self._lastCharTime <= self._TYPING_TIMEOUT
):
if len(line.strip()) < max(len(speech.curWordChars) + 1, 3):
return
if self._hasNewLines:
# Clear the typed word buffer for new text lines.
# This will need to be changed once #8110 is merged.
speech.curWordChars = []
self._queuedChars = []
super(winConsoleUIA, self)._reportNewText(line)

def event_typedCharacter(self, ch):
if not ch.isspace():
self._isTyping = True
if ch in ('\n', '\r', '\t'):
# Clear the typed word buffer for tab and return.
if ch == '\t':
# Clear the typed word buffer for tab completion.
# This will need to be changed once #8110 is merged.
speech.curWordChars = []
self._lastCharTime = time.time()
if (
(
config.conf['keyboard']['speakTypedCharacters']
Expand All @@ -248,9 +245,12 @@ def event_textChange(self):
"kb:control+d",
"kb:control+pause"
])
def script_clear_isTyping(self, gesture):
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.
"""
gesture.send()
self._isTyping = False
self._queuedChars = []

def _getTextLines(self):
Expand All @@ -259,6 +259,16 @@ def _getTextLines(self):
res = [ptr.GetElement(i).GetText(-1) for i in range(ptr.length)]
return res

def _calculateNewText(self, newLines, oldLines):
self._hasNewLines = (
self._findNonBlankIndices(newLines)
!= self._findNonBlankIndices(oldLines)
)
return super(winConsoleUIA, self)._calculateNewText(newLines, oldLines)

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

def findExtraOverlayClasses(obj, clsList):
if obj.UIAElement.cachedAutomationId == "Text Area":
clsList.append(winConsoleUIA)
Expand Down
2 changes: 1 addition & 1 deletion source/NVDAObjects/behaviors.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def _monitor(self):
newLines = self._getTextLines()
if config.conf["presentation"]["reportDynamicContentChanges"]:
outLines = self._calculateNewText(newLines, oldLines)
if len(outLines) == 1 and len(outLines[0]) == 1:
if len(outLines) == 1 and len(outLines[0].strip()) == 1:
# This is only a single character,
# which probably means it is just a typed character,
# so ignore it.
Expand Down

0 comments on commit 535c938

Please sign in to comment.