From 884652763950d4745c4b850842c6c8d50a4330b7 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 21 Oct 2016 01:14:46 +0200 Subject: [PATCH] new commands: cursor_line and cursor_column for announce current position --- config/keyboard/desktop.conf | 2 ++ config/keyboard/laptop.conf | 2 ++ config/keyboard/test.conf | 6 +++-- src/fenrir/commands/commands/cursor_column.py | 25 +++++++++++++++++++ src/fenrir/commands/commands/cursor_lineno.py | 25 +++++++++++++++++++ src/fenrir/core/outputManager.py | 6 +++++ 6 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/fenrir/commands/commands/cursor_column.py create mode 100644 src/fenrir/commands/commands/cursor_lineno.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 076795ff..88311c8a 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -31,6 +31,8 @@ KEY_FENRIR,KEY_KPDOT=exit_review KEY_FENRIR,KEY_KP5=curr_screen KEY_FENRIR,KEY_KP8=curr_screen_before_cursor KEY_FENRIR,KEY_KP2=curr_screen_after_cursor +#=cursor_column +#=cursor_lineno KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 54d9ba3d..106c958e 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -30,6 +30,8 @@ KEY_FENRIR,KEY_SHIFT,KEY_DOT=cursor_position KEY_FENRIR,KEY_SHIFT,KEY_K=curr_screen KEY_FENRIR,KEY_SHIFT,KEY_I=curr_screen_before_cursor KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor +#=cursor_column +#=cursor_lineno KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 1740b98e..3c97a015 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -29,8 +29,10 @@ KEY_KPDOT=cursor_position KEY_FENRIR,KEY_I=indent_curr_line KEY_FENRIR,KEY_KPDOT=exit_review KEY_FENRIR,KEY_KP5=curr_screen -KEY_FENRIR,KEY_KP8=curr_screen_before_cursor -KEY_FENRIR,KEY_KP2=curr_screen_after_cursor +#KEY_FENRIR,KEY_KP8=curr_screen_before_cursor +#KEY_FENRIR,KEY_KP2=curr_screen_after_cursor +KEY_FENRIR,KEY_KP2=cursor_column +KEY_FENRIR,KEY_KP8=cursor_lineno KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/src/fenrir/commands/commands/cursor_column.py b/src/fenrir/commands/commands/cursor_column.py new file mode 100644 index 00000000..04365458 --- /dev/null +++ b/src/fenrir/commands/commands/cursor_column.py @@ -0,0 +1,25 @@ +#!/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 'presents the current column number for review cursor in review mode or the text cursor if not. Starts with 1' + def run(self): + cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() + self.env['runtime']['outputManager'].presentText(str(cursorPos['x'] + 1) , interrupt=True) + self.env['runtime']['outputManager'].announceActiveCursor() + self.env['runtime']['outputManager'].presentText(' column number' , interrupt=False) + + def setCallback(self, callback): + pass diff --git a/src/fenrir/commands/commands/cursor_lineno.py b/src/fenrir/commands/commands/cursor_lineno.py new file mode 100644 index 00000000..2d76639d --- /dev/null +++ b/src/fenrir/commands/commands/cursor_lineno.py @@ -0,0 +1,25 @@ +#!/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 'presents the current line number for review cursor in review mode or the text cursor if not. Starts with 1' + def run(self): + cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() + self.env['runtime']['outputManager'].presentText(str(cursorPos['y'] + 1), interrupt=True) + self.env['runtime']['outputManager'].announceActiveCursor() + self.env['runtime']['outputManager'].presentText(' line number' , interrupt=False) + + def setCallback(self, callback): + pass diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index 6b4c5088..9aaf759b 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -127,3 +127,9 @@ class outputManager(): self.env['runtime']['debug'].writeDebugOut("\"playSoundIcon\" in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) return False + def announceActiveCursor(self, interrupt_p=False): + if self.env['runtime']['cursorManager'].isReviewMode(): + self.presentText(' review cursor ', interrupt=interrupt_p) + else: + self.presentText(' text cursor ', interrupt=interrupt_p) +