From cdc86fdad1c92bba67d1aabb609c9f5857f5c9aa Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 19 Sep 2016 20:43:41 +0200 Subject: [PATCH] more modernizing commands --- .../commands/onInput/10000-shut_up.py | 4 +--- ...0-present_char_if_cursor_change_horizontal.py | 9 +++------ ...000-present_line_if_cursor_change_vertical.py | 11 ++++++----- .../commands/onScreenChanged/60000-word_echo.py | 16 ++++++++-------- .../onScreenChanged/62000-spell_check.py | 4 ++-- .../onScreenChanged/75000-incomming_promote.py | 2 ++ 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/fenrir-package/commands/onInput/10000-shut_up.py b/src/fenrir-package/commands/onInput/10000-shut_up.py index d1fac41a..410621ec 100644 --- a/src/fenrir-package/commands/onInput/10000-shut_up.py +++ b/src/fenrir-package/commands/onInput/10000-shut_up.py @@ -17,9 +17,7 @@ class command(): return if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: return -# if environment['screenData']['newCursor'] == environment['screenData']['oldCursor'] and\ -# environment['screenData']['newDelta'] == environment['screenData']['oldDelta']: -# return environment + environment['runtime']['outputManager'].interruptOutput(environment) def setCallback(self, callback): diff --git a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py index 6154ecf9..c56b4785 100644 --- a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py @@ -25,12 +25,9 @@ class command(): if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\ environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: return - print('drin') - if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip() == '': - pass - #environment['runtime']['outputManager'].presentText(environment, "blank",True) - else: - environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']],interrupt=True) + currChar = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']] + if not currChar.strip(" \t\n") == '': + environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py b/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py index bf0db01c..7d782cf8 100644 --- a/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py +++ b/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py @@ -12,15 +12,16 @@ class command(): def run(self, environment): if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: - return environment + return if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: - return environment + return if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']: - return environment - if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].strip(" \t\n") == '': + return + currLine = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] + if currLine.strip(" \t\n") == '': environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) else: - environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True) + environment['runtime']['outputManager'].presentText(environment, currLine, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py index 5f61f756..df1b358a 100644 --- a/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py +++ b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py @@ -14,17 +14,17 @@ class command(): def run(self, environment): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'): return - + # just when cursor move worddetection is needed if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: return - + # for now no new line if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']: - return environment + return if len(environment['screenData']['newDelta']) > 1: - return - + return + # TTY Change is no new word if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: return @@ -32,17 +32,17 @@ class command(): # first place could not be the end of a word if environment['screenData']['newCursor']['x'] == 0: return - + # get the word newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent) # was this a typed word? if environment['screenData']['newDelta'] != '': - if not(newContent[environment['screenData']['oldCursor']['x']].strip() == '' and x != environment['screenData']['oldCursor']['x']): + if not(newContent[environment['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['oldCursor']['x']): return else: # or just arrow arround? - if not(newContent[environment['screenData']['newCursor']['x']].strip() == '' and x != environment['screenData']['newCursor']['x']): + if not(newContent[environment['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['newCursor']['x']): return if currWord != '': diff --git a/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py index f8bef2ce..d9d6e765 100644 --- a/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py +++ b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py @@ -54,11 +54,11 @@ class command(): x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent) # was this a typed word? if environment['screenData']['newDelta'] != '': - if not(newContent[environment['screenData']['oldCursor']['x']].strip() == '' and x != environment['screenData']['oldCursor']['x']): + if not(newContent[environment['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['oldCursor']['x']): return else: # or just arrow arround? - if not(newContent[environment['screenData']['newCursor']['x']].strip() == '' and x != environment['screenData']['newCursor']['x']): + if not(newContent[environment['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['newCursor']['x']): return if currWord != '': diff --git a/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py b/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py index 837dccde..e05ef321 100644 --- a/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py +++ b/src/fenrir-package/commands/onScreenChanged/75000-incomming_promote.py @@ -14,6 +14,8 @@ class command(): def run(self, environment): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'promote', 'enabled'): return + if environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list').strip(" \t\n") == '': + return if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: return if environment['screenData']['newDelta'] == '':