From 0e4818f28b37acc864dc314120c72d811046a36d Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Thu, 9 Jul 2026 17:33:21 +1000 Subject: [PATCH] Revert "LiveText: pumped generator follow-up (#20216)" This reverts commit 9fe7dde9ab1b173d3c03f001bb2704121ac8ad7f. --- source/NVDAObjects/behaviors.py | 57 ++++++++------------------------- source/config/configSpec.py | 3 -- source/gui/settingsDialogs.py | 21 ------------ user_docs/en/changes.md | 2 +- user_docs/en/userGuide.md | 10 ------ 5 files changed, 14 insertions(+), 79 deletions(-) diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index 2c90948b5f3..07f785c2a34 100755 --- a/source/NVDAObjects/behaviors.py +++ b/source/NVDAObjects/behaviors.py @@ -1,8 +1,8 @@ # A part of NonVisual Desktop Access (NVDA) # This file is covered by the GNU General Public License. # See the file COPYING for more details. -# Copyright (C) 2006-2026 NV Access Limited, Peter Vágner, Joseph Lee, Bill Dengler, -# Burman's Computer and Education Ltd, Cary-rowen, Cyrille Bougot, Ethin Probst +# Copyright (C) 2006-2025 NV Access Limited, Peter Vágner, Joseph Lee, Bill Dengler, +# Burman's Computer and Education Ltd, Cary-rowen, Cyrille Bougot """Mix-in classes which provide common behaviour for particular types of controls across different APIs. Behaviors described in this mix-in include providing table navigation commands for certain table rows, terminal input and output support, announcing notifications and suggestion items and so on. @@ -11,7 +11,6 @@ import os import time import threading -import math import tones import queueHandler import eventHandler @@ -384,6 +383,10 @@ class LiveText(NVDAObject): # If the text is live, this is definitely content. presentationType = NVDAObject.presType_content + MAX_LINES: int = 100 + """The maximum number of lines that will be reported when a large number of lines are queued. + Subclasses may override this to allow custom line reporting batches. + """ announceNewLineText = False def initOverlayClass(self): @@ -465,54 +468,20 @@ def _reportNewLines(self, lines: list[str]) -> None: Subclasses may override this method to provide custom filtering of new text, where logic depends on multiple lines. """ - maxNewLines: int = config.conf["terminals"]["maxNewLines"] - if maxNewLines: - droppedCount = len(lines) - maxNewLines - if droppedCount > 0: - if ( - config.conf["terminals"]["beepForSkippedLines"] - and speech.getState().speechMode == speech.SpeechMode.talk - ): - skippedLinesBeepHz = 550 - tones.beep( - skippedLinesBeepHz, - self._getSkippedLinesBeepLength(droppedCount), - ) - lines = lines[-maxNewLines:] + droppedCount = len(lines) - self.MAX_LINES + if droppedCount > 0: + lines = lines[-self.MAX_LINES :] if self._reportNewLinesGenID is not None: queueHandler.cancelGeneratorObject(self._reportNewLinesGenID) self._reportNewLinesGenID = None - newLinesBatchSize: int = config.conf["terminals"]["newLinesBatchSize"] - if newLinesBatchSize <= 0: # Report synchronously - for line in lines: - self._reportNewText(line) - else: - self._reportNewLinesGenID = queueHandler.registerGeneratorObject( - self._reportNewLinesGenerator( - lines, - newLinesBatchSize, - ), - ) + self._reportNewLinesGenID = queueHandler.registerGeneratorObject(self._reportNewLinesGenerator(lines)) - @staticmethod - def _getSkippedLinesBeepLength(droppedCount: int) -> int: - skippedLinesBeepMinLengthMs = 10 - skippedLinesBeepMaxLengthMs = 100 - droppedCount = max(droppedCount, 1) - maxNewLines: int = config.conf["terminals"]["maxNewLines"] - ratio = 1.0 if maxNewLines <= 1 else min(1.0, math.log(droppedCount, maxNewLines)) - lengthRange = skippedLinesBeepMaxLengthMs - skippedLinesBeepMinLengthMs - return round(skippedLinesBeepMinLengthMs + lengthRange * ratio) - - def _reportNewLinesGenerator( - self, - lines: list[str], - batchSize: int, - ) -> Generator[None, None, None]: + def _reportNewLinesGenerator(self, lines: list[str]) -> Generator[None, None, None]: + YIELD_EVERY = 5 # Sweet spot between yielding on every line and a batch try: for i, line in enumerate(lines, 1): self._reportNewText(line) - if i % batchSize == 0: + if i % YIELD_EVERY == 0: yield finally: self._reportNewLinesGenID = None diff --git a/source/config/configSpec.py b/source/config/configSpec.py index fb4a1650e98..1d1839f2c7a 100644 --- a/source/config/configSpec.py +++ b/source/config/configSpec.py @@ -312,9 +312,6 @@ [terminals] speakPasswords = boolean(default=false) keyboardSupportInLegacy = boolean(default=True) - maxNewLines = integer(min=0, default=100) - newLinesBatchSize = integer(min=0, default=5) - beepForSkippedLines = boolean(default=true) diffAlgo = option("auto", "dmp", "difflib", default="auto") wtStrategy = featureFlag(optionsEnum="WindowsTerminalStrategyFlag", behaviorOfDefault="diffing") diff --git a/source/gui/settingsDialogs.py b/source/gui/settingsDialogs.py index c5e65c7ffb7..f81b9771af7 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -4497,22 +4497,6 @@ def __init__(self, parent): ["terminals", "keyboardSupportInLegacy"], ) self.keyboardSupportInLegacyCheckBox.Enable(winVersion.getWinVer() >= winVersion.WIN10_1607) - # Translators: This is the label for a checkbox in the - # Advanced settings panel. - label = _("Beep for &skipped lines") - self.beepForSkippedLinesCheckBox = terminalsGroup.addItem( - wx.CheckBox(terminalsBox, label=label), - ) - self.bindHelpEvent( - "AdvancedSettingsBeepForSkippedLines", - self.beepForSkippedLinesCheckBox, - ) - self.beepForSkippedLinesCheckBox.SetValue( - config.conf["terminals"]["beepForSkippedLines"], - ) - self.beepForSkippedLinesCheckBox.defaultValue = self._getDefaultValue( - ["terminals", "beepForSkippedLines"], - ) # Translators: This is the label for a combo box for selecting a # method of detecting changed content in terminals in the advanced @@ -4809,7 +4793,6 @@ def haveConfigDefaultsBeenRestored(self): == self.keyboardSupportInLegacyCheckBox.defaultValue and self.winConsoleSpeakPasswordsCheckBox.IsChecked() == self.winConsoleSpeakPasswordsCheckBox.defaultValue - and self.beepForSkippedLinesCheckBox.IsChecked() == self.beepForSkippedLinesCheckBox.defaultValue and self.diffAlgoCombo.GetSelection() == self.diffAlgoCombo.defaultValue and self.wtStrategyCombo.isValueConfigSpecDefault() and self.cancelExpiredFocusSpeechCombo.GetSelection() @@ -4842,9 +4825,6 @@ def restoreToDefaults(self): self.brailleLiveRegionsCombo.resetToConfigSpecDefault() self.winConsoleSpeakPasswordsCheckBox.SetValue(self.winConsoleSpeakPasswordsCheckBox.defaultValue) self.keyboardSupportInLegacyCheckBox.SetValue(self.keyboardSupportInLegacyCheckBox.defaultValue) - self.beepForSkippedLinesCheckBox.SetValue( - self.beepForSkippedLinesCheckBox.defaultValue, - ) self.diffAlgoCombo.SetSelection(self.diffAlgoCombo.defaultValue) self.wtStrategyCombo.resetToConfigSpecDefault() self.cancelExpiredFocusSpeechCombo.SetSelection(self.cancelExpiredFocusSpeechCombo.defaultValue) @@ -4887,7 +4867,6 @@ def onSave(self): self.enhancedEventProcessingComboBox.saveCurrentValueToConf() config.conf["terminals"]["speakPasswords"] = self.winConsoleSpeakPasswordsCheckBox.IsChecked() config.conf["terminals"]["keyboardSupportInLegacy"] = self.keyboardSupportInLegacyCheckBox.IsChecked() - config.conf["terminals"]["beepForSkippedLines"] = self.beepForSkippedLinesCheckBox.IsChecked() diffAlgoChoice = self.diffAlgoCombo.GetSelection() config.conf["terminals"]["diffAlgo"] = self.diffAlgoVals[diffAlgoChoice] self.wtStrategyCombo.saveCurrentValueToConf() diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index 666d78d4cbb..6befac7d53e 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -36,7 +36,7 @@ * In PowerPoint and other Office applications, NVDA will now correctly read and navigate the edit fields in the insert hyperlink dialog. (#17390, @aryanchoudharypro) * The actions button can now be used when selecting multiple add-ons in the Add-on Store to perform batch actions, instead of just via the context menu in the add-ons list. (#19971, @amirmahdifard) * When moving to an ARIA grid cell in focus mode in web browsers, NVDA no longer reports both the row and column headers even if only the row or only the column changed. (#17750, @jcsteh) -* In live text regions, such as terminals, NVDA no longer freezes when substantial amounts of text are dumped to the screen. (#20177, #20216, @ethindp, @codeofdusk) +* In live text regions, such as terminals, NVDA no longer freezes when substantial amounts of text are dumped to the screen. (#20177) * When an application stops responding, NVDA no longer freezes or floods its log with errors; it stays responsive and drops UIA and MSAA events from the unresponsive application until it recovers. (#16749, @heath-toby) * Reduced lag on UI Automation text change events, improving the responsiveness of controls such as combo boxes and of File Explorer, by using the cached element class name instead of a live cross-process fetch. (#16749, @heath-toby) * In Notepad++, NVDA now continues to report IME composition text in speech and braille while selecting or navigating within Chinese IME composition. (#14140, #14152, @keyang556) diff --git a/user_docs/en/userGuide.md b/user_docs/en/userGuide.md index 15adf086bc1..e87757b3da8 100644 --- a/user_docs/en/userGuide.md +++ b/user_docs/en/userGuide.md @@ -4171,16 +4171,6 @@ This feature is available and enabled by default on Windows 10 versions 1607 and Warning: with this option enabled, typed characters that do not appear onscreen, such as passwords, will not be suppressed. In untrusted environments, you may temporarily disable [speak typed characters](#KeyboardSettingsSpeakTypedCharacters) and [speak typed words](#KeyboardSettingsSpeakTypedWords) when entering passwords. -##### Beep for skipped lines {#AdvancedSettingsBeepForSkippedLines} - -This setting controls whether NVDA plays a short beep when too many new lines arrive before they can all be reported. -The beep indicates that some lines were skipped, and becomes slightly longer as more lines are skipped. - -| . {.hideHeaderRow} |.| -|---|---| -| Options | Disabled, Enabled | -| Default | Enabled | - ##### Diff algorithm {#DiffAlgo} This setting controls how NVDA determines the new text to speak in terminals.