From 6c63317e3308482c6e0b06e4b064e2b7a7e945c4 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 30 Jan 2017 20:30:49 +0100 Subject: [PATCH] add unbound flush_braille command --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 1 + config/settings/espeak.settings.conf | 6 ++++-- config/settings/settings.conf | 6 ++++-- config/settings/settings.conf.chrys | 6 ++++-- config/settings/settings.conf.storm | 6 ++++-- src/fenrir/core/outputManager.py | 22 ++++++++++++++++++++-- src/fenrir/core/settings.py | 2 +- 9 files changed, 40 insertions(+), 11 deletions(-) diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index c2a90c7d..5b8854dd 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -34,6 +34,7 @@ KEY_FENRIR,KEY_KP2=curr_screen_after_cursor #=cursor_read_to_end_of_line #=cursor_column #=cursor_lineno +#=flush_braille KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 65d5398c..c9ee2052 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -33,6 +33,7 @@ KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor #=cursor_read_to_end_of_line #=cursor_column #=cursor_lineno +#=flush_braille KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 4467ccee..f85d7964 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -34,6 +34,7 @@ KEY_FENRIR,KEY_KP5=curr_screen #=cursor_read_to_end_of_line KEY_FENRIR,KEY_KP2=cursor_column KEY_FENRIR,KEY_KP8=cursor_lineno +#=flush_braille KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1 KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_1=bookmark_1 diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 0d027f04..36c7b032 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -67,8 +67,10 @@ enabled=False driver=brlapiDriver layout=en # to what should the flush timeout relate to -# word = flush after seconds * word words -# static = flush after X secods +# word = flush after (number of words to display) * seconds +# char = flush after (number of chars to display) * seconds +# fix = flush after X seconds +# none = no automatic flush (manual via shortcut) flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 940f25d7..eb4e3b60 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -68,8 +68,10 @@ enabled=False driver=brlapiDriver layout=en # to what should the flush timeout relate to -# word = flush after seconds * word words -# static = flush after X secods +# word = flush after (number of words to display) * seconds +# char = flush after (number of chars to display) * seconds +# fix = flush after X seconds +# none = no automatic flush (manual via shortcut) flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index a995c14f..a2bd74c5 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -67,8 +67,10 @@ enabled=False driver=brlapiDriver layout=en # to what should the flush timeout relate to -# word = flush after seconds * word words -# static = flush after X secods +# word = flush after (number of words to display) * seconds +# char = flush after (number of chars to display) * seconds +# fix = flush after X seconds +# none = no automatic flush (manual via shortcut) flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index e9b204c2..a8e311ec 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -25,8 +25,10 @@ enabled=False driver=brlapiDriver layout=en # to what should the flush timeout relate to -# word = flush after seconds * word words -# static = flush after X secods +# word = flush after (number of words to display) * seconds +# char = flush after (number of chars to display) * seconds +# fix = flush after X seconds +# none = no automatic flush (manual via shortcut) flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index ebfe4fa5..9fd6d21c 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -107,7 +107,7 @@ class outputManager(): return size = self.env['runtime']['brailleDriver'].getDeviceSize() if flush: - self.env['output']['nextFlush'] = time.time() + 5.0 + self.env['output']['nextFlush'] = time.time() + self.getFlushTime(text) self.env['output']['messageText'] = text self.env['runtime']['brailleDriver'].writeText('flush'+self.env['output']['messageText'] [self.env['output']['messageOffset']['x']: \ self.env['output']['messageOffset']['x']+size[0]]) @@ -120,6 +120,7 @@ class outputManager(): 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('notflush<>' + currLine +'<>'+currLine[cursor['x']:cursor['x'] + size[0]]) else: self.env['runtime']['brailleDriver'].writeText('flush'+self.env['output']['messageText'] [self.env['output']['messageOffset']['x']: \ @@ -128,8 +129,25 @@ class outputManager(): def interruptOutput(self): self.env['runtime']['speechDriver'].cancel() self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) - + def clearFlushTime(self): + self.setFlushTime(0.0) + + def setFlushTime(self,newTime): + self.env['output']['nextFlush'] = newTime + + def getFlushTime(self,text=''): + if self.env['runtime']['settingsManager'].getSettingAsFloat('braille', 'flushTimeout') < 0 or \ + self.env['runtime']['settingsManager'].getSetting('braille', 'flushMode').upper() == 'NONE': + return 999999999999 + if self.env['runtime']['settingsManager'].getSetting('braille', 'flushMode').upper() == 'FIX': + return self.env['runtime']['settingsManager'].getSettingAsFloat('braille', 'flushTimeout') + if self.env['runtime']['settingsManager'].getSetting('braille', 'flushMode').upper() == 'CHAR': + return self.env['runtime']['settingsManager'].getSettingAsFloat('braille', 'flushTimeout') * len(text) + if self.env['runtime']['settingsManager'].getSetting('braille', 'flushMode').upper() == 'WORD': + wordsList = text.split(' ') + return self.env['runtime']['settingsManager'].getSettingAsFloat('braille', 'flushTimeout') * len( list( filter(None, wordsList) ) ) + def playSoundIcon(self, soundIcon = '', interrupt=True): if soundIcon == '': return False diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 7e4fd945..0687aff8 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -31,7 +31,7 @@ settings = { 'enabled': False, 'driver':'brlapiDriver', 'layout': 'en', - 'flushMode': 'word', + 'flushMode': 'word', #NONE,FIX,CHAR,WORD 'flushTimeout': 3, 'fixCursorOnCell': -1, },