From b29114abeaa5793b0a97a3fe6eba5d32efb19f86 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 9 Jul 2017 18:03:29 +0200 Subject: [PATCH] add onCursorChange trigger; implement auto leave review mode on cursor change --- config/settings/espeak.settings.conf | 2 +- config/settings/settings.conf | 2 +- config/settings/settings.conf.storm | 6 ++-- ...resent_char_if_cursor_change_horizontal.py | 0 .../50000-char_echo.py | 0 ...-present_line_if_cursor_change_vertical.py | 0 .../60000-word_echo.py | 0 .../62000-spell_check.py | 0 .../65000-char_delete_echo.py | 0 .../onCursorChange/66000-exit_review_mode.py | 26 +++++++++++++++ .../onInput/11000-leave_review_mode.py | 33 ------------------- src/fenrir/core/fenrirManager.py | 6 +++- src/fenrir/core/generalData.py | 2 +- src/fenrir/core/settingsData.py | 2 +- 14 files changed, 38 insertions(+), 41 deletions(-) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/45000-present_char_if_cursor_change_horizontal.py (100%) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/50000-char_echo.py (100%) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/55000-present_line_if_cursor_change_vertical.py (100%) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/60000-word_echo.py (100%) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/62000-spell_check.py (100%) rename src/fenrir/commands/{onScreenUpdate => onCursorChange}/65000-char_delete_echo.py (100%) create mode 100644 src/fenrir/commands/onCursorChange/66000-exit_review_mode.py delete mode 100644 src/fenrir/commands/onInput/11000-leave_review_mode.py diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 56f2d781..923ad0ea 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -173,7 +173,7 @@ highlight=False lineBreak=True endOfScreen=True # leave the review when pressing a key -leaveReviewOnKeypress=False +leaveReviewOnCursorChange=True # leave the review when changing the screen leaveReviewOnScreenChange=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 9033d4fc..c9565d06 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -180,7 +180,7 @@ highlight=False lineBreak=True endOfScreen=True # leave the review when pressing a key -leaveReviewOnKeypress=False +leaveReviewOnCursorChange=True # leave the review when changing the screen leaveReviewOnScreenChange=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index b2f93cb2..eab9ebed 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -78,8 +78,8 @@ panSizeHorizontal=0 driver=vcsaDriver encoding=cp850 screenUpdateDelay=0.05 -suspendingScreen=7 -autodetectSuspendingScreen=False +suspendingScreen= +autodetectSuspendingScreen=True [keyboard] driver=evdevDriver @@ -128,7 +128,7 @@ highlight=False lineBreak=True endOfScreen=True # leave the review when pressing a key -leaveReviewOnKeypress=False +leaveReviewOnCursorChange=True # leave the review when changing the screen leaveReviewOnScreenChange=True diff --git a/src/fenrir/commands/onScreenUpdate/45000-present_char_if_cursor_change_horizontal.py b/src/fenrir/commands/onCursorChange/45000-present_char_if_cursor_change_horizontal.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/45000-present_char_if_cursor_change_horizontal.py rename to src/fenrir/commands/onCursorChange/45000-present_char_if_cursor_change_horizontal.py diff --git a/src/fenrir/commands/onScreenUpdate/50000-char_echo.py b/src/fenrir/commands/onCursorChange/50000-char_echo.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/50000-char_echo.py rename to src/fenrir/commands/onCursorChange/50000-char_echo.py diff --git a/src/fenrir/commands/onScreenUpdate/55000-present_line_if_cursor_change_vertical.py b/src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/55000-present_line_if_cursor_change_vertical.py rename to src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py diff --git a/src/fenrir/commands/onScreenUpdate/60000-word_echo.py b/src/fenrir/commands/onCursorChange/60000-word_echo.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/60000-word_echo.py rename to src/fenrir/commands/onCursorChange/60000-word_echo.py diff --git a/src/fenrir/commands/onScreenUpdate/62000-spell_check.py b/src/fenrir/commands/onCursorChange/62000-spell_check.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/62000-spell_check.py rename to src/fenrir/commands/onCursorChange/62000-spell_check.py diff --git a/src/fenrir/commands/onScreenUpdate/65000-char_delete_echo.py b/src/fenrir/commands/onCursorChange/65000-char_delete_echo.py similarity index 100% rename from src/fenrir/commands/onScreenUpdate/65000-char_delete_echo.py rename to src/fenrir/commands/onCursorChange/65000-char_delete_echo.py diff --git a/src/fenrir/commands/onCursorChange/66000-exit_review_mode.py b/src/fenrir/commands/onCursorChange/66000-exit_review_mode.py new file mode 100644 index 00000000..2f7a8cfa --- /dev/null +++ b/src/fenrir/commands/onCursorChange/66000-exit_review_mode.py @@ -0,0 +1,26 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from 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/fenrir/commands/onInput/11000-leave_review_mode.py b/src/fenrir/commands/onInput/11000-leave_review_mode.py deleted file mode 100644 index 91c91a6b..00000000 --- a/src/fenrir/commands/onInput/11000-leave_review_mode.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/python -# -*- coding: utf-8 -*- - -# Fenrir TTY screen reader -# By Chrys, Storm Dragon, and contributers. - -from 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): - return - if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnKeypress'): - return - if not self.env['runtime']['inputManager'].noKeyPressed(): - return - if self.env['runtime']['screenManager'].isScreenChange(): - return - if len(self.env['input']['prevDeepestInput']) > len(self.env['input']['currInput']): - return - self.env['runtime']['cursorManager'].clearReviewCursor() - - def setCallback(self, callback): - pass - diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index 151be8a5..8d10e4e7 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -88,7 +88,11 @@ class fenrirManager(): self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ self.environment['runtime']['applicationManager'].getPrevApplication(), \ self.environment['runtime']['applicationManager'].getCurrentApplication()) - ''' + ''' + # has cursor changed? + if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \ + self.environment['runtime']['cursorManager'].isCursorHorizontalMove(): + self.environment['runtime']['commandManager'].executeDefaultTrigger('onCursorChange') self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate') #print(time.time() -s) diff --git a/src/fenrir/core/generalData.py b/src/fenrir/core/generalData.py index 261e7379..ff89e64c 100644 --- a/src/fenrir/core/generalData.py +++ b/src/fenrir/core/generalData.py @@ -13,6 +13,6 @@ generalData = { 'prevUser':'', 'managerList':['eventManager','punctuationManager','cursorManager','applicationManager','commandManager' ,'screenManager','inputManager','outputManager','debug'], -'commandFolderList':['commands','onInput','onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' +'commandFolderList':['commands','onInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice' ,'onApplicationChange','onSwitchApplicationProfile',], } diff --git a/src/fenrir/core/settingsData.py b/src/fenrir/core/settingsData.py index 4e849d6a..c94df2cf 100644 --- a/src/fenrir/core/settingsData.py +++ b/src/fenrir/core/settingsData.py @@ -76,7 +76,7 @@ settingsData = { 'review':{ 'lineBreak': True, 'endOfScreen': True, - 'leaveReviewOnKeypress': False, + 'leaveReviewOnCursorChange': True, 'leaveReviewOnScreenChange': True, }, 'promote':{