From 94146055973068f01fb6542f67ed8c390bbc992b Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Wed, 5 Jun 2019 01:28:30 -0400 Subject: [PATCH 1/3] 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. --- source/NVDAObjects/UIA/winConsoleUIA.py | 42 ++++++++++++++++--------- source/NVDAObjects/behaviors.py | 2 +- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/source/NVDAObjects/UIA/winConsoleUIA.py b/source/NVDAObjects/UIA/winConsoleUIA.py index b972dcb6602..30a9912405f 100644 --- a/source/NVDAObjects/UIA/winConsoleUIA.py +++ b/source/NVDAObjects/UIA/winConsoleUIA.py @@ -186,28 +186,25 @@ def _getWordOffsetsInThisLine(self, offset, lineInfo): 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()) < 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'] @@ -233,9 +230,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): @@ -243,3 +243,17 @@ def _getTextLines(self): ptr = self.UIATextPattern.GetVisibleRanges() res = [ptr.GetElement(i).GetText(-1) for i in range(ptr.length)] return res + + def _calculateNewText(self, newLines, oldLines): + self._hasNewLines = ( + self._findLastLineIndex(newLines) + != self._findLastLineIndex(oldLines) + ) + return super(winConsoleUIA, self)._calculateNewText(newLines, oldLines) + + def _findLastLineIndex(self, lines): + res = 0 + for index, line in enumerate(lines): + if line: + res = index + return res diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index 278591f8840..ddfc57eab26 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -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. From fa8b8119261d6bb8470fa31792541d75dd518d90 Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Tue, 11 Jun 2019 00:39:32 -0400 Subject: [PATCH 2/3] Meeting actions. --- source/NVDAObjects/UIA/winConsoleUIA.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/source/NVDAObjects/UIA/winConsoleUIA.py b/source/NVDAObjects/UIA/winConsoleUIA.py index e3734cc1476..7843b90a8b3 100644 --- a/source/NVDAObjects/UIA/winConsoleUIA.py +++ b/source/NVDAObjects/UIA/winConsoleUIA.py @@ -206,7 +206,7 @@ class winConsoleUIA(Terminal): def _reportNewText(self, line): # Additional typed character filtering beyond that in LiveText - if len(line.strip()) < 3: + if len(line.strip()) < max(len(speech.curWordChars) + 1, 3): return if self._hasNewLines: # Clear the typed word buffer for new text lines. @@ -261,18 +261,13 @@ def _getTextLines(self): def _calculateNewText(self, newLines, oldLines): self._hasNewLines = ( - self._findLastLineIndex(newLines) - != self._findLastLineIndex(oldLines) + self._findNonBlankIndices(newLines) + != self._findNonBlankIndices(oldLines) ) return super(winConsoleUIA, self)._calculateNewText(newLines, oldLines) - def _findLastLineIndex(self, lines): - res = 0 - for index, line in enumerate(lines): - if line: - res = index - return res - + def _findNonBlankIndices(self, lines): + return [index for index, line in enumerate(lines) if line] def findExtraOverlayClasses(obj, clsList): if obj.UIAElement.cachedAutomationId == "Text Area": From 040311e43d2469cd118b9eb66203af5799b6c4ce Mon Sep 17 00:00:00 2001 From: Bill Dengler Date: Sun, 16 Jun 2019 23:53:15 -0400 Subject: [PATCH 3/3] Fix Liblouis submodule maybe? --- include/liblouis | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/liblouis b/include/liblouis index 1362d1b54b0..cc834a39b28 160000 --- a/include/liblouis +++ b/include/liblouis @@ -1 +1 @@ -Subproject commit 1362d1b54b01f6637c25442226641a7c4c708d73 +Subproject commit cc834a39b28b22242d8546417afa1fda5a39440b