From 2d77b626dc0a3e9510fde9b4b8470d329840b315 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 30 Jan 2017 23:47:36 +0100 Subject: [PATCH] add option to leave review on keypress and on screen change --- config/settings/espeak.settings.conf | 4 +++ config/settings/settings.conf | 4 +++ config/settings/settings.conf.chrys | 4 +++ config/settings/settings.conf.storm | 4 +++ .../onInput/11000-leave_review_mode.py | 32 +++++++++++++++++++ ...ge_reset_marks.py => 85000-reset_marks.py} | 0 ...iew_mode.py => 89000-leave_review_mode.py} | 2 ++ src/fenrir/core/settings.py | 2 ++ 8 files changed, 52 insertions(+) create mode 100644 src/fenrir/commands/onInput/11000-leave_review_mode.py rename src/fenrir/commands/onScreenChanged/{85000-screen_chnage_reset_marks.py => 85000-reset_marks.py} (100%) rename src/fenrir/commands/onScreenChanged/{89000-screen_chnage_leve_review_mode.py => 89000-leave_review_mode.py} (79%) diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 36c7b032..e167e8f9 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -134,6 +134,10 @@ highlight=False [review] lineBreak=True endOfScreen=True +# leave the review when pressing a key +leaveReviewOnKeypress=False +# leave the review when changing the screen +leaveReviewOnScreenChange=True [promote] enabled=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index eb4e3b60..14d8fea4 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -137,6 +137,10 @@ highlight=False [review] lineBreak=True endOfScreen=True +# leave the review when pressing a key +leaveReviewOnKeypress=False +# leave the review when changing the screen +leaveReviewOnScreenChange=True [promote] enabled=True diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index a2bd74c5..b2d64c8f 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -136,6 +136,10 @@ highlight=False [review] lineBreak=True endOfScreen=True +# leave the review when pressing a key +leaveReviewOnKeypress=False +# leave the review when changing the screen +leaveReviewOnScreenChange=True [promote] enabled=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index a8e311ec..195b59eb 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -87,6 +87,10 @@ highlight=False [review] lineBreak=True endOfScreen=True +# leave the review when pressing a key +leaveReviewOnKeypress=False +# leave the review when changing the screen +leaveReviewOnScreenChange=True [promote] enabled=True diff --git a/src/fenrir/commands/onInput/11000-leave_review_mode.py b/src/fenrir/commands/onInput/11000-leave_review_mode.py new file mode 100644 index 00000000..0984f24c --- /dev/null +++ b/src/fenrir/commands/onInput/11000-leave_review_mode.py @@ -0,0 +1,32 @@ +#!/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): + if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnKeypress'): + return + if 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/commands/onScreenChanged/85000-screen_chnage_reset_marks.py b/src/fenrir/commands/onScreenChanged/85000-reset_marks.py similarity index 100% rename from src/fenrir/commands/onScreenChanged/85000-screen_chnage_reset_marks.py rename to src/fenrir/commands/onScreenChanged/85000-reset_marks.py diff --git a/src/fenrir/commands/onScreenChanged/89000-screen_chnage_leve_review_mode.py b/src/fenrir/commands/onScreenChanged/89000-leave_review_mode.py similarity index 79% rename from src/fenrir/commands/onScreenChanged/89000-screen_chnage_leve_review_mode.py rename to src/fenrir/commands/onScreenChanged/89000-leave_review_mode.py index b63b0d5a..84240ebe 100644 --- a/src/fenrir/commands/onScreenChanged/89000-screen_chnage_leve_review_mode.py +++ b/src/fenrir/commands/onScreenChanged/89000-leave_review_mode.py @@ -17,6 +17,8 @@ class command(): return 'No Description found' def run(self): + if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnScreenChange'): + return self.env['runtime']['cursorManager'].clearReviewCursor() def setCallback(self, callback): diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 0687aff8..4f3e8756 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -65,6 +65,8 @@ settings = { 'review':{ 'lineBreak': True, 'endOfScreen': True, + 'leaveReviewOnKeypress': False, + 'leaveReviewOnScreenChange': True, }, 'promote':{ 'enabled': True,