From 9afe31062002da228a6e438ade13ba26254a3946 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 1 Oct 2016 00:51:32 +0200 Subject: [PATCH] wait for input, move many scripts to input trigger --- config/settings/settings.conf | 12 ++++++------ ...5000-present_char_if_cursor_change_horizontal.py} | 11 +++++++---- .../{onScreenUpdate => onInput}/50000-char_echo.py | 0 .../{onScreenUpdate => onInput}/60000-word_echo.py | 0 .../{onScreenUpdate => onInput}/62000-spell_check.py | 0 .../65000-char_delete_echo.py | 0 src/fenrir-package/core/screenManager.py | 1 - src/fenrir-package/fenrir.py | 8 ++++---- 8 files changed, 17 insertions(+), 15 deletions(-) rename src/fenrir-package/commands/onInput/{54000-present_char_if_cursor_change_horizontal.py => 45000-present_char_if_cursor_change_horizontal.py} (70%) rename src/fenrir-package/commands/{onScreenUpdate => onInput}/50000-char_echo.py (100%) rename src/fenrir-package/commands/{onScreenUpdate => onInput}/60000-word_echo.py (100%) rename src/fenrir-package/commands/{onScreenUpdate => onInput}/62000-spell_check.py (100%) rename src/fenrir-package/commands/{onScreenUpdate => onInput}/65000-char_delete_echo.py (100%) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 46facad3..448bd691 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -58,7 +58,7 @@ voice= language=english-us # Read new text as it happens? -autoReadIncoming=True +autoReadIncomming=True [braille] #braille is not implemented yet @@ -69,7 +69,7 @@ layout=en driver=linux encoding=cp850 screenUpdateDelay=0.4 -suspendingScreen=1,2 +suspendingScreen= autodetectSuspendingScreen=False [keyboard] @@ -79,13 +79,13 @@ device=all grabDevices=True ignoreShortcuts=False # the current shortcut layout located in /etc/fenrir/keyboard -keyboardLayout=desktop +keyboardLayout=test # echo chars while typing. -charEcho=False +charEcho=True # echo deleted chars charDeleteEcho=True # echo word after pressing space -wordEcho=False +wordEcho=True # interrupt speech on any keypress interruptOnKeyPress=False # timeout for double tap in sec @@ -96,7 +96,7 @@ debugLevel=0 punctuationLevel=1 numberOfClipboards=10 # define the current fenrir key -fenrirKeys=KEY_KP0,KEY_META +fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P dateFormat=%A, %B %d, %Y autoSpellCheck=True diff --git a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py b/src/fenrir-package/commands/onInput/45000-present_char_if_cursor_change_horizontal.py similarity index 70% rename from src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py rename to src/fenrir-package/commands/onInput/45000-present_char_if_cursor_change_horizontal.py index 90954709..f55aba64 100644 --- a/src/fenrir-package/commands/onInput/54000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir-package/commands/onInput/45000-present_char_if_cursor_change_horizontal.py @@ -17,24 +17,27 @@ class command(): return '' def run(self): - + currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']] if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: return - if self.env['runtime']['inputManager'].noKeyPressed(): - return + #if self.env['runtime']['inputManager'].noKeyPressed(): + # return # detect an change on the screen, we just want to cursor arround, so no change should appear if self.env['screenData']['newDelta'] != '': + print('0',currChar ) return if self.env['screenData']['newNegativeDelta'] != '': + print('1',currChar) return # is it a horizontal change? if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y'] or\ self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']: + print('2',currChar, self.env['screenData']['newCursor']['x'],self.env['screenData']['oldCursor']['x'],self.env['screenData']['newCursor']['y'] , self.env['screenData']['oldCursor']['y']) return currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']] if not currChar.strip(" \t\n") == '': self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True) - + print(currChar) def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onScreenUpdate/50000-char_echo.py b/src/fenrir-package/commands/onInput/50000-char_echo.py similarity index 100% rename from src/fenrir-package/commands/onScreenUpdate/50000-char_echo.py rename to src/fenrir-package/commands/onInput/50000-char_echo.py diff --git a/src/fenrir-package/commands/onScreenUpdate/60000-word_echo.py b/src/fenrir-package/commands/onInput/60000-word_echo.py similarity index 100% rename from src/fenrir-package/commands/onScreenUpdate/60000-word_echo.py rename to src/fenrir-package/commands/onInput/60000-word_echo.py diff --git a/src/fenrir-package/commands/onScreenUpdate/62000-spell_check.py b/src/fenrir-package/commands/onInput/62000-spell_check.py similarity index 100% rename from src/fenrir-package/commands/onScreenUpdate/62000-spell_check.py rename to src/fenrir-package/commands/onInput/62000-spell_check.py diff --git a/src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py b/src/fenrir-package/commands/onInput/65000-char_delete_echo.py similarity index 100% rename from src/fenrir-package/commands/onScreenUpdate/65000-char_delete_echo.py rename to src/fenrir-package/commands/onInput/65000-char_delete_echo.py diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index a517cab3..b800f2df 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -23,7 +23,6 @@ class screenManager(): def update(self, trigger = 'onUpdate'): self.env['runtime']['screenDriver'].getCurrScreen() - if not self.isSuspendingScreen(): if trigger == 'onUpdate': self.env['runtime']['applicationManager'].getCurrentApplication() diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index ba7d60bf..121f493f 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -37,11 +37,12 @@ class fenrir(): def handleProcess(self): #startTime = time.time() eventReceived = self.environment['runtime']['inputManager'].getInputEvent() + print(eventReceived) if eventReceived: self.prepareCommand() if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['generalInformation']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen(): self.environment['runtime']['inputManager'].writeEventBuffer() - + time.sleep(0.005) if self.environment['runtime']['inputManager'].noKeyPressed(): if self.wasCommand: self.wasCommand = False @@ -50,9 +51,8 @@ class fenrir(): self.environment['runtime']['inputManager'].clearEventBuffer() if self.environment['input']['keyForeward'] > 0: self.environment['input']['keyForeward'] -=1 - else: - self.environment['runtime']['screenManager'].update('onInput') - self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') + self.environment['runtime']['screenManager'].update('onInput') + self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') else: self.environment['runtime']['screenManager'].update('onUpdate') if self.environment['runtime']['applicationManager'].isApplicationChange():