From 0ff4002f16db09cb6045c2f7ef8fc8bd2774a125 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 15 Jul 2016 16:31:19 +0200 Subject: [PATCH] add horizontal and vertical announcements --- .../commands/commands/curr_line.py | 4 ++-- .../commands/commands/exit_review.py | 2 +- .../commands/commands/next_line.py | 4 ++-- .../commands/commands/prev_line.py | 4 ++-- .../commands/onInput/50000-speak_incomming.py | 2 +- .../onScreenChanged/70000-speak_incomming.py | 2 +- src/fenrir-package/core/outputManager.py | 2 +- src/fenrir-package/fenrir.py | 4 ++-- src/fenrir-package/screen/linux.py | 22 ++++++++++++------- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/fenrir-package/commands/commands/curr_line.py b/src/fenrir-package/commands/commands/curr_line.py index 36bb43b3..66013d1f 100644 --- a/src/fenrir-package/commands/commands/curr_line.py +++ b/src/fenrir-package/commands/commands/curr_line.py @@ -9,9 +9,9 @@ class command(): environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '': - environment['runtime']['outputManager'].speakText(environment, "blank") + environment['runtime']['outputManager'].presentText(environment, "blank") else: - environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/exit_review.py b/src/fenrir-package/commands/commands/exit_review.py index 35a17b91..453317d8 100644 --- a/src/fenrir-package/commands/commands/exit_review.py +++ b/src/fenrir-package/commands/commands/exit_review.py @@ -6,7 +6,7 @@ class command(): def run(self, environment): environment['screenData']['oldCursorReview'] = {'x':-1,'y':-1} environment['screenData']['newCursorReview'] = {'x':-1,'y':-1} - environment['runtime']['outputManager'].speakText(environment, "leve review mode") + environment['runtime']['outputManager'].presentText(environment, "leve review mode") return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/next_line.py b/src/fenrir-package/commands/commands/next_line.py index 9a64b30d..1152a806 100644 --- a/src/fenrir-package/commands/commands/next_line.py +++ b/src/fenrir-package/commands/commands/next_line.py @@ -11,9 +11,9 @@ class command(): environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] + 1 if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '': - environment['runtime']['outputManager'].speakText(environment, "blank") + environment['runtime']['outputManager'].presentText(environment, "blank") else: - environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/prev_line.py b/src/fenrir-package/commands/commands/prev_line.py index 4d6bba03..b498e29b 100644 --- a/src/fenrir-package/commands/commands/prev_line.py +++ b/src/fenrir-package/commands/commands/prev_line.py @@ -10,9 +10,9 @@ class command(): if environment['screenData']['newCursorReview']['y'] - 1 >= 0: environment['screenData']['newCursorReview']['y'] = environment['screenData']['newCursorReview']['y'] - 1 if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']].replace(" ","").replace("\n","").replace("\t","") == '': - environment['runtime']['outputManager'].speakText(environment, "blank") + environment['runtime']['outputManager'].presentText(environment, "blank") else: - environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursorReview']['y']]) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onInput/50000-speak_incomming.py b/src/fenrir-package/commands/onInput/50000-speak_incomming.py index 665d6876..2fd954c4 100644 --- a/src/fenrir-package/commands/onInput/50000-speak_incomming.py +++ b/src/fenrir-package/commands/onInput/50000-speak_incomming.py @@ -10,7 +10,7 @@ class command(): return environment if environment['screenData']['newDelta'] != environment['screenData']['oldDelta'] or \ environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: - environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newDelta'], Interrupt=False) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], Interrupt=False) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py b/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py index 18980365..444162fa 100644 --- a/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py +++ b/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py @@ -6,7 +6,7 @@ class command(): def run(self, environment): if environment['screenData']['newDelta'] != environment['screenData']['oldDelta'] or \ environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: - environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newDelta']) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta']) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index 73c1633f..5d06648f 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -24,7 +24,7 @@ class outputManager(): environment['runtime']['speechDriver'].speak(Text) def brailleText(self, environment, Text): - if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braile', 'enabled'): + if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): return print('braille') def interruptOutput(self, environment): diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 48409085..39fc02c5 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -31,7 +31,7 @@ class fenrir(): while(self.environment['generalInformation']['running']): self.environment = self.environment['runtime']['inputManager'].getKeyPressed(self.environment) self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment) - self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment) + self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput') self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput') if self.environment['commandInfo']['currCommand'] != '': self.environment['input']['currShortcut'] = {} @@ -41,7 +41,7 @@ class fenrir(): def updateScreen(self): self.environment['runtime']['globalLock'].acquire(True) - self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment) + self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen') self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') self.environment['runtime']['globalLock'].release() time.sleep(0.5) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 8b839110..73ef28d3 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -12,7 +12,7 @@ class screen(): self.vcsaDevicePath = device self.textWrapper = textwrap.TextWrapper() self.textWrapper.drop_whitespace = False - def analyzeScreen(self, environment): + def analyzeScreen(self, environment, trigger='updateScreen'): # set new "old" values environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes'] environment['screenData']['oldContentText'] = environment['screenData']['newContentText'] @@ -21,21 +21,27 @@ class screen(): environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y'] environment['screenData']['oldTTY'] = environment['screenData']['newTTY'] environment['screenData']['oldDelta'] = environment['screenData']['newDelta'] - + newTTY = environment['screenData']['newTTY'] # read screen currTTY = open('/sys/devices/virtual/tty/tty0/active','r') - environment['screenData']['newTTY'] = currTTY.read()[3:-1] + newTTY = currTTY.read()[3:-1] currTTY.close() - + newContentBytes = b'' try: - vcsa = open(self.vcsaDevicePath + environment['screenData']['newTTY'] ,'rb',0) - environment['screenData']['newContentBytes'] = vcsa.read() + vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) + newContentBytes = vcsa.read() vcsa.close() - if len(environment['screenData']['newContentBytes']) < 5: + if len(newContentBytes) < 5: return environment except: return environment - + if trigger != 'onInput': + if ((newContentBytes[2] != environment['screenData']['oldCursor']['x']) or\ + (newContentBytes[3] != environment['screenData']['oldCursor']['y'])) and\ + (newTTY == environment['screenData']['oldTTY']): + return environment + environment['screenData']['newTTY'] = newTTY + environment['screenData']['newContentBytes'] = newContentBytes # get metadata like cursor or screensize environment['screenData']['lines'] = int( environment['screenData']['newContentBytes'][0]) environment['screenData']['columns'] = int( environment['screenData']['newContentBytes'][1])