diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 54180a27..bec25378 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_F2=toggle_braille KEY_FENRIR,KEY_F3=toggle_sound KEY_FENRIR,KEY_F4=toggle_speech KEY_FENRIR,KEY_ENTER=temp_disable_speech +KEY_FENRIR,KEY_SHIFT,KEY_P=progress_bar_monitor KEY_FENRIR,KEY_SHIFT,KEY_ENTER=silence_until_prompt KEY_FENRIR,KEY_SHIFT,KEY_CTRL,KEY_P=toggle_punctuation_level KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check diff --git a/config/settings/settings.conf b/config/settings/settings.conf index d6f74425..ba95a9d2 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -95,7 +95,7 @@ fenrirMaxRate=450 driver=vcsaDriver encoding=auto screenUpdateDelay=0.05 -ignoreScreen= +ignoreScreen=7 autodetectIgnoreScreen=True [keyboard] @@ -143,8 +143,8 @@ emoticons=True # define the current Fenrir key fenrirKeys=KEY_KP0,KEY_META,KEY_INSERT scriptKeys=KEY_COMPOSE -timeFormat=%H:%M:%P -dateFormat=%A, %B %d, %Y +timeFormat=%%I:%%M%%P +dateFormat=%%A, %%B %%d, %%Y autoSpellCheck=True spellCheckLanguage=en_US # path for your scripts "scriptKeys" functionality @@ -218,16 +218,24 @@ quickMenu=speech#rate;speech#pitch;speech#volume # Custom prompt patterns for silence until prompt feature # You can add your own shell prompt patterns as regular expressions # Each pattern should be on a separate line, format: customPatterns=pattern1,pattern2,pattern3 -# Examples: +# +# Built-in patterns include: +# - Shell prompts: $, #, >, user@host$, [user@host]$, bash-5.1$ +# - Package manager prompts: [Y/n], [y/N], [Yes/No], (Y/n), (y/N) +# - sudo prompts: [sudo] password for user:, Password:, user's password: +# - Confirmation prompts: Press any key, Are you sure?, Please confirm +# +# Custom pattern examples: # For PS1='[\u@\h \W] \$ ' use: \[.*@.*\s.*\]\s*[$#>]\s* # For "[user@hostname ~] $" use: \[.*@.*\s.*\]\s*[$#>]\s* # For custom prompts ending with specific strings, use patterns like: .*your_prompt_ending$ +# For custom package manager prompts: .*your_package_manager.*\[[YyNn]/[YyNn]\].* customPatterns= # Specific prompt strings to match exactly (useful for very specific custom prompts) # Format: exactMatches=prompt1,prompt2,prompt3 # Examples: -# exactMatches=[storm@fenrir ~] $,[root@fenrir ~] # +# exactMatches=[storm@fenrir ~] $,[root@fenrir ~] #,Continue installation? [Y/n] exactMatches= [time] diff --git a/src/fenrirscreenreader/commands/command_template.py b/src/fenrirscreenreader/commands/command_template.py index 4b8a1d90..4063c950 100644 --- a/src/fenrirscreenreader/commands/command_template.py +++ b/src/fenrirscreenreader/commands/command_template.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/00_init_commands.py b/src/fenrirscreenreader/commands/commands/00_init_commands.py index a12b0d87..6457a1cc 100644 --- a/src/fenrirscreenreader/commands/commands/00_init_commands.py +++ b/src/fenrirscreenreader/commands/commands/00_init_commands.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug # this command is just to initialize stuff. # like init index lists in memoryManager diff --git a/src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py b/src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py index c7b83f32..80062ad0 100644 --- a/src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py +++ b/src/fenrirscreenreader/commands/commands/add_word_to_spell_check.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils import string initialized = False diff --git a/src/fenrirscreenreader/commands/commands/adjustment_base.py b/src/fenrirscreenreader/commands/commands/adjustment_base.py new file mode 100644 index 00000000..575c0abd --- /dev/null +++ b/src/fenrirscreenreader/commands/commands/adjustment_base.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +import math + +class AdjustmentCommand(): + """Base class for speech and sound adjustment commands""" + def __init__(self, section, setting, direction, step=0.1): + self.section = section # 'speech' or 'sound' + self.setting = setting # 'rate', 'pitch', 'volume' + self.direction = direction # 'inc' or 'dec' + self.step = step + + def initialize(self, environment): + self.env = environment + + def shutdown(self): + pass + + def getDescription(self): + action = "Increase" if self.direction == 'inc' else "Decrease" + if self.section == 'speech': + return _(f'{action} the speech {self.setting}') + else: + return _(f'{action} the {self.section} {self.setting}') + + def run(self): + if self.section == 'sound' and self.setting == 'volume': + # Sound volume uses different method + self._adjust_sound_volume() + else: + # Speech rate, pitch, volume use standard method + self._adjust_speech_setting() + + def _adjust_speech_setting(self): + """Adjust speech settings (rate, pitch, volume)""" + value = self.env['runtime']['settingsManager'].getSettingAsFloat(self.section, self.setting) + + # Apply adjustment with rounding + if self.direction == 'inc': + value = round((math.ceil(10 * value) / 10) + self.step, 2) + if value > 1.0: + value = 1.0 + else: # dec + value = round((math.ceil(10 * value) / 10) - self.step, 2) + if value < 0.0: + value = 0.0 + + # Set the new value + self.env['runtime']['settingsManager'].setSetting(self.section, self.setting, str(value)) + + # Present feedback + percentage = int(value * 100) + if self.section == 'speech': + feedback = _("{0} percent speech {1}").format(percentage, self.setting) + else: + feedback = _("{0} percent {1} {2}").format(percentage, self.section, self.setting) + + self.env['runtime']['outputManager'].presentText(feedback, soundIcon='', interrupt=True) + + def _adjust_sound_volume(self): + """Adjust sound volume using same logic as speech""" + value = self.env['runtime']['settingsManager'].getSettingAsFloat(self.section, self.setting) + + # Sound volume uses same math as speech settings + if self.direction == 'inc': + value = round((math.ceil(10 * value) / 10) + self.step, 2) + if value > 1.0: + value = 1.0 + else: # dec + value = round((math.ceil(10 * value) / 10) - self.step, 2) + if value < 0.0: + value = 0.0 + + # Set the new value + self.env['runtime']['settingsManager'].setSetting(self.section, self.setting, str(value)) + + # Present feedback with appropriate sound icon + percentage = int(value * 100) + sound_icon = 'SoundOn' if self.direction == 'inc' else 'SoundOff' + feedback = _("{0} percent sound volume").format(percentage) + self.env['runtime']['outputManager'].presentText(feedback, soundIcon=sound_icon, interrupt=True) + + def setCallback(self, callback): + pass \ No newline at end of file diff --git a/src/fenrirscreenreader/commands/commands/announce_fenrir_version.py b/src/fenrirscreenreader/commands/commands/announce_fenrir_version.py index 8e29064a..6adc18f7 100644 --- a/src/fenrirscreenreader/commands/commands/announce_fenrir_version.py +++ b/src/fenrirscreenreader/commands/commands/announce_fenrir_version.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader import fenrirVersion class command(): diff --git a/src/fenrirscreenreader/commands/commands/attribute_cursor.py b/src/fenrirscreenreader/commands/commands/attribute_cursor.py index 72b66818..ec8010e1 100644 --- a/src/fenrirscreenreader/commands/commands/attribute_cursor.py +++ b/src/fenrirscreenreader/commands/commands/attribute_cursor.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import screen_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/bookmark_1.py b/src/fenrirscreenreader/commands/commands/bookmark_1.py index 23f2b536..13e6f54a 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_1.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_1.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '1' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(1, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_10.py b/src/fenrirscreenreader/commands/commands/bookmark_10.py index c669abab..1ea9c79f 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_10.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_10.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '10' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(10, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_2.py b/src/fenrirscreenreader/commands/commands/bookmark_2.py index 41b5f18b..8e93d4e1 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_2.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_2.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '2' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(2, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_3.py b/src/fenrirscreenreader/commands/commands/bookmark_3.py index defde3b7..168224af 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_3.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_3.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '3' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(3, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_4.py b/src/fenrirscreenreader/commands/commands/bookmark_4.py index 16428b6b..913c31e4 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_4.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_4.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '4' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(4, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_5.py b/src/fenrirscreenreader/commands/commands/bookmark_5.py index a2859d22..f5556fa7 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_5.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_5.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '5' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(5, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_6.py b/src/fenrirscreenreader/commands/commands/bookmark_6.py index 4eba278f..729fe1f3 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_6.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_6.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '6' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(6, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_7.py b/src/fenrirscreenreader/commands/commands/bookmark_7.py index 919d124b..8387c77a 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_7.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_7.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '7' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(7, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_8.py b/src/fenrirscreenreader/commands/commands/bookmark_8.py index c58a7356..f1e4c799 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_8.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_8.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '8' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(8, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_9.py b/src/fenrirscreenreader/commands/commands/bookmark_9.py index 57d811a5..04da752b 100644 --- a/src/fenrirscreenreader/commands/commands/bookmark_9.py +++ b/src/fenrirscreenreader/commands/commands/bookmark_9.py @@ -4,45 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import mark_utils -from fenrirscreenreader.utils import line_utils +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '9' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('read Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - if not self.env['commandBuffer']['bookMarks'][self.ID]: - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set').format(self.ID,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: - self.env['runtime']['outputManager'].presentText(_('Bookmark for application {0} not set').format(currApp,), interrupt=True) - return - - # set marks - marked = '' - startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() - if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: - endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() - marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) - else: - x, y, marked = \ - line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) - if marked.isspace(): - self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(marked, interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(9, 'read') diff --git a/src/fenrirscreenreader/commands/commands/bookmark_base.py b/src/fenrirscreenreader/commands/commands/bookmark_base.py new file mode 100644 index 00000000..4bb4930f --- /dev/null +++ b/src/fenrirscreenreader/commands/commands/bookmark_base.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +import gettext +_ = gettext.gettext + +from fenrirscreenreader.utils import mark_utils +from fenrirscreenreader.utils import line_utils + +class BookmarkCommand(): + """Base class for bookmark operations - read, set, clear""" + def __init__(self, bookmark_id, action='read'): + self.ID = str(bookmark_id) + self.action = action + + def initialize(self, environment): + self.env = environment + # Always initialize bookmark structure - all commands need this + if self.ID not in self.env['commandBuffer']['bookMarks']: + self.env['commandBuffer']['bookMarks'][self.ID] = {} + + def shutdown(self): + pass + + def getDescription(self): + if self.action == 'read': + return _('read Bookmark {0}').format(self.ID) + elif self.action == 'set': + return _('set Bookmark {0}').format(self.ID) + elif self.action == 'clear': + return _('remove Bookmark {0}').format(self.ID) + return f'{self.action} Bookmark {self.ID}' + + def run(self): + if self.action == 'read': + self._read_bookmark() + elif self.action == 'set': + self._set_bookmark() + elif self.action == 'clear': + self._clear_bookmark() + + def _read_bookmark(self): + currApp = self.env['runtime']['applicationManager'].getCurrentApplication() + + if not self.env['commandBuffer']['bookMarks'][self.ID]: + self.env['runtime']['outputManager'].presentText('Bookmark {0} not set'.format(self.ID), interrupt=True) + return + + if currApp not in self.env['commandBuffer']['bookMarks'][self.ID]: + self.env['runtime']['outputManager'].presentText('Bookmark for application {0} not set'.format(currApp), interrupt=True) + return + + if not self.env['commandBuffer']['bookMarks'][self.ID][currApp].get('1'): + self.env['runtime']['outputManager'].presentText('Bookmark for application {0} not set'.format(currApp), interrupt=True) + return + + # Get bookmarked text + marked = '' + startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() + + if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: + endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() + marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screen']['newContentText']) + else: + x, y, marked = line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screen']['newContentText']) + + if marked.isspace(): + self.env['runtime']['outputManager'].presentText(_('blank'), soundIcon='EmptyLine', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(marked, interrupt=True) + + def _set_bookmark(self): + if not self.env['commandBuffer']['Marks']['1']: + self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) + return + + currApp = self.env['runtime']['applicationManager'].getCurrentApplication() + self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} + + self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() + + if self.env['commandBuffer']['Marks']['2']: + self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() + else: + self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None + + self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) + + # Clear marks after setting bookmark + self.env['commandBuffer']['Marks']['1'] = None + self.env['commandBuffer']['Marks']['2'] = None + + def _clear_bookmark(self): + currApp = self.env['runtime']['applicationManager'].getCurrentApplication() + + if self.ID in self.env['commandBuffer']['bookMarks'] and currApp in self.env['commandBuffer']['bookMarks'][self.ID]: + del self.env['commandBuffer']['bookMarks'][self.ID][currApp] + self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(_('Bookmark {0} not set for application {1}').format(self.ID, currApp), interrupt=True) + + def setCallback(self, callback): + pass + +# Factory function to create bookmark command instances +def create_bookmark_commands(): + """Create all bookmark command instances""" + commands = {} + + # Create read bookmark commands (bookmark_1 through bookmark_10) + for i in range(1, 11): + commands[f'bookmark_{i}'] = lambda i=i: BookmarkCommand(i, 'read') + + # Create set bookmark commands (set_bookmark_1 through set_bookmark_10) + for i in range(1, 11): + commands[f'set_bookmark_{i}'] = lambda i=i: BookmarkCommand(i, 'set') + + # Create clear bookmark commands (clear_bookmark_1 through clear_bookmark_10) + for i in range(1, 11): + commands[f'clear_bookmark_{i}'] = lambda i=i: BookmarkCommand(i, 'clear') + + return commands + +# For backwards compatibility, provide individual command classes +# This allows the existing command loading system to work unchanged + +def _make_command_class(bookmark_id, action): + """Create a command class for a specific bookmark and action""" + class command(BookmarkCommand): + def __init__(self): + super().__init__(bookmark_id, action) + return command + +# Generate individual command classes for each bookmark operation +# These will be used by the existing command loading system + +# Read bookmarks (bookmark_1.py style) +for i in range(1, 11): + globals()[f'bookmark_{i}_command'] = _make_command_class(i, 'read') + +# Set bookmarks (set_bookmark_1.py style) +for i in range(1, 11): + globals()[f'set_bookmark_{i}_command'] = _make_command_class(i, 'set') + +# Clear bookmarks (clear_bookmark_1.py style) +for i in range(1, 11): + globals()[f'clear_bookmark_{i}_command'] = _make_command_class(i, 'clear') \ No newline at end of file diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_1.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_1.py index 2cbac84e..4bbd2977 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_1.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_1.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '1' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(1, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_10.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_10.py index 8c19e0ee..56642bec 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_10.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_10.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '10' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(10, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_2.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_2.py index ac084680..11d4d4ac 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_2.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_2.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '2' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(2, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_3.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_3.py index 367417d7..5b94bf72 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_3.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_3.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '3' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(3, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_4.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_4.py index 1d1267b2..6b970a83 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_4.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_4.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '4' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(4, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_5.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_5.py index d16ef410..2a6ad9c7 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_5.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_5.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '5' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(5, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_6.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_6.py index 9797f812..15521a9d 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_6.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_6.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '6' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(6, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_7.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_7.py index baaeb133..d318ab79 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_7.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_7.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '7' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(7, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_8.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_8.py index 66328cf3..867c337b 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_8.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_8.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '8' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(8, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_bookmark_9.py b/src/fenrirscreenreader/commands/commands/clear_bookmark_9.py index 2a87c4df..b579d0cc 100644 --- a/src/fenrirscreenreader/commands/commands/clear_bookmark_9.py +++ b/src/fenrirscreenreader/commands/commands/clear_bookmark_9.py @@ -4,24 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '9' - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('remove Bookmark {0}').format(self.ID,) - - def run(self): - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - - del self.env['commandBuffer']['bookMarks'][self.ID][currApp] - - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} removed for application {1}').format(self.ID, currApp), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__(9, 'clear') diff --git a/src/fenrirscreenreader/commands/commands/clear_clipboard.py b/src/fenrirscreenreader/commands/commands/clear_clipboard.py index a8bb425b..a8d6126f 100644 --- a/src/fenrirscreenreader/commands/commands/clear_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/clear_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/clear_window_application.py b/src/fenrirscreenreader/commands/commands/clear_window_application.py index 305f99f5..31e436eb 100644 --- a/src/fenrirscreenreader/commands/commands/clear_window_application.py +++ b/src/fenrirscreenreader/commands/commands/clear_window_application.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/copy_last_echo_to_clipboard.py b/src/fenrirscreenreader/commands/commands/copy_last_echo_to_clipboard.py index 5129badf..f8b56722 100644 --- a/src/fenrirscreenreader/commands/commands/copy_last_echo_to_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/copy_last_echo_to_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/copy_marked_to_clipboard.py b/src/fenrirscreenreader/commands/commands/copy_marked_to_clipboard.py index 7445df70..806aac3e 100644 --- a/src/fenrirscreenreader/commands/commands/copy_marked_to_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/copy_marked_to_clipboard.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/curr_clipboard.py b/src/fenrirscreenreader/commands/commands/curr_clipboard.py index 92d5cd37..0031f835 100644 --- a/src/fenrirscreenreader/commands/commands/curr_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/curr_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/curr_screen.py b/src/fenrirscreenreader/commands/commands/curr_screen.py index e4a66fe7..de87910b 100644 --- a/src/fenrirscreenreader/commands/commands/curr_screen.py +++ b/src/fenrirscreenreader/commands/commands/curr_screen.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/curr_screen_after_cursor.py b/src/fenrirscreenreader/commands/commands/curr_screen_after_cursor.py index cf560d38..6269458a 100644 --- a/src/fenrirscreenreader/commands/commands/curr_screen_after_cursor.py +++ b/src/fenrirscreenreader/commands/commands/curr_screen_after_cursor.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/curr_screen_before_cursor.py b/src/fenrirscreenreader/commands/commands/curr_screen_before_cursor.py index 627c2cce..7d0afbfc 100644 --- a/src/fenrirscreenreader/commands/commands/curr_screen_before_cursor.py +++ b/src/fenrirscreenreader/commands/commands/curr_screen_before_cursor.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/current_quick_menu_entry.py b/src/fenrirscreenreader/commands/commands/current_quick_menu_entry.py index 0b21ad3c..a89ce3ee 100644 --- a/src/fenrirscreenreader/commands/commands/current_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/commands/current_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/current_quick_menu_value.py b/src/fenrirscreenreader/commands/commands/current_quick_menu_value.py index b9da1e0e..6522e080 100644 --- a/src/fenrirscreenreader/commands/commands/current_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/commands/current_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/cursor_column.py b/src/fenrirscreenreader/commands/commands/cursor_column.py index 9f4bb089..f6a9bb82 100644 --- a/src/fenrirscreenreader/commands/commands/cursor_column.py +++ b/src/fenrirscreenreader/commands/commands/cursor_column.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/cursor_lineno.py b/src/fenrirscreenreader/commands/commands/cursor_lineno.py index 739e0b33..938c1356 100644 --- a/src/fenrirscreenreader/commands/commands/cursor_lineno.py +++ b/src/fenrirscreenreader/commands/commands/cursor_lineno.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/cursor_position.py b/src/fenrirscreenreader/commands/commands/cursor_position.py index a267bee1..c00cf38d 100644 --- a/src/fenrirscreenreader/commands/commands/cursor_position.py +++ b/src/fenrirscreenreader/commands/commands/cursor_position.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/cursor_read_line_to_cursor.py b/src/fenrirscreenreader/commands/commands/cursor_read_line_to_cursor.py index 0f0a0fff..80fd8d86 100644 --- a/src/fenrirscreenreader/commands/commands/cursor_read_line_to_cursor.py +++ b/src/fenrirscreenreader/commands/commands/cursor_read_line_to_cursor.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/cursor_read_to_end_of_line.py b/src/fenrirscreenreader/commands/commands/cursor_read_to_end_of_line.py index 4c56f019..5f8b32f6 100644 --- a/src/fenrirscreenreader/commands/commands/cursor_read_to_end_of_line.py +++ b/src/fenrirscreenreader/commands/commands/cursor_read_to_end_of_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/date.py b/src/fenrirscreenreader/commands/commands/date.py index 3275d2f0..7a95ca1c 100644 --- a/src/fenrirscreenreader/commands/commands/date.py +++ b/src/fenrirscreenreader/commands/commands/date.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/commands/dec_alsa_volume.py b/src/fenrirscreenreader/commands/commands/dec_alsa_volume.py index 87e719d4..59cf13fe 100644 --- a/src/fenrirscreenreader/commands/commands/dec_alsa_volume.py +++ b/src/fenrirscreenreader/commands/commands/dec_alsa_volume.py @@ -4,36 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -initialized = False -try: - import alsaaudio - initialized = True -except: - pass +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -from fenrirscreenreader.core import debug - -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _("Decrease system volume") - - def run(self): - if not initialized: - self.env['runtime']['outputManager'].presentText(_('alsaaudio is not installed'), interrupt=True) - return - mixer = alsaaudio.Mixer() - value = mixer.getvolume()[0] - value = value - 5 - if value < 5: - value = 5 - mixer.setvolume(value) - self.env['runtime']['outputManager'].presentText(_("{0} percent system volume").format(value), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('alsa', 'volume', 'dec') diff --git a/src/fenrirscreenreader/commands/commands/dec_sound_volume.py b/src/fenrirscreenreader/commands/commands/dec_sound_volume.py index 097359b8..4b36bf11 100644 --- a/src/fenrirscreenreader/commands/commands/dec_sound_volume.py +++ b/src/fenrirscreenreader/commands/commands/dec_sound_volume.py @@ -4,30 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('decrease sound volume') - - def run(self): - - value = self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume') - - value = round((math.ceil(10 * value) / 10) - 0.1, 2) - if value < 0.1: - value = 0.1 - self.env['runtime']['settingsManager'].setSetting('sound', 'volume', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent sound volume").format(int(value * 100)), soundIcon='SoundOff', interrupt=True) - - def setCallback(self, callback): - pass - + super().__init__('sound', 'volume', 'dec') diff --git a/src/fenrirscreenreader/commands/commands/dec_speech_pitch.py b/src/fenrirscreenreader/commands/commands/dec_speech_pitch.py index 5ca24a9a..02cf36e8 100644 --- a/src/fenrirscreenreader/commands/commands/dec_speech_pitch.py +++ b/src/fenrirscreenreader/commands/commands/dec_speech_pitch.py @@ -4,26 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Decreases the pitch of the speech') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'pitch') - value = round((math.ceil(10 * value) / 10) - 0.1, 2) - if value < 0.0: - value = 0.0 - self.env['runtime']['settingsManager'].setSetting('speech', 'pitch', str(value)) - self.env['runtime']['outputManager'].presentText(_('{0} percent speech pitch').format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('speech', 'pitch', 'dec') diff --git a/src/fenrirscreenreader/commands/commands/dec_speech_rate.py b/src/fenrirscreenreader/commands/commands/dec_speech_rate.py index 1e4462b9..82b54982 100644 --- a/src/fenrirscreenreader/commands/commands/dec_speech_rate.py +++ b/src/fenrirscreenreader/commands/commands/dec_speech_rate.py @@ -4,27 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Decreases the rate of the speech') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate') - value = round((math.ceil(10 * value) / 10) - 0.1, 2) - if value < 0.0: - value = 0.0 - self.env['runtime']['settingsManager'].setSetting('speech', 'rate', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent speech rate").format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('speech', 'rate', 'dec') diff --git a/src/fenrirscreenreader/commands/commands/dec_speech_volume.py b/src/fenrirscreenreader/commands/commands/dec_speech_volume.py index 6a87edc9..f3d48afc 100644 --- a/src/fenrirscreenreader/commands/commands/dec_speech_volume.py +++ b/src/fenrirscreenreader/commands/commands/dec_speech_volume.py @@ -4,28 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Decreases the volume of the speech') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'volume') - value = round((math.ceil(10 * value) / 10) - 0.1, 2) - if value < 0.1: - value = 0.1 - self.env['runtime']['settingsManager'].setSetting('speech', 'volume', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent speech volume").format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass - + super().__init__('speech', 'volume', 'dec') diff --git a/src/fenrirscreenreader/commands/commands/exit_review.py b/src/fenrirscreenreader/commands/commands/exit_review.py index 01898b14..86ddf87d 100644 --- a/src/fenrirscreenreader/commands/commands/exit_review.py +++ b/src/fenrirscreenreader/commands/commands/exit_review.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/export_clipboard_to_x.py b/src/fenrirscreenreader/commands/commands/export_clipboard_to_x.py index 296c93bd..6d460d5c 100644 --- a/src/fenrirscreenreader/commands/commands/export_clipboard_to_x.py +++ b/src/fenrirscreenreader/commands/commands/export_clipboard_to_x.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import os import importlib import _thread diff --git a/src/fenrirscreenreader/commands/commands/first_clipboard.py b/src/fenrirscreenreader/commands/commands/first_clipboard.py index 0511b6da..c2bc287a 100644 --- a/src/fenrirscreenreader/commands/commands/first_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/first_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/forward_keypress.py b/src/fenrirscreenreader/commands/commands/forward_keypress.py index c8081254..4c50bc61 100644 --- a/src/fenrirscreenreader/commands/commands/forward_keypress.py +++ b/src/fenrirscreenreader/commands/commands/forward_keypress.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/import_clipboard_from_file.py b/src/fenrirscreenreader/commands/commands/import_clipboard_from_file.py index 249c7c90..0446cb4b 100644 --- a/src/fenrirscreenreader/commands/commands/import_clipboard_from_file.py +++ b/src/fenrirscreenreader/commands/commands/import_clipboard_from_file.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils import os diff --git a/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py b/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py index 40f395e1..b5ea5222 100644 --- a/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py +++ b/src/fenrirscreenreader/commands/commands/import_clipboard_from_x.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import importlib import _thread import pyperclip diff --git a/src/fenrirscreenreader/commands/commands/inc_alsa_volume.py b/src/fenrirscreenreader/commands/commands/inc_alsa_volume.py index 4580ba25..ba3f4086 100644 --- a/src/fenrirscreenreader/commands/commands/inc_alsa_volume.py +++ b/src/fenrirscreenreader/commands/commands/inc_alsa_volume.py @@ -4,36 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -initialized = False -try: - import alsaaudio - initialized = True -except: - pass +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -from fenrirscreenreader.core import debug - -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _("Increase system volume") - - def run(self): - if not initialized: - self.env['runtime']['outputManager'].presentText(_('alsaaudio is not installed'), interrupt=True) - return - mixer = alsaaudio.Mixer() - value = mixer.getvolume()[0] - value = value + 5 - if value > 100: - value = 100 - mixer.setvolume(value) - self.env['runtime']['outputManager'].presentText(_("{0} percent system volume").format(value), interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('alsa', 'volume', 'inc') diff --git a/src/fenrirscreenreader/commands/commands/inc_sound_volume.py b/src/fenrirscreenreader/commands/commands/inc_sound_volume.py index 9ce291e7..67bd8d55 100644 --- a/src/fenrirscreenreader/commands/commands/inc_sound_volume.py +++ b/src/fenrirscreenreader/commands/commands/inc_sound_volume.py @@ -4,29 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('adjusts the volume for in coming sounds') - - def run(self): - - value = self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume') - - value = round((math.ceil(10 * value) / 10) + 0.1, 2) - if value > 1.0: - value = 1.0 - self.env['runtime']['settingsManager'].setSetting('sound', 'volume', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent sound volume").format(int(value * 100)), soundIcon='SoundOn', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('sound', 'volume', 'inc') diff --git a/src/fenrirscreenreader/commands/commands/inc_speech_pitch.py b/src/fenrirscreenreader/commands/commands/inc_speech_pitch.py index 735f7279..a4d9c09f 100644 --- a/src/fenrirscreenreader/commands/commands/inc_speech_pitch.py +++ b/src/fenrirscreenreader/commands/commands/inc_speech_pitch.py @@ -4,27 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Increases the pitch of the speech') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'pitch') - value = round((math.ceil(10 * value) / 10) + 0.1, 2) - if value > 1.0: - value = 1.0 - self.env['runtime']['settingsManager'].setSetting('speech', 'pitch', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent speech pitch").format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('speech', 'pitch', 'inc') diff --git a/src/fenrirscreenreader/commands/commands/inc_speech_rate.py b/src/fenrirscreenreader/commands/commands/inc_speech_rate.py index 91265677..b91fd1cd 100644 --- a/src/fenrirscreenreader/commands/commands/inc_speech_rate.py +++ b/src/fenrirscreenreader/commands/commands/inc_speech_rate.py @@ -4,27 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Increase the speech rate') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate') - value = round((math.ceil(10 * value) / 10) + 0.1, 2) - if value > 1.0: - value = 1.0 - self.env['runtime']['settingsManager'].setSetting('speech', 'rate', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent speech rate").format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('speech', 'rate', 'inc') diff --git a/src/fenrirscreenreader/commands/commands/inc_speech_volume.py b/src/fenrirscreenreader/commands/commands/inc_speech_volume.py index c4a91444..bb88059d 100644 --- a/src/fenrirscreenreader/commands/commands/inc_speech_volume.py +++ b/src/fenrirscreenreader/commands/commands/inc_speech_volume.py @@ -4,27 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug -import math +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'adjustment_base.py') +_spec = importlib.util.spec_from_file_location("adjustment_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +AdjustmentCommand = _module.AdjustmentCommand -class command(): +class command(AdjustmentCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Increase the speech volume') - - def run(self): - value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'volume') - value = round((math.ceil(10 * value) / 10) + 0.1, 2) - if value > 1.0: - value = 1.0 - self.env['runtime']['settingsManager'].setSetting('speech', 'volume', str(value)) - - self.env['runtime']['outputManager'].presentText(_("{0} percent speech volume").format(int(value * 100)), soundIcon='', interrupt=True) - - def setCallback(self, callback): - pass + super().__init__('speech', 'volume', 'inc') diff --git a/src/fenrirscreenreader/commands/commands/indent_curr_line.py b/src/fenrirscreenreader/commands/commands/indent_curr_line.py index 3f0ba702..68c12760 100644 --- a/src/fenrirscreenreader/commands/commands/indent_curr_line.py +++ b/src/fenrirscreenreader/commands/commands/indent_curr_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/last_clipboard.py b/src/fenrirscreenreader/commands/commands/last_clipboard.py index a5c496ac..e09d7fe8 100644 --- a/src/fenrirscreenreader/commands/commands/last_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/last_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/marked_text.py b/src/fenrirscreenreader/commands/commands/marked_text.py index 561f8024..3bf3f094 100644 --- a/src/fenrirscreenreader/commands/commands/marked_text.py +++ b/src/fenrirscreenreader/commands/commands/marked_text.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import mark_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/next_clipboard.py b/src/fenrirscreenreader/commands/commands/next_clipboard.py index 87320f03..7364f62d 100644 --- a/src/fenrirscreenreader/commands/commands/next_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/next_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/next_quick_menu_entry.py b/src/fenrirscreenreader/commands/commands/next_quick_menu_entry.py index e14fad03..1d2a5fb1 100644 --- a/src/fenrirscreenreader/commands/commands/next_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/commands/next_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/next_quick_menu_value.py b/src/fenrirscreenreader/commands/commands/next_quick_menu_value.py index ae15c51a..78a0f9ad 100644 --- a/src/fenrirscreenreader/commands/commands/next_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/commands/next_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/paste_clipboard.py b/src/fenrirscreenreader/commands/commands/paste_clipboard.py index 60d620bc..565ffc25 100644 --- a/src/fenrirscreenreader/commands/commands/paste_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/paste_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import time class command(): diff --git a/src/fenrirscreenreader/commands/commands/present_first_line.py b/src/fenrirscreenreader/commands/commands/present_first_line.py index 8c5c4383..3a901204 100644 --- a/src/fenrirscreenreader/commands/commands/present_first_line.py +++ b/src/fenrirscreenreader/commands/commands/present_first_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/present_last_line.py b/src/fenrirscreenreader/commands/commands/present_last_line.py index bd17aadf..274eb721 100644 --- a/src/fenrirscreenreader/commands/commands/present_last_line.py +++ b/src/fenrirscreenreader/commands/commands/present_last_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/prev_clipboard.py b/src/fenrirscreenreader/commands/commands/prev_clipboard.py index 531bd2ee..95bca467 100644 --- a/src/fenrirscreenreader/commands/commands/prev_clipboard.py +++ b/src/fenrirscreenreader/commands/commands/prev_clipboard.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/prev_quick_menu_entry.py b/src/fenrirscreenreader/commands/commands/prev_quick_menu_entry.py index 329438b1..87aef5df 100644 --- a/src/fenrirscreenreader/commands/commands/prev_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/commands/prev_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/prev_quick_menu_value.py b/src/fenrirscreenreader/commands/commands/prev_quick_menu_value.py index 64495c68..bfa7e8cb 100644 --- a/src/fenrirscreenreader/commands/commands/prev_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/commands/prev_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/progress_bar_monitor.py b/src/fenrirscreenreader/commands/commands/progress_bar_monitor.py index 083e4b6e..28808ec4 100644 --- a/src/fenrirscreenreader/commands/commands/progress_bar_monitor.py +++ b/src/fenrirscreenreader/commands/commands/progress_bar_monitor.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import re import time import threading @@ -58,7 +57,11 @@ class command(): # Don't control speech - progress monitor is beep-only def detectProgress(self, text): - if not self.env['runtime']['progressMonitoring']: + if not self.env['commandBuffer']['progressMonitoring']: + return + + # Skip progress detection if current screen looks like a prompt + if self.isCurrentLinePrompt(): return currentTime = time.time() @@ -67,10 +70,10 @@ class command(): percentMatch = re.search(r'(\d+(?:\.\d+)?)\s*%', text) if percentMatch: percentage = float(percentMatch.group(1)) - if percentage != self.env['runtime']['lastProgressValue']: + if percentage != self.env['commandBuffer']['lastProgressValue']: self.playProgressTone(percentage) - self.env['runtime']['lastProgressValue'] = percentage - self.env['runtime']['lastProgressTime'] = currentTime + self.env['commandBuffer']['lastProgressValue'] = percentage + self.env['commandBuffer']['lastProgressTime'] = currentTime return # Pattern 2: Fraction (15/100, 3 of 10, etc.) @@ -80,32 +83,35 @@ class command(): total = int(fractionMatch.group(2)) if total > 0: percentage = (current / total) * 100 - if percentage != self.env['runtime']['lastProgressValue']: + if percentage != self.env['commandBuffer']['lastProgressValue']: self.playProgressTone(percentage) - self.env['runtime']['lastProgressValue'] = percentage - self.env['runtime']['lastProgressTime'] = currentTime + self.env['commandBuffer']['lastProgressValue'] = percentage + self.env['commandBuffer']['lastProgressTime'] = currentTime return # Pattern 3: Progress bars ([#### ], [====> ], etc.) - barMatch = re.search(r'\[([#=\-\*]+)([^\]]*)\]', text) + # Improved pattern to avoid matching IRC channels like [#channel] + barMatch = re.search(r'\[([#=\-\*]+)([\s\.]*)\]', text) if barMatch: filled = len(barMatch.group(1)) - total = filled + len(barMatch.group(2)) - if total > 0: + unfilled = len(barMatch.group(2)) + total = filled + unfilled + # Require at least 2 progress chars total and unfilled portion must be spaces/dots + if total >= 2 and (not barMatch.group(2) or re.match(r'^[\s\.]*$', barMatch.group(2))): percentage = (filled / total) * 100 - if percentage != self.env['runtime']['lastProgressValue']: + if percentage != self.env['commandBuffer']['lastProgressValue']: self.playProgressTone(percentage) - self.env['runtime']['lastProgressValue'] = percentage - self.env['runtime']['lastProgressTime'] = currentTime + self.env['commandBuffer']['lastProgressValue'] = percentage + self.env['commandBuffer']['lastProgressTime'] = currentTime return # Pattern 4: Generic activity indicators (Loading..., Working..., etc.) activityPattern = re.search(r'(loading|processing|working|installing|downloading|compiling|building).*\.{2,}', text, re.IGNORECASE) if activityPattern: # Play a steady beep every 2 seconds for ongoing activity - if currentTime - self.env['runtime']['lastProgressTime'] >= 2.0: + if currentTime - self.env['commandBuffer']['lastProgressTime'] >= 2.0: self.playActivityBeep() - self.env['runtime']['lastProgressTime'] = currentTime + self.env['commandBuffer']['lastProgressTime'] = currentTime def playProgressTone(self, percentage): # Map 0-100% to 400-1200Hz frequency range @@ -116,6 +122,88 @@ class command(): def playActivityBeep(self): # Single tone for generic activity self.env['runtime']['outputManager'].playFrequence(800, 0.1, interrupt=False) + + def isCurrentLinePrompt(self): + """Check if the current line looks like a standalone prompt (not command with progress)""" + import re + + try: + # Get the current screen content + if not self.env['screen']['newContentText']: + return False + + lines = self.env['screen']['newContentText'].split('\n') + if not lines: + return False + + # Check the last line (most common) and current cursor line for prompt patterns + linesToCheck = [] + + # Add last line (most common for prompts) + if lines: + linesToCheck.append(lines[-1]) + + # Add current cursor line if different from last line + if (self.env['screen']['newCursor']['y'] < len(lines) and + self.env['screen']['newCursor']['y'] != len(lines) - 1): + linesToCheck.append(lines[self.env['screen']['newCursor']['y']]) + + # Standalone prompt patterns (no commands mixed in) + standalonePromptPatterns = [ + r'^\s*\$\s*$', # Just $ (with whitespace) + r'^\s*#\s*$', # Just # (with whitespace) + r'^\s*>\s*$', # Just > (with whitespace) + r'^\[.*\]\s*[\\\$#>]\s*$', # [path]$ without commands + r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # bash-5.1$ without commands + + # Interactive prompt patterns (these ARE standalone) + r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style + r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style + r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style + r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman style prompts + + # Authentication prompts (these ARE standalone) + r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password + r'^[Pp]assword\s*:\s*$', # Password: + r'.*[Pp]assword\s*:\s*$', # general password prompts + + # Continuation prompts (these ARE standalone) + r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key + r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure? + ] + + for line in linesToCheck: + line = line.strip() + if not line: + continue + + # Check if this line contains both a prompt AND other content (like commands) + # If so, don't treat it as a standalone prompt + hasPromptMarker = bool(re.search(r'.*@.*[\\\$#>]', line) or re.search(r'^\[.*\]\s*[\\\$#>]', line)) + if hasPromptMarker: + # If line has prompt marker but also has significant content after it, + # it's a command line, not a standalone prompt + promptEnd = max( + line.rfind('$'), + line.rfind('#'), + line.rfind('>'), + line.rfind('\\') + ) + if promptEnd >= 0 and promptEnd < len(line) - 5: # More than just whitespace after prompt + continue # This is a command line, not a standalone prompt + + for pattern in standalonePromptPatterns: + try: + if re.search(pattern, line): + return True + except re.error: + continue + + return False + + except Exception: + # If anything fails, assume it's not a prompt to be safe + return False def setCallback(self, callback): pass \ No newline at end of file diff --git a/src/fenrirscreenreader/commands/commands/quit_fenrir.py b/src/fenrirscreenreader/commands/commands/quit_fenrir.py index 18fcdc8f..0baf8449 100644 --- a/src/fenrirscreenreader/commands/commands/quit_fenrir.py +++ b/src/fenrirscreenreader/commands/commands/quit_fenrir.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/remove_marks.py b/src/fenrirscreenreader/commands/commands/remove_marks.py index 4d8ad998..17a62880 100644 --- a/src/fenrirscreenreader/commands/commands/remove_marks.py +++ b/src/fenrirscreenreader/commands/commands/remove_marks.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py b/src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py index fac7f5f4..edff9217 100644 --- a/src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py +++ b/src/fenrirscreenreader/commands/commands/remove_word_from_spell_check.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils import string initialized = False diff --git a/src/fenrirscreenreader/commands/commands/review_bottom.py b/src/fenrirscreenreader/commands/commands/review_bottom.py index 8cfaf34c..cc529e2b 100644 --- a/src/fenrirscreenreader/commands/commands/review_bottom.py +++ b/src/fenrirscreenreader/commands/commands/review_bottom.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/review_curr_char.py b/src/fenrirscreenreader/commands/commands/review_curr_char.py index 72c07c9a..6ce99926 100644 --- a/src/fenrirscreenreader/commands/commands/review_curr_char.py +++ b/src/fenrirscreenreader/commands/commands/review_curr_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -23,7 +22,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], currChar = \ char_utils.getCurrentChar(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, currChar, interrupt=True, announceCapital=True, flush=False) # is has attribute it enabled? if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'): cursorPos = self.env['screen']['newCursorReview'] diff --git a/src/fenrirscreenreader/commands/commands/review_curr_char_phonetic.py b/src/fenrirscreenreader/commands/commands/review_curr_char_phonetic.py index f118e85e..120045fe 100644 --- a/src/fenrirscreenreader/commands/commands/review_curr_char_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_curr_char_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_curr_line.py b/src/fenrirscreenreader/commands/commands/review_curr_line.py index 2f3be038..871cc0b7 100644 --- a/src/fenrirscreenreader/commands/commands/review_curr_line.py +++ b/src/fenrirscreenreader/commands/commands/review_curr_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_curr_word.py b/src/fenrirscreenreader/commands/commands/review_curr_word.py index c0a2cbab..079eaae1 100644 --- a/src/fenrirscreenreader/commands/commands/review_curr_word.py +++ b/src/fenrirscreenreader/commands/commands/review_curr_word.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_curr_word_phonetic.py b/src/fenrirscreenreader/commands/commands/review_curr_word_phonetic.py index 974112ba..d0158ef0 100644 --- a/src/fenrirscreenreader/commands/commands/review_curr_word_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_curr_word_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils from fenrirscreenreader.utils import char_utils diff --git a/src/fenrirscreenreader/commands/commands/review_down.py b/src/fenrirscreenreader/commands/commands/review_down.py index d122f36f..8797600a 100644 --- a/src/fenrirscreenreader/commands/commands/review_down.py +++ b/src/fenrirscreenreader/commands/commands/review_down.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_line_begin.py b/src/fenrirscreenreader/commands/commands/review_line_begin.py index e725d75d..5d31a04a 100644 --- a/src/fenrirscreenreader/commands/commands/review_line_begin.py +++ b/src/fenrirscreenreader/commands/commands/review_line_begin.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_line_end.py b/src/fenrirscreenreader/commands/commands/review_line_end.py index df820cc5..5cf18dd2 100644 --- a/src/fenrirscreenreader/commands/commands/review_line_end.py +++ b/src/fenrirscreenreader/commands/commands/review_line_end.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_line_first_char.py b/src/fenrirscreenreader/commands/commands/review_line_first_char.py index 7c7a3e11..84de0a72 100644 --- a/src/fenrirscreenreader/commands/commands/review_line_first_char.py +++ b/src/fenrirscreenreader/commands/commands/review_line_first_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils from fenrirscreenreader.utils import char_utils @@ -29,7 +28,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], currChar = \ char_utils.getCurrentChar(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, currChar, interrupt=True, announceCapital=True, flush=False) self.env['runtime']['outputManager'].presentText(_("first character in line indent {0}").format(str(len(currLine) - len(currLine.lstrip()))), interrupt=False) def setCallback(self, callback): diff --git a/src/fenrirscreenreader/commands/commands/review_line_last_char.py b/src/fenrirscreenreader/commands/commands/review_line_last_char.py index 7048c5f0..82bcf101 100644 --- a/src/fenrirscreenreader/commands/commands/review_line_last_char.py +++ b/src/fenrirscreenreader/commands/commands/review_line_last_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -23,7 +22,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], lastChar = \ char_utils.getLastCharInLine(self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, lastChar, interrupt=True, announceCapital=True, flush=False) self.env['runtime']['outputManager'].presentText(_("last character in line"), interrupt=False) def setCallback(self, callback): diff --git a/src/fenrirscreenreader/commands/commands/review_next_char.py b/src/fenrirscreenreader/commands/commands/review_next_char.py index 57ec7687..496e2f83 100644 --- a/src/fenrirscreenreader/commands/commands/review_next_char.py +++ b/src/fenrirscreenreader/commands/commands/review_next_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -22,7 +21,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], nextChar, endOfScreen, lineBreak = \ char_utils.getNextChar(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(nextChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, nextChar, interrupt=True, announceCapital=True, flush=False) if endOfScreen: if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'endOfScreen'): self.env['runtime']['outputManager'].presentText(_('end of screen'), interrupt=True, soundIcon='EndOfScreen') diff --git a/src/fenrirscreenreader/commands/commands/review_next_char_phonetic.py b/src/fenrirscreenreader/commands/commands/review_next_char_phonetic.py index 0a384d19..2d3a1fb2 100644 --- a/src/fenrirscreenreader/commands/commands/review_next_char_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_next_char_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_next_line.py b/src/fenrirscreenreader/commands/commands/review_next_line.py index b17018e9..a2870d7f 100644 --- a/src/fenrirscreenreader/commands/commands/review_next_line.py +++ b/src/fenrirscreenreader/commands/commands/review_next_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_next_word.py b/src/fenrirscreenreader/commands/commands/review_next_word.py index 6b6eb7cf..488ddc44 100644 --- a/src/fenrirscreenreader/commands/commands/review_next_word.py +++ b/src/fenrirscreenreader/commands/commands/review_next_word.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_next_word_phonetic.py b/src/fenrirscreenreader/commands/commands/review_next_word_phonetic.py index fe022ba4..e15fb014 100644 --- a/src/fenrirscreenreader/commands/commands/review_next_word_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_next_word_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils from fenrirscreenreader.utils import char_utils diff --git a/src/fenrirscreenreader/commands/commands/review_prev_char.py b/src/fenrirscreenreader/commands/commands/review_prev_char.py index fba67bc0..5c4587b8 100644 --- a/src/fenrirscreenreader/commands/commands/review_prev_char.py +++ b/src/fenrirscreenreader/commands/commands/review_prev_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -25,7 +24,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], prevChar, endOfScreen, lineBreak = \ char_utils.getPrevChar(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(prevChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, prevChar, interrupt=True, announceCapital=True, flush=False) if endOfScreen: if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'endOfScreen'): self.env['runtime']['outputManager'].presentText(_('end of screen'), interrupt=True, soundIcon='EndOfScreen') diff --git a/src/fenrirscreenreader/commands/commands/review_prev_char_phonetic.py b/src/fenrirscreenreader/commands/commands/review_prev_char_phonetic.py index c2909110..8cf125f9 100644 --- a/src/fenrirscreenreader/commands/commands/review_prev_char_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_prev_char_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_prev_line.py b/src/fenrirscreenreader/commands/commands/review_prev_line.py index ab25c35e..600fd171 100644 --- a/src/fenrirscreenreader/commands/commands/review_prev_line.py +++ b/src/fenrirscreenreader/commands/commands/review_prev_line.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_prev_word.py b/src/fenrirscreenreader/commands/commands/review_prev_word.py index 54ca1dfb..a785eb1d 100644 --- a/src/fenrirscreenreader/commands/commands/review_prev_word.py +++ b/src/fenrirscreenreader/commands/commands/review_prev_word.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_prev_word_phonetic.py b/src/fenrirscreenreader/commands/commands/review_prev_word_phonetic.py index d2222267..96f27f80 100644 --- a/src/fenrirscreenreader/commands/commands/review_prev_word_phonetic.py +++ b/src/fenrirscreenreader/commands/commands/review_prev_word_phonetic.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils from fenrirscreenreader.utils import char_utils diff --git a/src/fenrirscreenreader/commands/commands/review_screen_first_char.py b/src/fenrirscreenreader/commands/commands/review_screen_first_char.py index 74246d11..4bbc4554 100644 --- a/src/fenrirscreenreader/commands/commands/review_screen_first_char.py +++ b/src/fenrirscreenreader/commands/commands/review_screen_first_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -23,7 +22,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], lastChar = \ char_utils.getLastCharInLine(self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, lastChar, interrupt=True, announceCapital=True, flush=False) self.env['runtime']['outputManager'].presentText(_("first character in screen"), interrupt=False) def setCallback(self, callback): diff --git a/src/fenrirscreenreader/commands/commands/review_screen_last_char.py b/src/fenrirscreenreader/commands/commands/review_screen_last_char.py index 0c4fa1f0..afec3477 100644 --- a/src/fenrirscreenreader/commands/commands/review_screen_last_char.py +++ b/src/fenrirscreenreader/commands/commands/review_screen_last_char.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): @@ -23,7 +22,7 @@ class command(): self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], lastChar = \ char_utils.getLastCharInLine(self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) - self.env['runtime']['outputManager'].presentText(lastChar ,interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) + char_utils.presentCharForReview(self.env, lastChar, interrupt=True, announceCapital=True, flush=False) self.env['runtime']['outputManager'].presentText(_("last character in screen"), interrupt=False) def setCallback(self, callback): diff --git a/src/fenrirscreenreader/commands/commands/review_top.py b/src/fenrirscreenreader/commands/commands/review_top.py index f8fbca94..b3778e92 100644 --- a/src/fenrirscreenreader/commands/commands/review_top.py +++ b/src/fenrirscreenreader/commands/commands/review_top.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/review_up.py b/src/fenrirscreenreader/commands/commands/review_up.py index d6e05b9a..9788cb09 100644 --- a/src/fenrirscreenreader/commands/commands/review_up.py +++ b/src/fenrirscreenreader/commands/commands/review_up.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils class command(): diff --git a/src/fenrirscreenreader/commands/commands/save_settings.py b/src/fenrirscreenreader/commands/commands/save_settings.py index 279128dc..9f6ae177 100644 --- a/src/fenrirscreenreader/commands/commands/save_settings.py +++ b/src/fenrirscreenreader/commands/commands/save_settings.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.core import settingsManager class command(): diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_1.py b/src/fenrirscreenreader/commands/commands/set_bookmark_1.py index 11042676..333962b8 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_1.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_1.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '1' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(1, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_10.py b/src/fenrirscreenreader/commands/commands/set_bookmark_10.py index 6e10e5c5..499c1d4f 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_10.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_10.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '10' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(10, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_2.py b/src/fenrirscreenreader/commands/commands/set_bookmark_2.py index ca90680e..826a093a 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_2.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_2.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '2' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(2, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_3.py b/src/fenrirscreenreader/commands/commands/set_bookmark_3.py index a2e646f1..d87f444e 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_3.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_3.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '3' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(3, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_4.py b/src/fenrirscreenreader/commands/commands/set_bookmark_4.py index 2b1262ba..fe2c1f83 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_4.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_4.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '4' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(4, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_5.py b/src/fenrirscreenreader/commands/commands/set_bookmark_5.py index 5f03f4e6..efa41d0d 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_5.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_5.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '5' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(5, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_6.py b/src/fenrirscreenreader/commands/commands/set_bookmark_6.py index 90c9b2d1..e5998745 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_6.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_6.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '6' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(6, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_7.py b/src/fenrirscreenreader/commands/commands/set_bookmark_7.py index 0ff6e83d..f31fd689 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_7.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_7.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '7' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(7, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_8.py b/src/fenrirscreenreader/commands/commands/set_bookmark_8.py index 78c4532a..dcdb9ce9 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_8.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_8.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '8' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(8, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_bookmark_9.py b/src/fenrirscreenreader/commands/commands/set_bookmark_9.py index 371b1ee8..30b67ed2 100644 --- a/src/fenrirscreenreader/commands/commands/set_bookmark_9.py +++ b/src/fenrirscreenreader/commands/commands/set_bookmark_9.py @@ -4,33 +4,14 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import os +import importlib.util +_base_path = os.path.join(os.path.dirname(__file__), 'bookmark_base.py') +_spec = importlib.util.spec_from_file_location("bookmark_base", _base_path) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +BookmarkCommand = _module.BookmarkCommand -class command(): +class command(BookmarkCommand): def __init__(self): - self.ID = '9' - def initialize(self, environment): - self.env = environment - self.env['commandBuffer']['bookMarks'][self.ID] = {} - def shutdown(self): - pass - def getDescription(self): - return _('set Bookmark {0}').format(self.ID,) - - def run(self): - if not self.env['commandBuffer']['Marks']['1']: - self.env['runtime']['outputManager'].presentText(_("No mark found"), interrupt=True) - return - currApp = self.env['runtime']['applicationManager'].getCurrentApplication() - self.env['commandBuffer']['bookMarks'][self.ID][currApp] = {} - - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() - if self.env['commandBuffer']['Marks']['2']: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() - else: - self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'] = None - self.env['runtime']['outputManager'].presentText(_('Bookmark {0} set for application {1}').format(self.ID, currApp), interrupt=True) - self.env['commandBuffer']['Marks']['1'] = None - self.env['commandBuffer']['Marks']['2'] = None - def setCallback(self, callback): - pass + super().__init__(9, 'set') diff --git a/src/fenrirscreenreader/commands/commands/set_mark.py b/src/fenrirscreenreader/commands/commands/set_mark.py index e7b69105..2d22ae2a 100644 --- a/src/fenrirscreenreader/commands/commands/set_mark.py +++ b/src/fenrirscreenreader/commands/commands/set_mark.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/set_window_application.py b/src/fenrirscreenreader/commands/commands/set_window_application.py index a958ee24..bcc3f920 100644 --- a/src/fenrirscreenreader/commands/commands/set_window_application.py +++ b/src/fenrirscreenreader/commands/commands/set_window_application.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/shut_up.py b/src/fenrirscreenreader/commands/commands/shut_up.py index 169db793..1a5aa4b2 100644 --- a/src/fenrirscreenreader/commands/commands/shut_up.py +++ b/src/fenrirscreenreader/commands/commands/shut_up.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/silence_until_prompt.py b/src/fenrirscreenreader/commands/commands/silence_until_prompt.py index 4c9008cf..e9eb7607 100644 --- a/src/fenrirscreenreader/commands/commands/silence_until_prompt.py +++ b/src/fenrirscreenreader/commands/commands/silence_until_prompt.py @@ -74,12 +74,37 @@ class command(): # Add default shell prompt patterns promptPatterns.extend([ - r'^\s*\\\$\s*$', # Just $ (with whitespace) + r'^\s*\$\s*$', # Just $ (with whitespace) r'^\s*#\s*$', # Just # (with whitespace) r'^\s*>\s*$', # Just > (with whitespace) r'.*@.*[\\\$#>]\s*$', # Contains @ and ends with prompt char (user@host style) r'^\[.*\]\s*[\\\$#>]\s*$', # [anything]$ style prompts r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # Simple shell names like bash-5.1$ + + # Interactive prompt patterns + # Package manager confirmation prompts + r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style + r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style + r'.*\?\s*\([YyNn]/[YyNn]\)\s*$', # ? (Y/n) or ? (y/N) style + r'.*\?\s*\([Yy]es/[Nn]o\)\s*$', # ? (Yes/No) style + r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style + r'.*ok\s*\[[YyNn]/[YyNn]\].*$', # "Is this ok [y/N]:" style + r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman ":: Proceed? [Y/n]" style + + # Authentication prompts + r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password for user: + r'^[Pp]assword\s*:\s*$', # Password: + r'.*[Pp]assword\s*:\s*$', # general password prompts + r".*'s\s*[Pp]assword\s*:\s*$", # user's password: + r'^[Ee]nter\s+[Pp]assphrase.*:\s*$', # Enter passphrase: + r'^[Pp]lease\s+enter\s+[Pp]assphrase.*:\s*$', # Please enter passphrase: + + # General confirmation and continuation prompts + r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key to continue + r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure? + r'^[Pp]lease\s+confirm.*$', # Please confirm + r'.*confirm.*\([YyNn]/[YyNn]\).*$', # confirm (y/n) + r'.*\([Yy]/[Nn]\)\s*$', # ends with (Y/n) or (y/N) ]) for pattern in promptPatterns: diff --git a/src/fenrirscreenreader/commands/commands/spell_check.py b/src/fenrirscreenreader/commands/commands/spell_check.py index 87d5eeca..df4191e7 100644 --- a/src/fenrirscreenreader/commands/commands/spell_check.py +++ b/src/fenrirscreenreader/commands/commands/spell_check.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils initialized = False try: diff --git a/src/fenrirscreenreader/commands/commands/subprocess.py b/src/fenrirscreenreader/commands/commands/subprocess.py index f23340ef..052923a0 100644 --- a/src/fenrirscreenreader/commands/commands/subprocess.py +++ b/src/fenrirscreenreader/commands/commands/subprocess.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import subprocess, os from subprocess import Popen, PIPE import _thread diff --git a/src/fenrirscreenreader/commands/commands/temp_disable_speech.py b/src/fenrirscreenreader/commands/commands/temp_disable_speech.py index bbd863d4..6af2e32d 100644 --- a/src/fenrirscreenreader/commands/commands/temp_disable_speech.py +++ b/src/fenrirscreenreader/commands/commands/temp_disable_speech.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/time.py b/src/fenrirscreenreader/commands/commands/time.py index cb532e92..96b15b88 100644 --- a/src/fenrirscreenreader/commands/commands/time.py +++ b/src/fenrirscreenreader/commands/commands/time.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/commands/toggle_auto_indent.py b/src/fenrirscreenreader/commands/commands/toggle_auto_indent.py index 869c6400..7d32187c 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_auto_indent.py +++ b/src/fenrirscreenreader/commands/commands/toggle_auto_indent.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_auto_read.py b/src/fenrirscreenreader/commands/commands/toggle_auto_read.py index b9f4d0ae..b62eda2e 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_auto_read.py +++ b/src/fenrirscreenreader/commands/commands/toggle_auto_read.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_auto_spell_check.py b/src/fenrirscreenreader/commands/commands/toggle_auto_spell_check.py index 548ad908..622874fb 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_auto_spell_check.py +++ b/src/fenrirscreenreader/commands/commands/toggle_auto_spell_check.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/toggle_auto_time.py b/src/fenrirscreenreader/commands/commands/toggle_auto_time.py index 7cfeb952..01ce0f41 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_auto_time.py +++ b/src/fenrirscreenreader/commands/commands/toggle_auto_time.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_barrier.py b/src/fenrirscreenreader/commands/commands/toggle_barrier.py index 141eb93a..c0f8720a 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_barrier.py +++ b/src/fenrirscreenreader/commands/commands/toggle_barrier.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_emoticons.py b/src/fenrirscreenreader/commands/commands/toggle_emoticons.py index 518a19d2..967976cf 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_emoticons.py +++ b/src/fenrirscreenreader/commands/commands/toggle_emoticons.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py b/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py index 63714a11..b9eb7ea3 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py +++ b/src/fenrirscreenreader/commands/commands/toggle_has_attribute.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_highlight_tracking.py b/src/fenrirscreenreader/commands/commands/toggle_highlight_tracking.py index e2733355..e2782c4d 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_highlight_tracking.py +++ b/src/fenrirscreenreader/commands/commands/toggle_highlight_tracking.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_output.py b/src/fenrirscreenreader/commands/commands/toggle_output.py index 7ed8f5e6..f932fcd2 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_output.py +++ b/src/fenrirscreenreader/commands/commands/toggle_output.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/toggle_punctuation_level.py b/src/fenrirscreenreader/commands/commands/toggle_punctuation_level.py index 24c5b0eb..7721e401 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_punctuation_level.py +++ b/src/fenrirscreenreader/commands/commands/toggle_punctuation_level.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/toggle_sound.py b/src/fenrirscreenreader/commands/commands/toggle_sound.py index a176d326..41097d17 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_sound.py +++ b/src/fenrirscreenreader/commands/commands/toggle_sound.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/commands/toggle_speech.py b/src/fenrirscreenreader/commands/commands/toggle_speech.py index fc918825..c58e9d21 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_speech.py +++ b/src/fenrirscreenreader/commands/commands/toggle_speech.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/toggle_tutorial_mode.py b/src/fenrirscreenreader/commands/commands/toggle_tutorial_mode.py index b2e45407..9c98f4ba 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_tutorial_mode.py +++ b/src/fenrirscreenreader/commands/commands/toggle_tutorial_mode.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py b/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py index 4af3a72a..89cdf81d 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py +++ b/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/help/curr_help.py b/src/fenrirscreenreader/commands/help/curr_help.py index 281985ff..3586c63d 100644 --- a/src/fenrirscreenreader/commands/help/curr_help.py +++ b/src/fenrirscreenreader/commands/help/curr_help.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/help/next_help.py b/src/fenrirscreenreader/commands/help/next_help.py index 46e0f2e9..3e4819b2 100644 --- a/src/fenrirscreenreader/commands/help/next_help.py +++ b/src/fenrirscreenreader/commands/help/next_help.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/help/prev_help.py b/src/fenrirscreenreader/commands/help/prev_help.py index 27550ec7..62ad1d98 100644 --- a/src/fenrirscreenreader/commands/help/prev_help.py +++ b/src/fenrirscreenreader/commands/help/prev_help.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/onByteInput/10000-shut_up.py b/src/fenrirscreenreader/commands/onByteInput/10000-shut_up.py index 522ab94a..ef808a0f 100644 --- a/src/fenrirscreenreader/commands/onByteInput/10000-shut_up.py +++ b/src/fenrirscreenreader/commands/onByteInput/10000-shut_up.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onByteInput/15000-enable_temp_speech.py b/src/fenrirscreenreader/commands/onByteInput/15000-enable_temp_speech.py index f9d06a12..3aa0bd90 100644 --- a/src/fenrirscreenreader/commands/onByteInput/15000-enable_temp_speech.py +++ b/src/fenrirscreenreader/commands/onByteInput/15000-enable_temp_speech.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py b/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py index a53837dc..e940c6de 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py +++ b/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): @@ -48,7 +47,6 @@ class command(): currDelta.strip() != '': currDelta = currDelta.strip() self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - print(currDelta) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/onCursorChange/25000-word_echo_type.py b/src/fenrirscreenreader/commands/onCursorChange/25000-word_echo_type.py index 40054798..6a05cdef 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/25000-word_echo_type.py +++ b/src/fenrirscreenreader/commands/onCursorChange/25000-word_echo_type.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils import string diff --git a/src/fenrirscreenreader/commands/onCursorChange/35000-spell_check.py b/src/fenrirscreenreader/commands/onCursorChange/35000-spell_check.py index 0898a391..6f9b433a 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/35000-spell_check.py +++ b/src/fenrirscreenreader/commands/onCursorChange/35000-spell_check.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils import os, string diff --git a/src/fenrirscreenreader/commands/onCursorChange/45000-char_delete_echo.py b/src/fenrirscreenreader/commands/onCursorChange/45000-char_delete_echo.py index 7d342703..41feec75 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/45000-char_delete_echo.py +++ b/src/fenrirscreenreader/commands/onCursorChange/45000-char_delete_echo.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): 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 1fda1301..a6609ea5 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 @@ -4,8 +4,8 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import char_utils +from fenrirscreenreader.utils import word_utils class command(): def __init__(self): @@ -44,7 +44,13 @@ class command(): if self.env['screen']['newCursor']['x'] == x: return x, y, currChar = char_utils.getCurrentChar(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if not currChar.isspace(): + if currChar.isspace(): + # Only announce spaces during pure navigation (arrow keys) + # Check if this is really navigation by looking at input history + if (self.env['runtime']['inputManager'].getShortcutType() in ['KEY'] and + self.env['runtime']['inputManager'].getLastDeepestInput()[0] in ['KEY_LEFT', 'KEY_RIGHT', 'KEY_UP', 'KEY_DOWN']): + char_utils.presentCharForReview(self.env, currChar, interrupt=True, announceCapital=True, flush=False) + else: self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py index fd2b9353..b980c78e 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py +++ b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py b/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py index 9f52829d..d108c1cd 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py +++ b/src/fenrirscreenreader/commands/onCursorChange/60000-word_echo_navigation.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import word_utils import string 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 baaf189d..057ffe27 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 @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils from fenrirscreenreader.utils import word_utils diff --git a/src/fenrirscreenreader/commands/onCursorChange/68000-auto_identation_horizontal.py b/src/fenrirscreenreader/commands/onCursorChange/68000-auto_identation_horizontal.py index ea80ee0e..49d9e50c 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/68000-auto_identation_horizontal.py +++ b/src/fenrirscreenreader/commands/onCursorChange/68000-auto_identation_horizontal.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import line_utils from fenrirscreenreader.utils import word_utils diff --git a/src/fenrirscreenreader/commands/onCursorChange/85000-has_attribute.py b/src/fenrirscreenreader/commands/onCursorChange/85000-has_attribute.py index b7be5074..c7e9eed0 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/85000-has_attribute.py +++ b/src/fenrirscreenreader/commands/onCursorChange/85000-has_attribute.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug from fenrirscreenreader.utils import screen_utils class command(): diff --git a/src/fenrirscreenreader/commands/onCursorChange/95000-exit_review_mode.py b/src/fenrirscreenreader/commands/onCursorChange/95000-exit_review_mode.py index b9d095d9..bde418da 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/95000-exit_review_mode.py +++ b/src/fenrirscreenreader/commands/onCursorChange/95000-exit_review_mode.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/45000-char_echo.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/45000-char_echo.py deleted file mode 100644 index 96ecc656..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/45000-char_echo.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now) - xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) - if xMove > 1: - return - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'): - return - # detect deletion or chilling - if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']: - return - # is there any change? - if not self.env['runtime']['screenManager'].isDelta(): - return - - # filter unneded space on word begin - currDelta = self.env['screen']['newDelta'] - if len(currDelta.strip()) != len(currDelta) and \ - currDelta.strip() != '': - currDelta = currDelta.strip() - self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/46000-tab_completion.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/46000-tab_completion.py deleted file mode 100644 index 46ecb33d..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/46000-tab_completion.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # try to detect the tab completion by cursor change - xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) - if xMove == 1: - return - # is there any change? - if not self.env['runtime']['screenManager'].isDelta(): - return - if not( (xMove > 1) and xMove == len(self.env['screen']['newDelta'])): - return - # detect deletion or chilling - if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']: - return - - # filter unneded space on word begin - currDelta = self.env['screen']['newDelta'] - if len(currDelta.strip()) != len(currDelta) and \ - currDelta.strip() != '': - currDelta = currDelta.strip() - self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, announceCapital=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/50000-present_char_if_cursor_change_horizontal.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/50000-present_char_if_cursor_change_horizontal.py deleted file mode 100644 index 1fda1301..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/50000-present_char_if_cursor_change_horizontal.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import char_utils - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return '' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): - return - if self.env['runtime']['screenManager'].isScreenChange(): - return - # detect an change on the screen, we just want to cursor arround, so no change should appear - if self.env['runtime']['screenManager'].isDelta(): - return - if self.env['runtime']['screenManager'].isNegativeDelta(): - return - # is a vertical change? - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # is it a horizontal change? - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - - # echo word insteed of char - if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): - if abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) != 1: - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - if self.env['screen']['newCursor']['x'] == x: - return - x, y, currChar = char_utils.getCurrentChar(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if not currChar.isspace(): - self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/55000-present_line_if_cursor_change_vertical.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/55000-present_line_if_cursor_change_vertical.py deleted file mode 100644 index 7d0bb794..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/55000-present_line_if_cursor_change_vertical.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import line_utils -from fenrirscreenreader.utils import word_utils - -class command(): - def __init__(self): - self.lastIdent = -1 - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return '' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): - return - if self.env['runtime']['screenManager'].isScreenChange(): - self.lastIdent = 0 - return - # this leads to problems in vim -> status line change -> no announcement, so we do check the lengh as hack - if self.env['runtime']['screenManager'].isDelta(): - return - - # is a vertical change? - if not self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - - x, y, currLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if currLine.isspace(): - self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False) - else: - # ident - currIdent = len(currLine) - len(currLine.lstrip()) - if self.lastIdent == -1: - self.lastIdent = currIdent - doInterrupt = True - if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'): - if self.lastIdent != currIdent: - self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False) - doInterrupt = False - # barrier - sayLine = currLine - if self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): - isBarrier, barrierLine = self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) - if isBarrier: - sayLine = barrierLine - # output - self.env['runtime']['outputManager'].presentText(sayLine, interrupt=doInterrupt, flush=False) - self.lastIdent = currIdent - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/60000-word_echo_type.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/60000-word_echo_type.py deleted file mode 100644 index 40054798..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/60000-word_echo_type.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import string - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # is it enabled? - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): - return - # is naviation? - if self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] != 1: - return - # just when cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # currently writing - if self.env['runtime']['screenManager'].isDelta(): - return - - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - - # is there a word? - if currWord == '': - return - # at the end of a word - if not newContent[self.env['screen']['newCursor']['x']].isspace(): - return - # at the end of a word - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (x + len(currWord) != self.env['screen']['newCursor']['x']-1): - return - - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/61000-word_echo_navigation.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/61000-word_echo_navigation.py deleted file mode 100644 index 9f52829d..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/61000-word_echo_navigation.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import string - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # is navigation? - if not abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) > 1: - return - - # just when cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # currently writing - if self.env['runtime']['screenManager'].isDelta(): - return - - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - - # is there a word? - if currWord == '': - return - - # at the start of a word - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (self.env['screen']['newCursor']['x'] != x): - return - - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/62000-spell_check.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/62000-spell_check.py deleted file mode 100644 index 0898a391..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/62000-spell_check.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import os, string - -initialized = False -try: - import enchant - initialized = True -except: - pass - -class command(): - def __init__(self): - self.language = '' - self.spellChecker = '' - def initialize(self, environment): - self.env = environment - self.updateSpellLanguage() - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def updateSpellLanguage(self): - if not initialized: - return - self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')) - self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') - - def run(self): - if not initialized: - return - if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'): - return - if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: - try: - self.updateSpellLanguage() - except: - return - - # just when horizontal cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # more than a keyecho? - if len(self.env['screen']['newDelta']) > 1: - return - # deletion - if self.env['runtime']['screenManager'].isNegativeDelta(): - return - # first place could not be the end of a word - if self.env['screen']['newCursor']['x'] == 0: - return - - # get the word (just for speedup only look at current line - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - # was this a typed word? - if self.env['runtime']['screenManager'].isDelta(): - if not(newContent[self.env['screen']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']): - return - else: - currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~') - else: - # or just arrow arround? - if not newContent[self.env['screen']['newCursor']['x']].isspace(): - return - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (x + len(currWord) != self.env['screen']['newCursor']['x']-1): - return - - # just on end of word - if self.env['screen']['newCursor']['x'] > 0: - if not newContent[self.env['screen']['oldCursor']['x'] - 1].lower() in string.ascii_lowercase: - return - - # ignore bash buildins - if currWord in ['cd','fg','bg','alias','bind','dir','caller','buildin','command','declare','echo','enable','help','let','local','logout',\ - 'mapfile','printf','read','readarray','source','type','typeset','ulimit','unalias']: - return - # ignore the application name - if currWord.upper() == 'FENRIR': - return - if currWord[0] =='-': - return - if currWord[0] == '/': - return - if currWord[0] == '#': - return - if currWord.startswith('./'): - return - if '@' in currWord and '.' in currWord: - return - if currWord[0] == '@': - return - if currWord.isnumeric(): - return - if currWord.isdecimal(): - return - if currWord.isspace(): - return - - try: - if os.path.exists("/bin/"+currWord): - return - except: - pass - try: - if os.path.exists("/usr/bin/"+currWord): - return - except: - pass - try: - if os.path.exists("/sbin/"+currWord): - return - except: - pass - - if not self.spellChecker.check(currWord): - self.env['runtime']['outputManager'].presentText(_('misspelled'), soundIcon='mispell', interrupt=False, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/65000-char_delete_echo.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/65000-char_delete_echo.py deleted file mode 100644 index 7d342703..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/65000-char_delete_echo.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'): - return - # detect typing or chilling - if self.env['screen']['newCursor']['x'] >= self.env['screen']['oldCursor']['x']: - return - - # More than just a deletion happend - if self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): - return - - # no deletion - if not self.env['runtime']['screenManager'].isNegativeDelta(): - return - - # too much for a single backspace... - # word begin produce a diff wiht len == 2 |a | others with 1 |a| - if len(self.env['screen']['newNegativeDelta']) > 2: - return - - currNegativeDelta = self.env['screen']['newNegativeDelta'] - if len(currNegativeDelta.strip()) != len(currNegativeDelta) and \ - currNegativeDelta.strip() != '': - currNegativeDelta = currNegativeDelta.strip() - self.env['runtime']['outputManager'].presentText(currNegativeDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/66000-exit_review_mode.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/66000-exit_review_mode.py deleted file mode 100644 index b9d095d9..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/66000-exit_review_mode.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('exits review mode') - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnCursorChange'): - return - if self.env['runtime']['cursorManager'].isReviewMode(): - self.env['runtime']['cursorManager'].clearReviewCursor() - - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/77000-has_attribute.py b/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/77000-has_attribute.py deleted file mode 100644 index b7be5074..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/orig_sorting/77000-has_attribute.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import screen_utils - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Reads attributes of current cursor position') - def run(self): - # is it enabled? - if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'): - return - # is a vertical change? - if not (self.env['runtime']['cursorManager'].isCursorVerticalMove() or\ - self.env['runtime']['cursorManager'].isCursorHorizontalMove()): - return - - cursorPos = self.env['screen']['newCursor'] - - if not self.env['runtime']['attributeManager'].hasAttributes(cursorPos): - return - self.env['runtime']['outputManager'].presentText('has attribute', soundIcon='HasAttributes', interrupt=False) - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/15000-char_echo.py b/src/fenrirscreenreader/commands/onCursorChange/resort/15000-char_echo.py deleted file mode 100644 index 96ecc656..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/15000-char_echo.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now) - xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) - if xMove > 1: - return - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'): - return - # detect deletion or chilling - if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']: - return - # is there any change? - if not self.env['runtime']['screenManager'].isDelta(): - return - - # filter unneded space on word begin - currDelta = self.env['screen']['newDelta'] - if len(currDelta.strip()) != len(currDelta) and \ - currDelta.strip() != '': - currDelta = currDelta.strip() - self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/25000-word_echo_type.py b/src/fenrirscreenreader/commands/onCursorChange/resort/25000-word_echo_type.py deleted file mode 100644 index 40054798..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/25000-word_echo_type.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import string - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # is it enabled? - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): - return - # is naviation? - if self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] != 1: - return - # just when cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # currently writing - if self.env['runtime']['screenManager'].isDelta(): - return - - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - - # is there a word? - if currWord == '': - return - # at the end of a word - if not newContent[self.env['screen']['newCursor']['x']].isspace(): - return - # at the end of a word - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (x + len(currWord) != self.env['screen']['newCursor']['x']-1): - return - - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/35000-spell_check.py b/src/fenrirscreenreader/commands/onCursorChange/resort/35000-spell_check.py deleted file mode 100644 index 0898a391..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/35000-spell_check.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import os, string - -initialized = False -try: - import enchant - initialized = True -except: - pass - -class command(): - def __init__(self): - self.language = '' - self.spellChecker = '' - def initialize(self, environment): - self.env = environment - self.updateSpellLanguage() - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def updateSpellLanguage(self): - if not initialized: - return - self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')) - self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') - - def run(self): - if not initialized: - return - if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'): - return - if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: - try: - self.updateSpellLanguage() - except: - return - - # just when horizontal cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # more than a keyecho? - if len(self.env['screen']['newDelta']) > 1: - return - # deletion - if self.env['runtime']['screenManager'].isNegativeDelta(): - return - # first place could not be the end of a word - if self.env['screen']['newCursor']['x'] == 0: - return - - # get the word (just for speedup only look at current line - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - # was this a typed word? - if self.env['runtime']['screenManager'].isDelta(): - if not(newContent[self.env['screen']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']): - return - else: - currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~') - else: - # or just arrow arround? - if not newContent[self.env['screen']['newCursor']['x']].isspace(): - return - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (x + len(currWord) != self.env['screen']['newCursor']['x']-1): - return - - # just on end of word - if self.env['screen']['newCursor']['x'] > 0: - if not newContent[self.env['screen']['oldCursor']['x'] - 1].lower() in string.ascii_lowercase: - return - - # ignore bash buildins - if currWord in ['cd','fg','bg','alias','bind','dir','caller','buildin','command','declare','echo','enable','help','let','local','logout',\ - 'mapfile','printf','read','readarray','source','type','typeset','ulimit','unalias']: - return - # ignore the application name - if currWord.upper() == 'FENRIR': - return - if currWord[0] =='-': - return - if currWord[0] == '/': - return - if currWord[0] == '#': - return - if currWord.startswith('./'): - return - if '@' in currWord and '.' in currWord: - return - if currWord[0] == '@': - return - if currWord.isnumeric(): - return - if currWord.isdecimal(): - return - if currWord.isspace(): - return - - try: - if os.path.exists("/bin/"+currWord): - return - except: - pass - try: - if os.path.exists("/usr/bin/"+currWord): - return - except: - pass - try: - if os.path.exists("/sbin/"+currWord): - return - except: - pass - - if not self.spellChecker.check(currWord): - self.env['runtime']['outputManager'].presentText(_('misspelled'), soundIcon='mispell', interrupt=False, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/45000-char_delete_echo.py b/src/fenrirscreenreader/commands/onCursorChange/resort/45000-char_delete_echo.py deleted file mode 100644 index 7d342703..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/45000-char_delete_echo.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'): - return - # detect typing or chilling - if self.env['screen']['newCursor']['x'] >= self.env['screen']['oldCursor']['x']: - return - - # More than just a deletion happend - if self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): - return - - # no deletion - if not self.env['runtime']['screenManager'].isNegativeDelta(): - return - - # too much for a single backspace... - # word begin produce a diff wiht len == 2 |a | others with 1 |a| - if len(self.env['screen']['newNegativeDelta']) > 2: - return - - currNegativeDelta = self.env['screen']['newNegativeDelta'] - if len(currNegativeDelta.strip()) != len(currNegativeDelta) and \ - currNegativeDelta.strip() != '': - currNegativeDelta = currNegativeDelta.strip() - self.env['runtime']['outputManager'].presentText(currNegativeDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/50000-present_char_if_cursor_change_horizontal.py b/src/fenrirscreenreader/commands/onCursorChange/resort/50000-present_char_if_cursor_change_horizontal.py deleted file mode 100644 index 1fda1301..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/50000-present_char_if_cursor_change_horizontal.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import char_utils - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return '' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): - return - if self.env['runtime']['screenManager'].isScreenChange(): - return - # detect an change on the screen, we just want to cursor arround, so no change should appear - if self.env['runtime']['screenManager'].isDelta(): - return - if self.env['runtime']['screenManager'].isNegativeDelta(): - return - # is a vertical change? - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # is it a horizontal change? - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - - # echo word insteed of char - if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): - if abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) != 1: - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - if self.env['screen']['newCursor']['x'] == x: - return - x, y, currChar = char_utils.getCurrentChar(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if not currChar.isspace(): - self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False) - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/55000-tab_completion.py b/src/fenrirscreenreader/commands/onCursorChange/resort/55000-tab_completion.py deleted file mode 100644 index 46ecb33d..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/55000-tab_completion.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # try to detect the tab completion by cursor change - xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) - if xMove == 1: - return - # is there any change? - if not self.env['runtime']['screenManager'].isDelta(): - return - if not( (xMove > 1) and xMove == len(self.env['screen']['newDelta'])): - return - # detect deletion or chilling - if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']: - return - - # filter unneded space on word begin - currDelta = self.env['screen']['newDelta'] - if len(currDelta.strip()) != len(currDelta) and \ - currDelta.strip() != '': - currDelta = currDelta.strip() - self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, announceCapital=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/60000-word_echo_navigation.py b/src/fenrirscreenreader/commands/onCursorChange/resort/60000-word_echo_navigation.py deleted file mode 100644 index 9f52829d..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/60000-word_echo_navigation.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import word_utils -import string - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - # is navigation? - if not abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) > 1: - return - - # just when cursor move worddetection is needed - if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): - return - # for now no new line - if self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - # currently writing - if self.env['runtime']['screenManager'].isDelta(): - return - - # get the word - newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] - x, y, currWord, endOfScreen, lineBreak = \ - word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) - - # is there a word? - if currWord == '': - return - - # at the start of a word - if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ - (self.env['screen']['newCursor']['x'] != x): - return - - self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/65000-present_line_if_cursor_change_vertical.py b/src/fenrirscreenreader/commands/onCursorChange/resort/65000-present_line_if_cursor_change_vertical.py deleted file mode 100644 index 7d0bb794..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/65000-present_line_if_cursor_change_vertical.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import line_utils -from fenrirscreenreader.utils import word_utils - -class command(): - def __init__(self): - self.lastIdent = -1 - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return '' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): - return - if self.env['runtime']['screenManager'].isScreenChange(): - self.lastIdent = 0 - return - # this leads to problems in vim -> status line change -> no announcement, so we do check the lengh as hack - if self.env['runtime']['screenManager'].isDelta(): - return - - # is a vertical change? - if not self.env['runtime']['cursorManager'].isCursorVerticalMove(): - return - - x, y, currLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText']) - if currLine.isspace(): - self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False) - else: - # ident - currIdent = len(currLine) - len(currLine.lstrip()) - if self.lastIdent == -1: - self.lastIdent = currIdent - doInterrupt = True - if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'): - if self.lastIdent != currIdent: - self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False) - doInterrupt = False - # barrier - sayLine = currLine - if self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): - isBarrier, barrierLine = self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) - if isBarrier: - sayLine = barrierLine - # output - self.env['runtime']['outputManager'].presentText(sayLine, interrupt=doInterrupt, flush=False) - self.lastIdent = currIdent - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/85000-has_attribute.py b/src/fenrirscreenreader/commands/onCursorChange/resort/85000-has_attribute.py deleted file mode 100644 index b7be5074..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/85000-has_attribute.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -from fenrirscreenreader.utils import screen_utils - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('Reads attributes of current cursor position') - def run(self): - # is it enabled? - if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'): - return - # is a vertical change? - if not (self.env['runtime']['cursorManager'].isCursorVerticalMove() or\ - self.env['runtime']['cursorManager'].isCursorHorizontalMove()): - return - - cursorPos = self.env['screen']['newCursor'] - - if not self.env['runtime']['attributeManager'].hasAttributes(cursorPos): - return - self.env['runtime']['outputManager'].presentText('has attribute', soundIcon='HasAttributes', interrupt=False) - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onCursorChange/resort/95000-exit_review_mode.py b/src/fenrirscreenreader/commands/onCursorChange/resort/95000-exit_review_mode.py deleted file mode 100644 index b9d095d9..00000000 --- a/src/fenrirscreenreader/commands/onCursorChange/resort/95000-exit_review_mode.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('exits review mode') - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnCursorChange'): - return - if self.env['runtime']['cursorManager'].isReviewMode(): - self.env['runtime']['cursorManager'].clearReviewCursor() - - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onHeartBeat/2000-GetSessionInfo.py b/src/fenrirscreenreader/commands/onHeartBeat/2000-GetSessionInfo.py index 2856db92..c986b0d9 100755 --- a/src/fenrirscreenreader/commands/onHeartBeat/2000-GetSessionInfo.py +++ b/src/fenrirscreenreader/commands/onHeartBeat/2000-GetSessionInfo.py @@ -5,7 +5,6 @@ import time # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import time import datetime diff --git a/src/fenrirscreenreader/commands/onHeartBeat/76000-time.py b/src/fenrirscreenreader/commands/onHeartBeat/76000-time.py index 6ed247b4..59537a44 100755 --- a/src/fenrirscreenreader/commands/onHeartBeat/76000-time.py +++ b/src/fenrirscreenreader/commands/onHeartBeat/76000-time.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import time import datetime diff --git a/src/fenrirscreenreader/commands/onHeartBeat/deactive/1.echo.py b/src/fenrirscreenreader/commands/onHeartBeat/deactive/1.echo.py deleted file mode 100755 index 95e6bbda..00000000 --- a/src/fenrirscreenreader/commands/onHeartBeat/deactive/1.echo.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -import time -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug -import time - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - print(time.time()) - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onKeyInput/10000-shut_up.py b/src/fenrirscreenreader/commands/onKeyInput/10000-shut_up.py index 522ab94a..71f0b1b1 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/10000-shut_up.py +++ b/src/fenrirscreenreader/commands/onKeyInput/10000-shut_up.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/onKeyInput/15000-enable_temp_speech.py b/src/fenrirscreenreader/commands/onKeyInput/15000-enable_temp_speech.py index 29d37937..20e662d3 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/15000-enable_temp_speech.py +++ b/src/fenrirscreenreader/commands/onKeyInput/15000-enable_temp_speech.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onKeyInput/80000-capslock.py b/src/fenrirscreenreader/commands/onKeyInput/80000-capslock.py index f3efeb69..6568b836 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/80000-capslock.py +++ b/src/fenrirscreenreader/commands/onKeyInput/80000-capslock.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onKeyInput/80300-scrolllock.py b/src/fenrirscreenreader/commands/onKeyInput/80300-scrolllock.py index c3d64946..752110ba 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/80300-scrolllock.py +++ b/src/fenrirscreenreader/commands/onKeyInput/80300-scrolllock.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onKeyInput/80500-numlock.py b/src/fenrirscreenreader/commands/onKeyInput/80500-numlock.py index 96e1348e..39b0fb92 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/80500-numlock.py +++ b/src/fenrirscreenreader/commands/onKeyInput/80500-numlock.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py b/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py index fca7437a..a5df3c4c 100644 --- a/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py +++ b/src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-plugSound.py b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-plugSound.py index 461eb2b5..853d36d4 100755 --- a/src/fenrirscreenreader/commands/onPlugInputDevice/50000-plugSound.py +++ b/src/fenrirscreenreader/commands/onPlugInputDevice/50000-plugSound.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import time class command(): diff --git a/src/fenrirscreenreader/commands/onScreenChanged/10000-shut_up.py b/src/fenrirscreenreader/commands/onScreenChanged/10000-shut_up.py index 82686368..e1e18141 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/10000-shut_up.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/10000-shut_up.py @@ -4,8 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/onScreenChanged/20000-reset_last_cursor_attribute.py b/src/fenrirscreenreader/commands/onScreenChanged/20000-reset_last_cursor_attribute.py index 352191a0..945bbe5c 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/20000-reset_last_cursor_attribute.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/20000-reset_last_cursor_attribute.py @@ -5,8 +5,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug - class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py b/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py index 6d9e8b21..2f4d51e4 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/21000-reset_barrier_change.py @@ -1,11 +1,9 @@ - #!/usr/bin/env python3 # -*- coding: utf-8 -*- # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py b/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py index ac5bf809..02a23b70 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/70000-barrier_detect.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenChanged/80000-screen_change_announcement.py b/src/fenrirscreenreader/commands/onScreenChanged/80000-screen_change_announcement.py index 6a8b4069..cbd60d48 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/80000-screen_change_announcement.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/80000-screen_change_announcement.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenChanged/85000-reset_marks.py b/src/fenrirscreenreader/commands/onScreenChanged/85000-reset_marks.py index 3c365a73..1cc55473 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/85000-reset_marks.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/85000-reset_marks.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenChanged/89000-leave_review_mode.py b/src/fenrirscreenreader/commands/onScreenChanged/89000-leave_review_mode.py index 51defaf6..505bbddf 100644 --- a/src/fenrirscreenreader/commands/onScreenChanged/89000-leave_review_mode.py +++ b/src/fenrirscreenreader/commands/onScreenChanged/89000-leave_review_mode.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py b/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py index b74acd31..5198ebd5 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): pass diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py index 6933b62f..fba8c870 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/65000-progress_detector.py b/src/fenrirscreenreader/commands/onScreenUpdate/65000-progress_detector.py index dcd51dda..c4bb7481 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/65000-progress_detector.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/65000-progress_detector.py @@ -23,8 +23,11 @@ class command(): # Only run if progress monitoring is enabled try: if 'progressMonitoring' in self.env['commandBuffer'] and self.env['commandBuffer']['progressMonitoring']: + # Check if current line is a prompt - if so, reset progress state + if self.isCurrentLinePrompt(): + self.resetProgressState() # Only check new incoming text (newDelta), but filter out screen changes - if self.env['screen']['newDelta'] and self.isRealProgressUpdate(): + elif self.env['screen']['newDelta'] and self.isRealProgressUpdate(): self.detectProgress(self.env['screen']['newDelta']) except Exception as e: # Silently ignore errors to avoid disrupting normal operation @@ -49,7 +52,17 @@ class command(): if deltaLength > 200: # Allow longer progress lines like Claude Code's status return False + # Check if current line looks like a prompt - progress unlikely during prompts + if self.isCurrentLinePrompt(): + return False + return True + + def resetProgressState(self): + """Reset progress state when a prompt is detected, allowing new progress operations to start fresh""" + self.env['runtime']['debug'].writeDebugOut("Resetting progress state due to prompt detection", debug.debugLevel.INFO) + self.env['commandBuffer']['lastProgressValue'] = -1 + self.env['commandBuffer']['lastProgressTime'] = 0 def detectProgress(self, text): import re @@ -106,11 +119,14 @@ class command(): return # Pattern 3: Progress bars ([#### ], [====> ], etc.) - barMatch = re.search(r'\[([#=\-\*]+)([^\]]*)\]', text) + # Improved pattern to avoid matching IRC channels like [#channel] + barMatch = re.search(r'\[([#=\-\*]+)([\s\.]*)\]', text) if barMatch: filled = len(barMatch.group(1)) - total = filled + len(barMatch.group(2)) - if total > 0: + unfilled = len(barMatch.group(2)) + total = filled + unfilled + # Require at least 2 progress chars total and unfilled portion must be spaces/dots + if total >= 2 and (not barMatch.group(2) or re.match(r'^[\s\.]*$', barMatch.group(2))): percentage = (filled / total) * 100 if percentage != self.env['commandBuffer']['lastProgressValue']: self.playProgressTone(percentage) @@ -152,7 +168,88 @@ class command(): subprocess.Popen(shlex.split(command), stdin=None, stdout=None, stderr=None, shell=False) except Exception as e: self.env['runtime']['debug'].writeDebugOut("Sox tone error: " + str(e), debug.debugLevel.ERROR) + + def isCurrentLinePrompt(self): + """Check if the current line looks like a standalone prompt (not command with progress)""" + import re + try: + # Get the current screen content + if not self.env['screen']['newContentText']: + return False + + lines = self.env['screen']['newContentText'].split('\n') + if not lines: + return False + + # Check the last line (most common) and current cursor line for prompt patterns + linesToCheck = [] + + # Add last line (most common for prompts) + if lines: + linesToCheck.append(lines[-1]) + + # Add current cursor line if different from last line + if (self.env['screen']['newCursor']['y'] < len(lines) and + self.env['screen']['newCursor']['y'] != len(lines) - 1): + linesToCheck.append(lines[self.env['screen']['newCursor']['y']]) + + # Standalone prompt patterns (no commands mixed in) + standalonePromptPatterns = [ + r'^\s*\$\s*$', # Just $ (with whitespace) + r'^\s*#\s*$', # Just # (with whitespace) + r'^\s*>\s*$', # Just > (with whitespace) + r'^\[.*\]\s*[\\\$#>]\s*$', # [path]$ without commands + r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # bash-5.1$ without commands + + # Interactive prompt patterns (these ARE standalone) + r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style + r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style + r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style + r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman style prompts + + # Authentication prompts (these ARE standalone) + r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password + r'^[Pp]assword\s*:\s*$', # Password: + r'.*[Pp]assword\s*:\s*$', # general password prompts + + # Continuation prompts (these ARE standalone) + r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key + r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure? + ] + + for line in linesToCheck: + line = line.strip() + if not line: + continue + + # Check if this line contains both a prompt AND other content (like commands) + # If so, don't treat it as a standalone prompt + hasPromptMarker = bool(re.search(r'.*@.*[\\\$#>]', line) or re.search(r'^\[.*\]\s*[\\\$#>]', line)) + if hasPromptMarker: + # If line has prompt marker but also has significant content after it, + # it's a command line, not a standalone prompt + promptEnd = max( + line.rfind('$'), + line.rfind('#'), + line.rfind('>'), + line.rfind('\\') + ) + if promptEnd >= 0 and promptEnd < len(line) - 5: # More than just whitespace after prompt + continue # This is a command line, not a standalone prompt + + for pattern in standalonePromptPatterns: + try: + if re.search(pattern, line): + return True + except re.error: + continue + + return False + + except Exception: + # If anything fails, assume it's not a prompt to be safe + return False def setCallback(self, callback): pass \ No newline at end of file diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/66000-prompt_detector.py b/src/fenrirscreenreader/commands/onScreenUpdate/66000-prompt_detector.py index d172ba8a..4944442e 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/66000-prompt_detector.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/66000-prompt_detector.py @@ -68,12 +68,37 @@ class command(): # Add default shell prompt patterns promptPatterns.extend([ - r'^\s*\\\$\s*$', # Just $ (with whitespace) + r'^\s*\$\s*$', # Just $ (with whitespace) r'^\s*#\s*$', # Just # (with whitespace) r'^\s*>\s*$', # Just > (with whitespace) r'.*@.*[\\\$#>]\s*$', # Contains @ and ends with prompt char (user@host style) r'^\[.*\]\s*[\\\$#>]\s*$', # [anything]$ style prompts r'^[a-zA-Z0-9._-]+[\\\$#>]\s*$', # Simple shell names like bash-5.1$ + + # Interactive prompt patterns + # Package manager confirmation prompts + r'.*\?\s*\[[YyNn]/[YyNn]\]\s*$', # ? [Y/n] or ? [y/N] style + r'.*\?\s*\[[Yy]es/[Nn]o\]\s*$', # ? [Yes/No] style + r'.*\?\s*\([YyNn]/[YyNn]\)\s*$', # ? (Y/n) or ? (y/N) style + r'.*\?\s*\([Yy]es/[Nn]o\)\s*$', # ? (Yes/No) style + r'.*continue\?\s*\[[YyNn]/[YyNn]\].*$', # "continue? [Y/n]" style + r'.*ok\s*\[[YyNn]/[YyNn]\].*$', # "Is this ok [y/N]:" style + r'^::.*\?\s*\[[YyNn]/[YyNn]\].*$', # pacman ":: Proceed? [Y/n]" style + + # Authentication prompts + r'^\[[Ss]udo\]\s*[Pp]assword\s*for\s+.*:\s*$', # [sudo] password for user: + r'^[Pp]assword\s*:\s*$', # Password: + r'.*[Pp]assword\s*:\s*$', # general password prompts + r".*'s\s*[Pp]assword\s*:\s*$", # user's password: + r'^[Ee]nter\s+[Pp]assphrase.*:\s*$', # Enter passphrase: + r'^[Pp]lease\s+enter\s+[Pp]assphrase.*:\s*$', # Please enter passphrase: + + # General confirmation and continuation prompts + r'^[Pp]ress\s+any\s+key\s+to\s+continue.*$', # Press any key to continue + r'^[Aa]re\s+you\s+sure\?\s*.*$', # Are you sure? + r'^[Pp]lease\s+confirm.*$', # Please confirm + r'.*confirm.*\([YyNn]/[YyNn]\).*$', # confirm (y/n) + r'.*\([Yy]/[Nn]\)\s*$', # ends with (Y/n) or (y/N) ]) for pattern in promptPatterns: diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py b/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py index 8ae69e2a..40ad22e3 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py b/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py index b6639b24..23f2864b 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py @@ -5,7 +5,6 @@ import time # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py index f2411814..3b516f8f 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/rework/70000-incoming.py b/src/fenrirscreenreader/commands/onScreenUpdate/rework/70000-incoming.py deleted file mode 100644 index a7ab0466..00000000 --- a/src/fenrirscreenreader/commands/onScreenUpdate/rework/70000-incoming.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No Description found' - - def run(self): - if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'autoReadIncoming'): - return - # is there something to read? - if not self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): - return - - # this must be a keyecho or something - #if len(self.env['screen']['newDelta'].strip(' \n\t')) <= 1: - xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) - yMove = abs(self.env['screen']['newCursor']['y'] - self.env['screen']['oldCursor']['y']) - #print('-----') - #print(self.env['screen']['newDelta']) - #print(xMove, yMove, len(self.env['screen']['newNegativeDelta']), self.env['screen']['newNegativeDelta']) - #print(xMove, yMove, len(self.env['screen']['newDelta']), self.env['screen']['newDelta']) - if (xMove >= 1) and abs(xMove) == len(self.env['screen']['newDelta']): - # if len(self.env['screen']['newDelta'].strip(' \n\t0123456789')) <= 2: - if not '\n' in self.env['screen']['newDelta']: - return - # shift line - if (xMove != 0) and len(self.env['screen']['newNegativeDelta']) == 0: - return - # filter out delete - if (xMove == 0) and (yMove == 0): - if len(self.env['screen']['newNegativeDelta']) - len(self.env['screen']['newDelta']) in [1,2,3]: - return - - self.env['runtime']['outputManager'].presentText(self.env['screen']['newDelta'], interrupt=False, flush=False) - - def setCallback(self, callback): - pass - diff --git a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/default.py b/src/fenrirscreenreader/commands/onSwitchApplicationProfile/default.py index b7680d59..764a2292 100644 --- a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/default.py +++ b/src/fenrirscreenreader/commands/onSwitchApplicationProfile/default.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/agetty.py b/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/agetty.py deleted file mode 100644 index 63c92e3f..00000000 --- a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/agetty.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No description found' - def load(self): - print('--------------') - print('agetty') - print('load new',self.env['screen']['newApplication']) - print('--------------') - - def unload(self): - print('--------------') - print('agetty') - print('unload old',self.env['screen']['oldApplication']) - print('--------------') - - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/bash.py b/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/bash.py deleted file mode 100644 index d16a5ef9..00000000 --- a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/bash.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No description found' - def load(self): - print('--------------') - print('bash') - print('load new',self.env['screen']['newApplication']) - print('--------------') - - def unload(self): - print('--------------') - print('bash') - print('unload old',self.env['screen']['oldApplication']) - print('--------------') - - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/vim.py b/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/vim.py deleted file mode 100644 index 5f29e148..00000000 --- a/src/fenrirscreenreader/commands/onSwitchApplicationProfile/inactive/vim.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from fenrirscreenreader.core import debug - -class command(): - def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return 'No description found' - def load(self): - print('--------------') - print('vim') - print('load new',self.env['screen']['newApplication']) - print('--------------') - - def unload(self): - print('--------------') - print('vim') - print('unload old',self.env['screen']['oldApplication']) - print('--------------') - - def setCallback(self, callback): - pass diff --git a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py index 0b21ad3c..a89ce3ee 100644 --- a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py index b9da1e0e..6522e080 100644 --- a/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/quickMenu/current_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py index e14fad03..1d2a5fb1 100644 --- a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py index ae15c51a..78a0f9ad 100644 --- a/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/quickMenu/next_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py index 329438b1..87aef5df 100644 --- a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py +++ b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py index 64495c68..bfa7e8cb 100644 --- a/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py +++ b/src/fenrirscreenreader/commands/quickMenu/prev_quick_menu_value.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/switchTrigger_template.py b/src/fenrirscreenreader/commands/switchTrigger_template.py index 4d1ee82d..f8c837ff 100644 --- a/src/fenrirscreenreader/commands/switchTrigger_template.py +++ b/src/fenrirscreenreader/commands/switchTrigger_template.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py index 22818bae..41787ef8 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py b/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py index 30996797..56fcd4ff 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py index cb5e65b4..6ec99f52 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py b/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py index e1d34c2f..f902dd00 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py index 1eda533c..8aa5b011 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py index 959ef702..32ee67c1 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_a.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_a.py index 5ff18daf..d4708630 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_a.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_a.py @@ -4,22 +4,8 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +from fenrirscreenreader.commands.vmenu_navigation.vmenu_search_base import VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('a') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('a') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_b.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_b.py index 49ce995d..78575c33 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_b.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_b.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('b') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('b') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_c.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_c.py index 23073dfd..3b2733ac 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_c.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_c.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('c') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('c') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_d.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_d.py index 2a94e067..08e46880 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_d.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_d.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('d') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('d') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_e.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_e.py index e650afa5..6591af03 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_e.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_e.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('e') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('e') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_f.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_f.py index 0d5e9059..2ec56cad 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_f.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_f.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('f') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('f') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_g.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_g.py index bc093abf..85efbb07 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_g.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_g.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('g') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('g') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_h.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_h.py index 675309d6..78751213 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_h.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_h.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('h') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('h') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_i.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_i.py index f416633a..050ae6e1 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_i.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_i.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('i') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('i') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_j.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_j.py index 07700fe7..a6389c10 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_j.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_j.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('j') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('j') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_k.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_k.py index 297c5f5d..121849d5 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_k.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_k.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('k') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('k') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_l.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_l.py index 65ea410a..a7c5e661 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_l.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_l.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('l') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('l') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_m.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_m.py index 3870ca0c..2c11eb16 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_m.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_m.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('m') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('m') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_n.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_n.py index 4b2f0b90..06c6c944 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_n.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_n.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('n') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('n') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_o.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_o.py index 1b24411a..5cf8ef4a 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_o.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_o.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('o') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('o') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_p.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_p.py index 2bee8e6b..b32fd29f 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_p.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_p.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('p') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('p') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_q.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_q.py index 0424e888..56844daa 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_q.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_q.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('q') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('q') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_r.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_r.py index a8beef51..61e9536b 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_r.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_r.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('r') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('r') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_s.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_s.py index 0b9a68c5..c0c9389b 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_s.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_s.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('s') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('s') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_t.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_t.py index a6caf217..318d4275 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_t.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_t.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('t') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('t') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_u.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_u.py index b7cc8513..66b2eb4a 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_u.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_u.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('u') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('u') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_v.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_v.py index 6fd4aaf4..3ce4be06 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_v.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_v.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('v') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('v') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_w.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_w.py index 5ff18daf..0c4639f3 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_w.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_w.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('a') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('w') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_x.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_x.py index c5fc2ba4..07b476ca 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_x.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_x.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('x') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('x') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_y.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_y.py index 4591bf83..81a2d4cf 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_y.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_y.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('y') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('y') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/search_z.py b/src/fenrirscreenreader/commands/vmenu-navigation/search_z.py index 01b5d143..bd1ed83f 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/search_z.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/search_z.py @@ -4,22 +4,13 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug +import importlib.util +import os +_spec = importlib.util.spec_from_file_location("vmenu_search_base", os.path.join(os.path.dirname(__file__), "vmenu_search_base.py")) +_module = importlib.util.module_from_spec(_spec) +_spec.loader.exec_module(_module) +VMenuSearchCommand = _module.VMenuSearchCommand -class command(): +class command(VMenuSearchCommand): def __init__(self): - pass - def initialize(self, environment): - self.env = environment - def shutdown(self): - pass - def getDescription(self): - return _('search for an menu entry') - def run(self): - text = self.env['runtime']['vmenuManager'].searchEntry('z') - if text != '': - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - else: - self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) - def setCallback(self, callback): - pass + super().__init__('z') diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/vmenu_search_base.py b/src/fenrirscreenreader/commands/vmenu-navigation/vmenu_search_base.py new file mode 100644 index 00000000..e3e8fafc --- /dev/null +++ b/src/fenrirscreenreader/commands/vmenu-navigation/vmenu_search_base.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +class VMenuSearchCommand(): + """Base class for VMenu search commands""" + def __init__(self, search_char): + self.search_char = search_char.lower() + + def initialize(self, environment): + self.env = environment + + def shutdown(self): + pass + + def getDescription(self): + return _('search for an menu entry') + + def run(self): + text = self.env['runtime']['vmenuManager'].searchEntry(self.search_char) + if text != '': + self.env['runtime']['outputManager'].presentText(text, interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(_('not found'), soundIcon='ErrorScreen', interrupt=True) + + def setCallback(self, callback): + pass \ No newline at end of file diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/open.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/open.py index e3bddc87..571f69c8 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/open.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/open.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/save.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/save.py index 0e9db029..d5d57e3c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/save.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/file/save.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/replace.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/replace.py index f2f001db..08e1e27a 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/replace.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/replace.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/search.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/search.py index 6da6f437..6862f01b 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/search.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/search.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/test.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/test.py index 3275d2f0..7a95ca1c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/test.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mc/search/test.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/issue.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/issue.py index 2fd16a90..3329ab3e 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/issue.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/issue.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/open.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/open.py index 081decbc..a7d9ceab 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/open.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/open.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/save.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/save.py index 0e9db029..d5d57e3c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/save.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/file/save.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/replace.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/replace.py index f2f001db..08e1e27a 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/replace.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/replace.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/search.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/search.py index 6da6f437..6862f01b 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/search.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/search.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/test.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/test.py index 3275d2f0..7a95ca1c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/test.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/mutt/search/test.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/Help/about_nano.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/Help/about_nano.py index a293a07e..f4e2bddb 100755 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/Help/about_nano.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/Help/about_nano.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- encoding: utf-8 -from fenrirscreenreader.core import debug class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/open.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/open.py index e3bddc87..571f69c8 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/open.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/open.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/save.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/save.py index 8a2f9221..879f01b7 100755 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/save.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/file/save.py @@ -1,6 +1,5 @@ #!/usr/bin/env python # -*- encoding: utf-8 -from fenrirscreenreader.core import debug class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/replace.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/replace.py index f2f001db..08e1e27a 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/replace.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/replace.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/search.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/search.py index 6da6f437..6862f01b 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/search.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/search.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/test.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/test.py index 3275d2f0..7a95ca1c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/test.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/nano/search/test.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/open.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/open.py index e3bddc87..571f69c8 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/open.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/open.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/save.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/save.py index 0e9db029..d5d57e3c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/save.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/file/save.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/replace.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/replace.py index f2f001db..08e1e27a 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/replace.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/replace.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/search.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/search.py index 6da6f437..6862f01b 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/search.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/search.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/test.py b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/test.py index 3275d2f0..7a95ca1c 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/test.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/KEY/vim/search/test.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug import datetime class command(): diff --git a/src/fenrirscreenreader/commands/vmenu-profiles/template.py b/src/fenrirscreenreader/commands/vmenu-profiles/template.py index 0f645761..922d5cc1 100644 --- a/src/fenrirscreenreader/commands/vmenu-profiles/template.py +++ b/src/fenrirscreenreader/commands/vmenu-profiles/template.py @@ -4,7 +4,6 @@ # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. -from fenrirscreenreader.core import debug class command(): def __init__(self): diff --git a/src/fenrirscreenreader/core/applicationManager.py b/src/fenrirscreenreader/core/applicationManager.py index bef73a90..b05fde9a 100644 --- a/src/fenrirscreenreader/core/applicationManager.py +++ b/src/fenrirscreenreader/core/applicationManager.py @@ -16,16 +16,16 @@ class applicationManager(): def getCurrentApplication(self): currApp = self.env['screen']['newApplication'].upper() if not currApp: - currApp == 'DEFAULT' + currApp = 'DEFAULT' if currApp == '': - currApp == 'DEFAULT' + currApp = 'DEFAULT' return currApp def getPrevApplication(self): prevApp = self.env['screen']['oldApplication'].upper() if not prevApp: - prevApp == 'DEFAULT' + prevApp = 'DEFAULT' if prevApp == '': - prevApp == 'DEFAULT' + prevApp = 'DEFAULT' return prevApp def isApplicationChange(self): return self.env['screen']['oldApplication'] != self.env['screen']['newApplication'] diff --git a/src/fenrirscreenreader/core/attributeManager.py b/src/fenrirscreenreader/core/attributeManager.py index 7578a080..b16992b7 100644 --- a/src/fenrirscreenreader/core/attributeManager.py +++ b/src/fenrirscreenreader/core/attributeManager.py @@ -233,57 +233,110 @@ class attributeManager(): return attributeFormatString def trackHighlights(self): + """ + Detects text with changed attributes (highlighting) between screen updates. + + This is crucial for screen readers to announce when text becomes highlighted, + selected, or changes visual emphasis (bold, reverse video, color changes, etc.) + + Returns: + tuple: (highlighted_text, cursor_position) + - highlighted_text: string of characters that gained highlighting + - cursor_position: dict {'x': col, 'y': row} of first highlighted char + """ result = '' currCursor = None - # screen change + + # Early exit conditions - no attribute comparison possible if self.prevAttributes == None: + # First screen load - no previous attributes to compare against return result, currCursor - # no change if self.prevAttributes == self.currAttributes: + # No attribute changes detected return result, currCursor - # error case if self.currAttributes == None: + # Error condition - current attributes missing return result, currCursor - # special case for pty if not text exists. if len(self.currAttributes) == 0: + # Special case for PTY environments with no text content return result, currCursor + + # Get current screen text to correlate with attribute changes text = self.env['runtime']['screenManager'].getScreenText() textLines = text.split('\n') + # Sanity check: text lines must match attribute array dimensions if len(textLines) != len(self.currAttributes): return result, currCursor + + # Compare attributes line by line, character by character for line in range(len(self.prevAttributes)): if self.prevAttributes[line] != self.currAttributes[line]: + # This line has attribute changes - examine each character position for column in range(len(self.prevAttributes[line])): if self.prevAttributes[line][column] == self.currAttributes[line][column]: + # No change at this position continue + # Attribute changed at this position - check if it's worth announcing if self.isUsefulForTracking(line, column, self.currAttributes, self.prevAttributes): + # First highlighted character becomes cursor position for navigation if not currCursor: currCursor = {'x': column, 'y': line} + # Accumulate highlighted characters result += textLines[line][column] + # Add space between lines of highlighted text for speech clarity result += ' ' return result, currCursor def isUsefulForTracking(self, line, column, currAttributes, prevAttributes, attribute=1 , mode = 'zaxe'): + """ + Determines if an attribute change at a specific position is worth announcing. + + This prevents announcing every minor attribute change and focuses on meaningful + highlighting that indicates user selections, focus changes, or important emphasis. + + Args: + line, column: Position of the attribute change + currAttributes, prevAttributes: Current and previous attribute arrays + attribute: Which attribute to examine (1=background color by default) + mode: Detection algorithm ('zaxe', 'default', 'barrier') + + Returns: + bool: True if this attribute change should be announced to user + """ + # Sanity checks for valid position and sufficient screen content if len(currAttributes) <= 3: return False if line < 0: return False if line > len(currAttributes): return False + useful = False + if mode == 'default': - # non default tracking + # Simple mode: announce any non-default attribute useful = not self.isDefaultAttribute(currAttributes[line][column]) + elif (mode == 'zaxe') or (mode == ''): - # arround me tracking for bg + # Context-aware mode: only announce attributes that stand out from surroundings + # This prevents announcing entire blocks of highlighted text character by character + # by checking if the attribute differs from adjacent lines + if line == 0: - useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line + 2][column][attribute]) + # Top line: compare against lines below + useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and \ + (currAttributes[line][column][attribute] != currAttributes[line + 2][column][attribute]) elif line >= len(prevAttributes): - useful = (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 2][column][attribute]) + # Bottom line: compare against lines above + useful = (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) and \ + (currAttributes[line][column][attribute] != currAttributes[line - 2][column][attribute]) else: - useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) + # Middle lines: compare against both directions + useful = (currAttributes[line][column][attribute] != currAttributes[line + 1][column][attribute]) and \ + (currAttributes[line][column][attribute] != currAttributes[line - 1][column][attribute]) + elif mode == 'barrier': - # to be implement + # Barrier mode: future enhancement for detecting screen boundaries/separators useful = True return useful diff --git a/src/fenrirscreenreader/core/fenrirManager.py b/src/fenrirscreenreader/core/fenrirManager.py index cd0131cf..6e68b64c 100644 --- a/src/fenrirscreenreader/core/fenrirManager.py +++ b/src/fenrirscreenreader/core/fenrirManager.py @@ -116,7 +116,7 @@ class fenrirManager(): self.environment['runtime']['remoteManager'].handleRemoteIncomming(event['Data']) def handleScreenChange(self, event): - self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data']) + self.environment['runtime']['screenManager'].handleScreenChange(event['Data']) if self.environment['runtime']['vmenuManager'].getActive(): return self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged') diff --git a/src/fenrirscreenreader/core/memoryManager.py b/src/fenrirscreenreader/core/memoryManager.py index 6dccf7be..0798539c 100644 --- a/src/fenrirscreenreader/core/memoryManager.py +++ b/src/fenrirscreenreader/core/memoryManager.py @@ -92,7 +92,7 @@ class memoryManager(): def clearCurrentIndexList(self, name): if not self.listStorageValid(name): return False - self.listStorage[name]['index'] = [] + self.listStorage[name]['list'] = [] self.listStorage[name]['index'] = -1 def getCurrentIndex(self,name): if not self.listStorageValid(name): @@ -103,7 +103,7 @@ class memoryManager(): try: return self.listStorage[name]['index'] except: - retrun -1 + return -1 def isIndexListEmpty(self, name): if not self.listStorageValid(name): return False diff --git a/src/fenrirscreenreader/core/outputManager.py b/src/fenrirscreenreader/core/outputManager.py index 3967b19f..41a56456 100644 --- a/src/fenrirscreenreader/core/outputManager.py +++ b/src/fenrirscreenreader/core/outputManager.py @@ -101,7 +101,7 @@ class outputManager(): cleanText = self.env['runtime']['textManager'].replaceHeadLines(cleanText) cleanText = self.env['runtime']['punctuationManager'].proceedPunctuation(cleanText, ignorePunctuation) cleanText = re.sub(' +$', ' ', cleanText) - self.env['runtime']['speechDriver'].speak(cleanText) + self.env['runtime']['speechDriver'].speak(cleanText, True, ignorePunctuation) self.env['runtime']['debug'].writeDebugOut("Speak: "+ cleanText, debug.debugLevel.INFO) except Exception as e: self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ", debug.debugLevel.ERROR) diff --git a/src/fenrirscreenreader/core/punctuationManager.py b/src/fenrirscreenreader/core/punctuationManager.py index c7fc3d53..76806627 100644 --- a/src/fenrirscreenreader/core/punctuationManager.py +++ b/src/fenrirscreenreader/core/punctuationManager.py @@ -65,12 +65,14 @@ class punctuationManager(): def isPuctuation(self, char): return char in self.env['punctuation']['PUNCTDICT'] def proceedPunctuation(self, text, ignorePunctuation=False): + if ignorePunctuation: + return text resultText = text resultText = self.useCustomDict(resultText, self.env['punctuation']['CUSTOMDICT']) if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'emoticons'): resultText = self.useCustomDict(resultText, self.env['punctuation']['EMOTICONDICT'], ' ') currPunctLevel = '' - if not ignorePunctuation and self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower() in self.env['punctuation']['LEVELDICT']: + if self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower() in self.env['punctuation']['LEVELDICT']: currPunctLevel = self.env['punctuation']['LEVELDICT'][self.env['runtime']['settingsManager'].getSetting('general', 'punctuationLevel').lower()] else: currPunctLevel = string.punctuation +' ยง' diff --git a/src/fenrirscreenreader/core/screenManager.py b/src/fenrirscreenreader/core/screenManager.py index 04f6418f..1341aa98 100644 --- a/src/fenrirscreenreader/core/screenManager.py +++ b/src/fenrirscreenreader/core/screenManager.py @@ -52,7 +52,7 @@ class screenManager(): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') def isCurrScreenIgnoredChanged(self): return self.getCurrScreenIgnored() != self.getPrevScreenIgnored() - def hanldeScreenChange(self, eventData): + def handleScreenChange(self, eventData): self.getCurrScreen() self.getSessionInformation() self.updateScreenIgnored() @@ -120,47 +120,94 @@ class screenManager(): self.env['screen']['newDelta'] = '' self.env['runtime']['attributeManager'].resetAttributeDelta() - # changes on the screen + # Diff generation - critical for screen reader functionality + # This code detects and categorizes screen content changes to provide appropriate + # speech feedback (typing echo vs incoming text vs screen updates) + + # Pre-process screen text for comparison - collapse multiple spaces to single space + # This normalization prevents spurious diffs from spacing inconsistencies oldScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screen']['oldContentText'])) newScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screen']['newContentText'])) + + # Track whether this appears to be typing (user input) vs other screen changes typing = False diffList = [] if (self.env['screen']['oldContentText'] != self.env['screen']['newContentText']): + # Special case: Initial screen content (going from empty to populated) + # This handles first screen load or TTY switch scenarios if self.env['screen']['newContentText'] != '' and self.env['screen']['oldContentText'] == '': if oldScreenText == '' and\ newScreenText != '': self.env['screen']['newDelta'] = newScreenText else: + # Calculate byte positions for the current cursor's line in the flat text buffer + # Formula: (line_number * columns) + line_number accounts for newlines + # Each line contributes 'columns' chars + 1 newline char cursorLineStart = self.env['screen']['newCursor']['y'] * self.env['screen']['columns'] + self.env['screen']['newCursor']['y'] cursorLineEnd = cursorLineStart + self.env['screen']['columns'] + + # TYPING DETECTION ALGORITHM + # Determines if this screen change is likely user typing vs other content changes + # All conditions must be met for typing detection: if abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) >= 1 and \ self.env['screen']['oldCursor']['y'] == self.env['screen']['newCursor']['y'] and \ self.env['screen']['newContentText'][:cursorLineStart] == self.env['screen']['oldContentText'][:cursorLineStart] and \ self.env['screen']['newContentText'][cursorLineEnd:] == self.env['screen']['oldContentText'][cursorLineEnd:]: + # Condition 1: Cursor moved horizontally by at least 1 position (typical of typing) + # Condition 2: Cursor stayed on same line (typing doesn't usually change lines) + # Condition 3: Content BEFORE cursor line is unchanged (text above typing area) + # Condition 4: Content AFTER cursor line is unchanged (text below typing area) + # Together: only the current line changed, cursor moved horizontally = likely typing + + # Optimize diff calculation for typing by focusing on a small window around cursor cursorLineStartOffset = cursorLineStart cursorLineEndOffset = cursorLineEnd + + # Limit analysis window to avoid processing entire long lines + # +3 provides safety buffer beyond cursor position to catch edge cases if cursorLineEnd > cursorLineStart + self.env['screen']['newCursor']['x'] + 3: cursorLineEndOffset = cursorLineStart + self.env['screen']['newCursor']['x'] + 3 + + # Extract just the relevant text sections for character-level diff oldScreenText = self.env['screen']['oldContentText'][cursorLineStartOffset:cursorLineEndOffset] newScreenText = self.env['screen']['newContentText'][cursorLineStartOffset:cursorLineEndOffset] + + # Character-level diff for typing detection (not line-level) diff = self.differ.compare(oldScreenText, newScreenText) diffList = list(diff) typing = True + + # Validate typing assumption by checking if detected changes match cursor movement tempNewDelta = ''.join(x[2:] for x in diffList if x[0] == '+') if tempNewDelta.strip() != '': - if tempNewDelta != ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()): + # Compare diff result against expected typing pattern + # Expected: characters between old and new cursor positions + expectedTyping = ''.join(newScreenText[self.env['screen']['oldCursor']['x']:self.env['screen']['newCursor']['x']].rstrip()) + + # If diff doesn't match expected typing pattern, treat as general screen change + if tempNewDelta != expectedTyping: + # Fallback: treat entire current line as new content diffList = ['+ ' + self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] +'\n'] typing = False else: + # GENERAL SCREEN CHANGE DETECTION + # Not typing - handle as line-by-line content change + # This catches: incoming messages, screen updates, application output, etc. diff = self.differ.compare(oldScreenText.split('\n'),\ newScreenText.split('\n')) diffList = list(diff) + # Extract added and removed content from diff results + # Output format depends on whether this was detected as typing or general change if not typing: + # Line-based changes: join with newlines for proper speech cadence self.env['screen']['newDelta'] = '\n'.join(x[2:] for x in diffList if x[0] == '+') else: + # Character-based changes: no newlines for smooth typing echo self.env['screen']['newDelta'] = ''.join(x[2:] for x in diffList if x[0] == '+') + + # Negative delta (removed content) - used for backspace/delete detection self.env['screen']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') # track highlighted diff --git a/src/fenrirscreenreader/core/speechDriver.py b/src/fenrirscreenreader/core/speechDriver.py index 82b62d8d..969dcbf6 100644 --- a/src/fenrirscreenreader/core/speechDriver.py +++ b/src/fenrirscreenreader/core/speechDriver.py @@ -24,7 +24,7 @@ class speechDriver(): self.cancel() self._isInitialized = False - def speak(self,text, queueable=True): + def speak(self,text, queueable=True, ignorePunctuation=False): if not self._isInitialized: return if not queueable: @@ -57,7 +57,7 @@ class speechDriver(): if not isinstance(pitch, float): return if pitch < 0.0: - retrun + return if pitch > 1.0: return self.pitch = pitch @@ -67,7 +67,7 @@ class speechDriver(): if not isinstance(rate, float): return if rate < 0.0: - retrun + return if rate > 1.0: return self.rate = rate @@ -96,7 +96,7 @@ class speechDriver(): if not isinstance(volume,float): return if volume < 0.0: - retrun + return if volume > 1.0: return self.volume = volume diff --git a/src/fenrirscreenreader/remoteDriver/unixDriver.py b/src/fenrirscreenreader/remoteDriver/unixDriver.py index 531f05a5..89022c10 100644 --- a/src/fenrirscreenreader/remoteDriver/unixDriver.py +++ b/src/fenrirscreenreader/remoteDriver/unixDriver.py @@ -33,7 +33,7 @@ class driver(remoteDriver): os.unlink(socketFile) self.fenrirSock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.fenrirSock.bind(socketFile) - os.chmod(socketFile, 0o666) + os.chmod(socketFile, 0o666) # Allow all users to read/write self.fenrirSock.listen(1) while active.value: # Check if the client is still connected and if data is available: diff --git a/src/fenrirscreenreader/screenDriver/vcsaDriver.py b/src/fenrirscreenreader/screenDriver/vcsaDriver.py index 3626f765..dcf6245e 100644 --- a/src/fenrirscreenreader/screenDriver/vcsaDriver.py +++ b/src/fenrirscreenreader/screenDriver/vcsaDriver.py @@ -36,7 +36,8 @@ class driver(screenDriver): self.hichar = None try: # set workaround for paste clipboard -> injectTextToScreen - os.system('sysctl dev.tty.legacy_tiocsti=1') + subprocess.run(['sysctl', 'dev.tty.legacy_tiocsti=1'], + check=False, capture_output=True, timeout=5) except: pass def initialize(self, environment): diff --git a/src/fenrirscreenreader/soundDriver/genericDriver.py b/src/fenrirscreenreader/soundDriver/genericDriver.py index 168a1df5..c8badc5a 100644 --- a/src/fenrirscreenreader/soundDriver/genericDriver.py +++ b/src/fenrirscreenreader/soundDriver/genericDriver.py @@ -44,10 +44,14 @@ class driver(soundDriver): return if interrupt: self.cancel() + # Validate file path to prevent injection + import os + if not os.path.isfile(filePath) or '..' in filePath: + return popenSoundFileCommand = shlex.split(self.soundFileCommand) for idx, word in enumerate(popenSoundFileCommand): word = word.replace('fenrirVolume', str(self.volume )) - word = word.replace('fenrirSoundFile', str(filePath)) + word = word.replace('fenrirSoundFile', shlex.quote(str(filePath))) popenSoundFileCommand[idx] = word self.proc = subprocess.Popen(popenSoundFileCommand, shell=False) self.soundType = 'file' diff --git a/src/fenrirscreenreader/speechDriver/debugDriver.py b/src/fenrirscreenreader/speechDriver/debugDriver.py index 2b1f34f6..d8b18051 100644 --- a/src/fenrirscreenreader/speechDriver/debugDriver.py +++ b/src/fenrirscreenreader/speechDriver/debugDriver.py @@ -22,7 +22,7 @@ class driver(speechDriver): self._isInitialized = False print('Speech Debug Driver: Shutdown') - def speak(self,text, queueable=True): + def speak(self,text, queueable=True, ignorePunctuation=False): if not self._isInitialized: return if not queueable: diff --git a/src/fenrirscreenreader/speechDriver/genericDriver.py b/src/fenrirscreenreader/speechDriver/genericDriver.py index 971f6c62..592aefe5 100644 --- a/src/fenrirscreenreader/speechDriver/genericDriver.py +++ b/src/fenrirscreenreader/speechDriver/genericDriver.py @@ -52,7 +52,7 @@ class driver(speechDriver): self.cancel() self.textQueue.put(-1) - def speak(self,text, queueable=True): + def speak(self,text, queueable=True, ignorePunctuation=False): if not self._isInitialized: return if not queueable: @@ -174,7 +174,8 @@ class driver(speechDriver): word = word.replace('fenrirVoice', str(utterance['voice'])) word = word.replace('fenrirPitch', str(utterance['pitch'])) word = word.replace('fenrirRate', str(utterance['rate'])) - word = word.replace('fenrirText', str(utterance['text'])) + # Properly quote text to prevent command injection + word = word.replace('fenrirText', shlex.quote(str(utterance['text']))) popenSpeechCommand[idx] = word try: diff --git a/src/fenrirscreenreader/speechDriver/speechdDriver.py b/src/fenrirscreenreader/speechDriver/speechdDriver.py index b711d9e7..c87a86c0 100644 --- a/src/fenrirscreenreader/speechDriver/speechdDriver.py +++ b/src/fenrirscreenreader/speechDriver/speechdDriver.py @@ -37,7 +37,7 @@ class driver(speechDriver): pass self._isInitialized = False - def speak(self,text, queueable=True): + def speak(self,text, queueable=True, ignorePunctuation=False): if not queueable: self.cancel() if not self._isInitialized: @@ -66,7 +66,10 @@ class driver(speechDriver): self.env['runtime']['debug'].writeDebugOut('speechDriver setVoice:' + str(e),debug.debugLevel.ERROR) try: - self._sd.set_punctuation(self._punct.NONE) + if ignorePunctuation: + self._sd.set_punctuation(self._punct.ALL) + else: + self._sd.set_punctuation(self._punct.NONE) except Exception as e: self.env['runtime']['debug'].writeDebugOut('speechDriver set_punctuation:' + str(e),debug.debugLevel.ERROR) diff --git a/src/fenrirscreenreader/utils/char_utils.py b/src/fenrirscreenreader/utils/char_utils.py index 1ae9a8e0..425bad83 100644 --- a/src/fenrirscreenreader/utils/char_utils.py +++ b/src/fenrirscreenreader/utils/char_utils.py @@ -119,4 +119,15 @@ def getPhonetic(currChar): return phonChar except: return currChar + +def presentCharForReview(env, char, interrupt=True, announceCapital=True, flush=False): + """Present a character for explicit review commands only""" + if char == ' ': + if ' ' in env['punctuation']['PUNCTDICT']: + announceChar = env['punctuation']['PUNCTDICT'][' '] + else: + announceChar = 'space' + env['runtime']['outputManager'].presentText(announceChar, interrupt=interrupt, flush=flush) + else: + env['runtime']['outputManager'].presentText(char, interrupt=interrupt, ignorePunctuation=True, announceCapital=announceCapital, flush=flush) diff --git a/src/fenrirscreenreader/utils/line_utils.py b/src/fenrirscreenreader/utils/line_utils.py index 1c309ced..a18caaa7 100644 --- a/src/fenrirscreenreader/utils/line_utils.py +++ b/src/fenrirscreenreader/utils/line_utils.py @@ -5,7 +5,6 @@ # By Chrys, Storm Dragon, and contributers. from fenrirscreenreader.core import debug -from collections import Counter def getPrevLine(currX,currY, currText): endOfScreen = False diff --git a/src/fenrirscreenreader/utils/screen_utils.py b/src/fenrirscreenreader/utils/screen_utils.py index 0075d6c8..715fe65f 100644 --- a/src/fenrirscreenreader/utils/screen_utils.py +++ b/src/fenrirscreenreader/utils/screen_utils.py @@ -76,7 +76,7 @@ def getShell(): except: pass try: - if os.acess('/etc/passwd'): + if os.access('/etc/passwd', os.R_OK): with open('/etc/passwd') as f: users = f.readlines() for user in users: