diff --git a/source/NVDAObjects/behaviors.py b/source/NVDAObjects/behaviors.py index 45e0cfe1aa6..dba68d00403 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-2025 NV Access Limited, Peter Vágner, Joseph Lee, Bill Dengler, -# Burman's Computer and Education Ltd, Cary-rowen, Cyrille Bougot +# 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 """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,6 +11,7 @@ import os import time import threading +import math import tones import queueHandler import eventHandler @@ -469,14 +470,32 @@ 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. """ - droppedCount = len(lines) - self.MAX_LINES - if droppedCount > 0: - lines = lines[-self.MAX_LINES :] + if self.MAX_LINES > 0: + droppedCount = len(lines) - self.MAX_LINES + if droppedCount > 0: + if ( + config.conf["terminals"]["beepForSkippedLines"] + and speech.getState().speechMode == speech.SpeechMode.talk + ): + SKIPPED_LINES_BEEP_HZ = 550 + tones.beep( + SKIPPED_LINES_BEEP_HZ, + self._getSkippedLinesBeepLength(droppedCount), + ) + lines = lines[-self.MAX_LINES :] if self._reportNewLinesGenID is not None: queueHandler.cancelGeneratorObject(self._reportNewLinesGenID) self._reportNewLinesGenID = None self._reportNewLinesGenID = queueHandler.registerGeneratorObject(self._reportNewLinesGenerator(lines)) + def _getSkippedLinesBeepLength(self, droppedCount: int) -> int: + SKIPPED_LINES_BEEP_MIN_DURATION_MS = 10 + SKIPPED_LINES_BEEP_MAX_DURATION_MS = 100 + droppedCount = max(droppedCount, 1) + ratio = 1.0 if self.MAX_LINES <= 1 else min(1.0, math.log(droppedCount, self.MAX_LINES)) + lengthRange = SKIPPED_LINES_BEEP_MAX_DURATION_MS - SKIPPED_LINES_BEEP_MIN_DURATION_MS + return round(SKIPPED_LINES_BEEP_MIN_DURATION_MS + lengthRange * ratio) + def _reportNewLinesGenerator(self, lines: list[str]) -> Generator[None, None, None]: YIELD_EVERY = 5 # Sweet spot between yielding on every line and a batch try: diff --git a/source/config/configSpec.py b/source/config/configSpec.py index 4f4143521b8..b87ae2d578a 100644 --- a/source/config/configSpec.py +++ b/source/config/configSpec.py @@ -314,6 +314,7 @@ [terminals] speakPasswords = boolean(default=false) keyboardSupportInLegacy = boolean(default=True) + 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 75ec49d59f1..5a88d99d176 100644 --- a/source/gui/settingsDialogs.py +++ b/source/gui/settingsDialogs.py @@ -4533,6 +4533,22 @@ 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( + "BeepForSkippedLines", + 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 @@ -4829,6 +4845,7 @@ 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() @@ -4861,6 +4878,9 @@ 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) @@ -4903,6 +4923,7 @@ 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 016f21a52ee..b2b784fcfeb 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -52,7 +52,9 @@ * 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) +* In live text regions, such as terminals, NVDA no longer freezes when substantial amounts of text are dumped to the screen. (#20177, #20649, @ethindp, @codeofdusk) +By default, when lines are skipped in a large text flood, NVDA emits a beep proportional to the length of the skipped material. +This can be disabled in the Advanced settings panel. * In Windows Terminal, NVDA is less likely to report stale characters when moving the caret in delayed remote sessions such as SSH. (#19503, @sheldon-im) * 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) diff --git a/user_docs/en/userGuide.md b/user_docs/en/userGuide.md index dc24f87284f..b2481b5262d 100644 --- a/user_docs/en/userGuide.md +++ b/user_docs/en/userGuide.md @@ -4289,6 +4289,16 @@ 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 {#BeepForSkippedLines} + +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.