From c07ac6ca3dc9a5b21e359dfd3544db82f16882d5 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 26 Sep 2017 23:19:48 +0200 Subject: [PATCH] speak word when navigating cursor by word with CTRL + B --- .../commands/onCursorChange/60000-word_echo.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/fenrir/commands/onCursorChange/60000-word_echo.py b/src/fenrir/commands/onCursorChange/60000-word_echo.py index bbf0eac0..9af50208 100644 --- a/src/fenrir/commands/onCursorChange/60000-word_echo.py +++ b/src/fenrir/commands/onCursorChange/60000-word_echo.py @@ -19,9 +19,6 @@ class command(): return 'No Description found' def run(self): - # first place could not be the end of a word - if self.env['screen']['newCursor']['x'] == 0: - return # is it enabled? if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): return @@ -36,11 +33,21 @@ class command(): 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) + # currently writing if self.env['runtime']['screenManager'].isDelta(): return + + # navigate prev word + if self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x'] > 1: + # at the end of a word + if newContent[self.env['screen']['newCursor']['x']].isspace(): + return + if self.env['screen']['newCursor']['x'] != x: + return + # next word else: - # at the end of a word + # at the end of a word if not newContent[self.env['screen']['newCursor']['x']].isspace(): return if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \