From f13013f21fc7824cc1a88698a2259b55875e04e6 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 29 Jan 2017 23:12:35 +0100 Subject: [PATCH] improve Braile support --- src/fenrir/core/environment.py | 2 ++ src/fenrir/core/outputManager.py | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/fenrir/core/environment.py b/src/fenrir/core/environment.py index 367305a8..410c8e99 100644 --- a/src/fenrir/core/environment.py +++ b/src/fenrir/core/environment.py @@ -8,6 +8,7 @@ from core import debug from core import settings from core import runtime from core import screenData +from core import output from core import generalInformation from core import commands from core import inputEvent @@ -24,6 +25,7 @@ environment = { 'commandBuffer': commands.commandBuffer, 'input': inputEvent.input, 'punctuation': punctuation.punctuation, +'output': output.output, 'soundIcons': {}, 'bindings': {}, } diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index fc108b94..53950729 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -23,7 +23,7 @@ class outputManager(): self.env['runtime']['settingsManager'].shutdownDriver('speechDriver') self.env['runtime']['settingsManager'].shutdownDriver('brailleDriver') - def presentText(self, text, interrupt=True, soundIcon = '', ignorePunctuation=False, announceCapital=False): + def presentText(self, text, interrupt=True, soundIcon = '', ignorePunctuation=False, announceCapital=False, flush=False): if text == '': return self.env['runtime']['debug'].writeDebugOut("presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO) @@ -98,12 +98,25 @@ class outputManager(): self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) - def brailleText(self, text, interrupt=True): + def brailleText(self, text, flush=False): if not self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled'): return if self.env['runtime']['brailleDriver'] == None: return - self.env['runtime']['brailleDriver'].writeText(text[:35]) + size = self.env['runtime']['brailleDriver'].getDeviceSize() + if flush: + self.env['output']['nextFlush'] = time.time() + 5.0 + self.env['output']['messageText'] = text + + self.env['runtime']['brailleDriver'].writeText(text[:size[0]]) + else: + if self.env['output']['nextFlush'] < time.time(): + if self.env['output']['messageText'] != '': + self.env['output']['messageText'] = '' + cursor = self.env['runtime']['cursorManager'].getReviewOrTextCursor() + x, y, currLine = \ + line_utils.getCurrentLine(cursor['x'], cursor['y'], self.env['screenData']['newContentText']) + self.env['runtime']['brailleDriver'].writeText(currLine[:size[0]]) def interruptOutput(self): self.env['runtime']['speechDriver'].cancel()