From beca468338d397446a38ef56a88d7951ec6c8ca1 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Thu, 8 Jan 2026 12:37:55 -0500 Subject: [PATCH] Finally! Fixed bug that was causing interruption when prompt comes back. --- ...resent_char_if_cursor_change_horizontal.py | 11 ++++- .../onCursorChange/55000-tab_completion.py | 11 ++++- .../60000-word_echo_navigation.py | 9 +++- ...-present_line_if_cursor_change_vertical.py | 14 ++++-- .../onHeartBeat/65000-prompt_flush.py | 49 +++++++++++++++++++ src/fenrirscreenreader/fenrirVersion.py | 2 +- 6 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 src/fenrirscreenreader/commands/onHeartBeat/65000-prompt_flush.py diff --git a/src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py b/src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py index a1969ca0..061753b3 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrirscreenreader/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py @@ -71,6 +71,13 @@ class command: self.env["screen"]["new_cursor"]["y"], self.env["screen"]["new_content_text"], ) + # Don't interrupt ongoing auto-read announcements + do_interrupt = True + if self.env["runtime"]["SettingsManager"].get_setting_as_bool( + "speech", "auto_read_incoming" + ): + do_interrupt = False + if curr_char.isspace(): # Only announce spaces during pure navigation (arrow keys) # Check if this is really navigation by looking at input history @@ -87,14 +94,14 @@ class command: char_utils.present_char_for_review( self.env, curr_char, - interrupt=True, + interrupt=do_interrupt, announce_capital=True, flush=False, ) else: self.env["runtime"]["OutputManager"].present_text( curr_char, - interrupt=True, + interrupt=do_interrupt, ignore_punctuation=True, announce_capital=True, flush=False, diff --git a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py index fa2e035e..40a197ba 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py +++ b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py @@ -152,11 +152,18 @@ class command: curr_delta = delta_text if (len(curr_delta.strip()) != len(curr_delta) and curr_delta.strip() != ""): curr_delta = curr_delta.strip() - + + # Don't interrupt ongoing auto-read announcements + do_interrupt = True + if self.env["runtime"]["SettingsManager"].get_setting_as_bool( + "speech", "auto_read_incoming" + ): + do_interrupt = False + # Enhanced announcement with better handling of empty completions if curr_delta: self.env["runtime"]["OutputManager"].present_text( - curr_delta, interrupt=True, announce_capital=True, flush=False + curr_delta, interrupt=do_interrupt, announce_capital=True, flush=False ) def set_callback(self, callback): diff --git a/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py b/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py index 32c8d4ec..d2de92c3 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py +++ b/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py @@ -66,8 +66,15 @@ class command: ): return + # Don't interrupt ongoing auto-read announcements + do_interrupt = True + if self.env["runtime"]["SettingsManager"].get_setting_as_bool( + "speech", "auto_read_incoming" + ): + do_interrupt = False + self.env["runtime"]["OutputManager"].present_text( - curr_word, interrupt=True, flush=False + curr_word, interrupt=do_interrupt, flush=False ) def set_callback(self, callback): diff --git a/src/fenrirscreenreader/commands/onCursorChange/65000-present_line_if_cursor_change_vertical.py b/src/fenrirscreenreader/commands/onCursorChange/65000-present_line_if_cursor_change_vertical.py index 0f94793a..0ec5fd66 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/65000-present_line_if_cursor_change_vertical.py +++ b/src/fenrirscreenreader/commands/onCursorChange/65000-present_line_if_cursor_change_vertical.py @@ -30,8 +30,8 @@ class command: if self.env["runtime"]["ScreenManager"].is_screen_change(): self.lastIdent = 0 return - # this leads to problems in vim -> status line change -> no - # announcement, so we do check the lengh as hack + # Don't announce cursor movements when auto-read is handling incoming text + # This prevents interrupting ongoing auto-read announcements if self.env["runtime"]["ScreenManager"].is_delta(): return @@ -44,16 +44,22 @@ class command: self.env["screen"]["new_cursor"]["y"], self.env["screen"]["new_content_text"], ) + # Don't interrupt ongoing auto-read announcements with cursor movement + do_interrupt = True + if self.env["runtime"]["SettingsManager"].get_setting_as_bool( + "speech", "auto_read_incoming" + ): + do_interrupt = False + if curr_line.isspace(): self.env["runtime"]["OutputManager"].present_text( - _("blank"), sound_icon="EmptyLine", interrupt=True, flush=False + _("blank"), sound_icon="EmptyLine", interrupt=do_interrupt, flush=False ) else: # ident curr_ident = len(curr_line) - len(curr_line.lstrip()) if self.lastIdent == -1: self.lastIdent = curr_ident - do_interrupt = True if self.env["runtime"]["SettingsManager"].get_setting_as_bool( "general", "auto_present_indent" ): diff --git a/src/fenrirscreenreader/commands/onHeartBeat/65000-prompt_flush.py b/src/fenrirscreenreader/commands/onHeartBeat/65000-prompt_flush.py new file mode 100644 index 00000000..d9ecdcd1 --- /dev/null +++ b/src/fenrirscreenreader/commands/onHeartBeat/65000-prompt_flush.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributors. + +import time + + +class command: + def __init__(self): + pass + + def initialize(self, environment): + self.env = environment + + def shutdown(self): + pass + + def get_description(self): + return "" + + def run(self): + if not self.env["runtime"]["SettingsManager"].get_setting_as_bool( + "speech", "auto_read_incoming" + ): + return + + if "pendingPromptText" not in self.env["commandBuffer"]: + return + + pending_text = self.env["commandBuffer"]["pendingPromptText"] + if not pending_text: + return + + pending_time = self.env["commandBuffer"].get("pendingPromptTime", 0) + delay = self.env["runtime"]["SettingsManager"].get_setting_as_float( + "speech", "batch_flush_interval" + ) + if time.time() - pending_time < delay: + return + + self.env["runtime"]["OutputManager"].present_text( + pending_text, interrupt=False, flush=False + ) + self.env["commandBuffer"]["pendingPromptText"] = "" + + def set_callback(self, callback): + pass diff --git a/src/fenrirscreenreader/fenrirVersion.py b/src/fenrirscreenreader/fenrirVersion.py index 960db504..50cb39ed 100644 --- a/src/fenrirscreenreader/fenrirVersion.py +++ b/src/fenrirscreenreader/fenrirVersion.py @@ -4,5 +4,5 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributors. -version = "2026.01.05" +version = "2026.01.08" code_name = "testing"