From cebfb6797c01c76916c0e7cc1edd780c5a4e1de3 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 7 Aug 2016 17:00:54 +0200 Subject: [PATCH] polish auto output --- ...resent_char_if_cursor_change_horizontal.py | 28 +++++++++++++ ...-present_line_if_cursor_change_vertical.py | 21 ++++++++++ .../onScreenChanged/60000-word_echo.py | 42 +++++++++++++++++++ .../onScreenChanged/65000-char_delete_echo.py | 33 +++++++++++++++ .../onScreenChanged/70000-incomming.py | 21 ++++++++++ .../onScreenChanged/75000-char_echo.py | 28 +++++++++++++ .../onScreenChanged/80000-tty_change.py | 17 ++++++++ 7 files changed, 190 insertions(+) create mode 100644 src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py create mode 100644 src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py create mode 100644 src/fenrir-package/commands/onScreenChanged/60000-word_echo.py create mode 100644 src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py create mode 100644 src/fenrir-package/commands/onScreenChanged/70000-incomming.py create mode 100644 src/fenrir-package/commands/onScreenChanged/75000-char_echo.py create mode 100644 src/fenrir-package/commands/onScreenChanged/80000-tty_change.py 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 new file mode 100644 index 00000000..db97926f --- /dev/null +++ b/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py @@ -0,0 +1,28 @@ +#!/bin/python +import time +class command(): + def __init__(self): + pass + def run(self, environment): + # TTY Change + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + # detect an change on the screen, we just want to cursor arround, so no change should appear + if environment['screenData']['newDelta'] != '': + return environment + # is it a horizontal change? + if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\ + environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: + return environment + + if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].strip(" \t\n") == '': + 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) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + 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 new file mode 100644 index 00000000..08391870 --- /dev/null +++ b/src/fenrir-package/commands/onInput/55000-present_line_if_cursor_change_vertical.py @@ -0,0 +1,21 @@ +#!/bin/python + +class command(): + def __init__(self): + pass + def run(self, environment): + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: + return environment + if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']: + return environment + if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].strip(" \t\n") == '': + environment['runtime']['outputManager'].presentText(environment, "blank", soundIconName='EmptyLine', interrupt=True) + else: + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True) + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py new file mode 100644 index 00000000..35a5d9c9 --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/60000-word_echo.py @@ -0,0 +1,42 @@ +#!/bin/python +from utils import word_utils + +class command(): + def __init__(self): + pass + def run(self, environment): + if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'): + return environment + + # just when cursor move worddetection is needed + if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: + return environment + + # for now no new line + if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']: + return environment + if len(environment['screenData']['newDelta']) > 1: + return environment + + # TTY Change is no new word + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + + # first place could not be the end of a word + if environment['screenData']['newCursor']['x'] == 0: + return environment + + # 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) + if not(newContent[environment['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['newCursor']['x']): + return environment + + if currWord != '': + environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py new file mode 100644 index 00000000..e431a75e --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/65000-char_delete_echo.py @@ -0,0 +1,33 @@ +#!/bin/python + +class command(): + def __init__(self): + pass + def run(self, environment): + + if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charDeleteEcho'): + return environment + + # detect typing or chilling + if environment['screenData']['newCursor']['x'] >= environment['screenData']['oldCursor']['x']: + return environment + + # TTY change + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + + # More than just a deletion happend + if environment['screenData']['newDelta'].strip(" \t\n") != '': + if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: + return environment + + # No deletion + if environment['screenData']['newNegativeDelta'] == '': + return environment + + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newNegativeDelta'], interrupt=True) + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/onScreenChanged/70000-incomming.py b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py new file mode 100644 index 00000000..9eb83367 --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/70000-incomming.py @@ -0,0 +1,21 @@ +#!/bin/python + +class command(): + def __init__(self): + pass + def run(self, environment): + #if environment['screenData']['newCursor']['x'] > environment['screenData']['oldCursor']['x']: + # return environment + + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + if environment['screenData']['newDelta'] == '': + return environment + + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=False) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/onScreenChanged/75000-char_echo.py b/src/fenrir-package/commands/onScreenChanged/75000-char_echo.py new file mode 100644 index 00000000..6b7ac07c --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/75000-char_echo.py @@ -0,0 +1,28 @@ +#!/bin/python + +class command(): + def __init__(self): + pass + def run(self, environment): + + if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho'): + return environment + # detect deletion or chilling + if environment['screenData']['newCursor']['x'] <= environment['screenData']['oldCursor']['x']: + return environment + # TTY Change + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: + return environment + # is there any change? + if environment['screenData']['newDelta'] == '': + return environment + # big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now) + if len(environment['screenData']['newDelta']) > 5: + return environment + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass diff --git a/src/fenrir-package/commands/onScreenChanged/80000-tty_change.py b/src/fenrir-package/commands/onScreenChanged/80000-tty_change.py new file mode 100644 index 00000000..91b1b7a5 --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/80000-tty_change.py @@ -0,0 +1,17 @@ +#!/bin/python + +class command(): + def __init__(self): + pass + def run(self, environment): + + if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: + return environment + environment['runtime']['outputManager'].playSoundIcon(environment,'ChangeTTY') + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass