From 13742ba98066788b3ea8fc097c4fb264ee7019e1 Mon Sep 17 00:00:00 2001 From: Chrys Date: Fri, 6 Sep 2019 22:16:00 +0200 Subject: [PATCH] strip whitespace --- .../commands/onCursorChange/15000-char_echo.py | 1 - .../onCursorChange/55000-tab_completion.py | 2 -- .../onScreenUpdate/56000-highlight_tracking.py | 6 ++---- .../commands/onScreenUpdate/60000-history.py | 16 ++++++++-------- .../commands/onScreenUpdate/70000-incoming.py | 6 +++--- .../onScreenUpdate/75000-incoming_promote.py | 8 +++----- .../onScreenUpdate/80000-barrier_detect.py | 7 ++----- 7 files changed, 18 insertions(+), 28 deletions(-) diff --git a/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py b/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py index 7ae8aa2d..039752bf 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py +++ b/src/fenrirscreenreader/commands/onCursorChange/15000-char_echo.py @@ -36,7 +36,6 @@ class command(): # is there any change? if not self.env['runtime']['screenManager'].isDelta(): return - # filter unneded space on word begin currDelta = self.env['screen']['newDelta'] if len(currDelta.strip()) != len(currDelta) and \ diff --git a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py index d111872f..7ef2fc93 100644 --- a/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py +++ b/src/fenrirscreenreader/commands/onCursorChange/55000-tab_completion.py @@ -15,7 +15,6 @@ class command(): pass def getDescription(self): return 'No Description found' - def run(self): # try to detect the tab completion by cursor change xMove = self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] @@ -32,7 +31,6 @@ class command(): return if not xMove == len(self.env['screen']['newDelta']): return - # filter unneded space on word begin currDelta = self.env['screen']['newDelta'] if len(currDelta.strip()) != len(currDelta) and \ diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py b/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py index 1937acff..2363463b 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/56000-highlight_tracking.py @@ -13,13 +13,11 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('enables or disables tracking of highlighted') - + return _('enables or disables tracking of highlighted') def run(self): if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): return attributeDelta = self.env['runtime']['attributeManager'].getAttributeDelta() - self.env['runtime']['outputManager'].presentText(attributeDelta, soundIcon='', interrupt=True, flush=False) - + self.env['runtime']['outputManager'].presentText(attributeDelta, soundIcon='', interrupt=True, flush=False) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py index 84332835..d94d0338 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/60000-history.py @@ -14,7 +14,7 @@ class command(): def shutdown(self): pass def getDescription(self): - return '' + return '' def run(self): if self.env['screen']['newAttribDelta'] != '': return @@ -31,15 +31,15 @@ class command(): if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']: if not (self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_UP'],['KEY_DOWN']]): return - if self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']: + elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']: if not (self.env['runtime']['byteManager'].getLastByteKey() in [b'^[[A',b'^[[B']): return - + prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']] - currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] + currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] if prevLine == currLine: if self.env['screen']['newDelta'] != '': - return + return if not currLine.isspace(): currPrompt = currLine.find('$') rootPrompt = currLine.find('#') @@ -47,17 +47,17 @@ class command(): if rootPrompt > 0: currPrompt = rootPrompt else: - announce = currLine + announce = currLine if currPrompt > 0: remove_digits = str.maketrans('0123456789', ' ') if prevLine[:currPrompt].translate(remove_digits) == currLine[:currPrompt].translate(remove_digits): announce = currLine[currPrompt+1:] else: - announce = currLine + announce = currLine if currLine.isspace(): self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False) - else: + else: self.env['runtime']['outputManager'].presentText(announce, interrupt=True, flush=False) self.env['commandsIgnore']['onScreenUpdate']['CHAR_DELETE_ECHO'] = True self.env['commandsIgnore']['onScreenUpdate']['CHAR_ECHO'] = True diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py b/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py index 3d1595a2..e790b2dc 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/70000-incoming.py @@ -21,9 +21,9 @@ class command(): return # is there something to read? if not self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): - return - - # this must be a keyecho or something + return + + # this must be a keyecho or something #if len(self.env['screen']['newDelta'].strip(' \n\t')) <= 1: xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']) yMove = abs(self.env['screen']['newCursor']['y'] - self.env['screen']['oldCursor']['y']) diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py b/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py index ed3027d9..66d84037 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/75000-incoming_promote.py @@ -15,8 +15,7 @@ class command(): def shutdown(self): pass def getDescription(self): - return 'No Description found' - + return 'No Description found' def run(self): if not self.env['runtime']['settingsManager'].getSettingAsBool('promote', 'enabled'): return @@ -25,13 +24,12 @@ class command(): if int(time.time() - self.env['input']['lastInputTime']) < self.env['runtime']['settingsManager'].getSettingAsInt('promote', 'inactiveTimeoutSec'): return if len(self.env['runtime']['settingsManager'].getSetting('promote', 'list')) == 0: - return + return for promote in self.env['runtime']['settingsManager'].getSetting('promote', 'list').split(','): if promote in self.env['screen']['newDelta']: - self.env['runtime']['outputManager'].playSoundIcon('PromotedText') + self.env['runtime']['outputManager'].playSoundIcon('PromotedText') self.env['input']['lastInputTime'] = time.time() return - def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py index 87d119b0..207ed4a8 100644 --- a/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py +++ b/src/fenrirscreenreader/commands/onScreenUpdate/80000-barrier_detect.py @@ -14,16 +14,13 @@ class command(): def shutdown(self): pass def getDescription(self): - return 'No Description found' - + return 'No Description found' def run(self): if not self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'): return if not self.env['runtime']['screenManager'].isDelta(ignoreSpace=True): - return - + return self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y']) - def setCallback(self, callback): pass