From d7450428399b9f46275d0e511870503e8d965019 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 26 Sep 2017 23:51:07 +0200 Subject: [PATCH] improve navigation --- .../50000-present_char_if_cursor_change_horizontal.py | 9 +++++++++ .../55000-present_line_if_cursor_change_vertical.py | 3 ++- src/fenrir/commands/onCursorChange/60000-word_echo.py | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/fenrir/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py b/src/fenrir/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py index 7128b903..1a684f13 100644 --- a/src/fenrir/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir/commands/onCursorChange/50000-present_char_if_cursor_change_horizontal.py @@ -33,6 +33,15 @@ class command(): # 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) diff --git a/src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py b/src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py index 3be96485..55d27505 100644 --- a/src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py +++ b/src/fenrir/commands/onCursorChange/55000-present_line_if_cursor_change_vertical.py @@ -6,6 +6,7 @@ from core import debug from utils import line_utils +from utils import word_utils class command(): def __init__(self): @@ -21,7 +22,7 @@ class command(): if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): return if self.env['runtime']['screenManager'].isScreenChange(): - return + 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(): if len(self.env['screen']['newDelta']) > 4: diff --git a/src/fenrir/commands/onCursorChange/60000-word_echo.py b/src/fenrir/commands/onCursorChange/60000-word_echo.py index 75d10293..4f303c69 100644 --- a/src/fenrir/commands/onCursorChange/60000-word_echo.py +++ b/src/fenrir/commands/onCursorChange/60000-word_echo.py @@ -42,14 +42,14 @@ class command(): if currWord == '': return - # navigate prev word - if self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x'] > 1: + # navigate by word (i.e. CTRL + Arrow left/right) + if abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) > 1: # at the start of a word if newContent[self.env['screen']['newCursor']['x']].isspace(): return if self.env['screen']['newCursor']['x'] != x: return - # navigate next word + # navigate by char (left/ right) else: # at the end of a word if not newContent[self.env['screen']['newCursor']['x']].isspace():