From cb6b66b40075328f17eb5a8e0d02d25bc6d0459b Mon Sep 17 00:00:00 2001 From: Chrys Date: Wed, 13 Jul 2022 16:33:16 +0200 Subject: [PATCH] add more navigation commands and update speakup layout --- config/keyboard/desktop.conf | 2 ++ config/keyboard/speakup.conf | 4 +-- .../commands/commands/review_bottom.py | 4 +-- .../commands/review_screen_first_char.py | 30 +++++++++++++++++++ .../commands/review_screen_last_char.py | 30 +++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 src/fenrirscreenreader/commands/commands/review_screen_first_char.py create mode 100644 src/fenrirscreenreader/commands/commands/review_screen_last_char.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 26499fb4..2725721e 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -32,6 +32,8 @@ KEY_FENRIR,KEY_KP5=curr_screen KEY_FENRIR,KEY_KP8=curr_screen_before_cursor KEY_FENRIR,KEY_KP2=curr_screen_after_cursor #=cursor_read_to_end_of_line +#=review_screen_last_char +#=review_screen_first_char #=cursor_column #=cursor_lineno #=braille_flush diff --git a/config/keyboard/speakup.conf b/config/keyboard/speakup.conf index d18c0f7c..53fd8eea 100644 --- a/config/keyboard/speakup.conf +++ b/config/keyboard/speakup.conf @@ -79,10 +79,10 @@ KEY_FENRIR,KEY_KP9=review_bottom KEY_FENRIR,KEY_KP3=review_top # InsKeyPad-7 Move reading cursor to left edge of screen (insert home) -# TODO +KEY_FENRIR,KEY_KP7=review_screen_first_char # InsKeyPad-1 Move reading cursor to right edge of screen (insert end) -# TODO +KEY_FENRIR,KEY_KP1=review_screen_last_char # ControlKeyPad-1 Move reading cursor to last character on current line. KEY_CTRL,KEY_KP1=review_line_end diff --git a/src/fenrirscreenreader/commands/commands/review_bottom.py b/src/fenrirscreenreader/commands/commands/review_bottom.py index 1d2f3c1b..cbc9e833 100644 --- a/src/fenrirscreenreader/commands/commands/review_bottom.py +++ b/src/fenrirscreenreader/commands/commands/review_bottom.py @@ -14,11 +14,11 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('Move review to the bottom of the screen') + return _('Move review to the bottom of the screen') def run(self): self.env['screen']['newCursorReview'] = { 'x': 0, 'y':self.env['screen']['lines'] -1} - self.env['runtime']['outputManager'].presentText(_("Bottom"), interrupt=True, flush=False) + self.env['runtime']['outputManager'].presentText(_("Bottom"), interrupt=True, flush=False) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/commands/review_screen_first_char.py b/src/fenrirscreenreader/commands/commands/review_screen_first_char.py new file mode 100644 index 00000000..460d38cc --- /dev/null +++ b/src/fenrirscreenreader/commands/commands/review_screen_first_char.py @@ -0,0 +1,30 @@ +#!/bin/python +# -*- 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 _('Move Review to the first character on the screen (left top)') + + def run(self): + cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() + self.env['runtime']['cursorManager'].setReviewCursorPosition(0 ,0) + 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) + self.env['runtime']['outputManager'].presentText(_("first character in screen"), interrupt=False) + + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/commands/commands/review_screen_last_char.py b/src/fenrirscreenreader/commands/commands/review_screen_last_char.py new file mode 100644 index 00000000..cdd51058 --- /dev/null +++ b/src/fenrirscreenreader/commands/commands/review_screen_last_char.py @@ -0,0 +1,30 @@ +#!/bin/python +# -*- 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 _('Move Review to the last character on the screen (right bottom)') + + def run(self): + cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() + self.env['runtime']['cursorManager'].setReviewCursorPosition(self.env['screen']['columns']-1 ,self.env['screen']['lines']-1) + 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) + self.env['runtime']['outputManager'].presentText(_("last character in screen"), interrupt=False) + + def setCallback(self, callback): + pass