From 87a9672c039a7681eefb4a4d42dad50340743820 Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 2 Feb 2017 19:06:53 +0100 Subject: [PATCH] add offset --- config/settings/espeak.settings.conf | 14 ++++++---- config/settings/settings.conf | 16 ++++++----- config/settings/settings.conf.chrys | 14 ++++++---- config/settings/settings.conf.storm | 14 ++++++---- src/fenrir/core/output.py | 4 +-- src/fenrir/core/outputManager.py | 42 ++++++++++++++++++---------- src/fenrir/core/settings.py | 3 +- 7 files changed, 64 insertions(+), 43 deletions(-) diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index b3731e3c..017e3e7a 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -80,6 +80,14 @@ flushTimeout=3 # -1 = last cell on device # >0 = fix cell number fixCursorOnCell=-1 +#How should the braille follow the focus +# none = no automatic toggle command used +# review = priority to review +# last = follow last used cursor +cursorFollowMode=review +# number of cells in panning +# 0 = display size, >0 number of cells +panSize=0 [screen] driver=vcsaDriver @@ -130,12 +138,6 @@ scriptPath=/usr/share/fenrir/scripts [focus] cursor=True highlight=False -# How should the braille follow the focus -# none = no automatic toggle command used -# review = priority to review -# last = follow last used cursor -# text = jumps to textcursor when typing, needs command to be back to review -brailleFocusMode=review [review] lineBreak=True diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 144cadae..e5e63eed 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -81,6 +81,14 @@ flushTimeout=3 # -1 = last cell on device # >0 = fix cell number fixCursorOnCell=-1 +#How should the braille follow the focus +# none = no automatic toggle command used +# review = priority to review +# last = follow last used cursor +cursorFollowMode=review +# number of cells in panning +# 0 = display size, >0 number of cells +panSize=0 [screen] driver=vcsaDriver @@ -133,13 +141,7 @@ scriptPath=/usr/share/fenrir/scripts cursor=True #follow highlighted text changes highlight=False -#How should the braille follow the focus -# none = no automatic toggle command used -# review = priority to review -# last = follow last used cursor -# text = jumps to textcursor when typing, needs command to be back to review -brailleFocusMode=review - + [review] lineBreak=True endOfScreen=True diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index c6276b54..c6a99c5e 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -80,6 +80,14 @@ flushTimeout=3 # -1 = last cell on device # >0 = fix cell number fixCursorOnCell=-1 +#How should the braille follow the focus +# none = no automatic toggle command used +# review = priority to review +# last = follow last used cursor +cursorFollowMode=review +# number of cells in panning +# 0 = display size, >0 number of cells +panSize=0 [screen] driver=vcsaDriver @@ -132,12 +140,6 @@ scriptPath=/usr/share/fenrir/scripts cursor=True #follow highlighted text changes highlight=False -# How should the braille follow the focus -# none = no automatic toggle command used -# review = priority to review -# last = follow last used cursor -# text = jumps to textcursor when typing, needs command to be back to review -brailleFocusMode=review [review] lineBreak=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index d55abe7e..c1107bde 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -38,6 +38,14 @@ flushTimeout=3 # -1 = last cell on device # >0 = fix cell number fixCursorOnCell=-1 +#How should the braille follow the focus +# none = no automatic toggle command used +# review = priority to review +# last = follow last used cursor +cursorFollowMode=review +# number of cells in panning +# 0 = display size, >0 number of cells +panSize=0 [screen] driver=vcsaDriver @@ -83,12 +91,6 @@ scriptPath=/usr/share/fenrir/scripts cursor=True #follow highlighted text changes highlight=False -# How should the braille follow the focus -# none = no automatic toggle command used -# review = priority to review -# last = follow last used cursor -# text = jumps to textcursor when typing, needs command to be back to review -brailleFocusMode=review [review] lineBreak=True diff --git a/src/fenrir/core/output.py b/src/fenrir/core/output.py index 82f69339..b029e332 100644 --- a/src/fenrir/core/output.py +++ b/src/fenrir/core/output.py @@ -10,6 +10,6 @@ from core import debug output = { 'nextFlush': time.time(), 'messageText': '', -'messageOffset': {'x':0,'y':0}, -'textOffset': {'x':0,'y':0}, +'messageOffset': None, +'cursorOffset': None, } diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index c7c6fa99..9323a19a 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -107,6 +107,7 @@ class outputManager(): return if flush: self.env['output']['nextFlush'] = time.time() + self.getFlushTime(text) + self.env['output']['messageOffset'] = {'x':0,'y':0} self.env['output']['messageText'] = text displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset']) self.env['runtime']['brailleDriver'].writeText('flush'+displayText) @@ -114,44 +115,55 @@ class outputManager(): if self.env['output']['nextFlush'] < time.time(): if self.env['output']['messageText'] != '': self.env['output']['messageText'] = '' - if self.env['output']['messageOffset'] != {'x':0,'y':0}: - self.env['output']['messageOffset'] = {'x':0,'y':0} + if self.env['output']['messageOffset'] != None: + self.env['output']['messageOffset'] = None cursor = self.getBrailleCursor() x, y, currLine = \ line_utils.getCurrentLine(cursor['x'], cursor['y'], self.env['screenData']['newContentText']) - displayText = self.getBrailleTextWithOffset(currLine, self.env['output']['textOffset'], cursor, flush=True) + displayText = self.getBrailleTextWithOffset(currLine, self.env['output']['cursorOffset'], cursor) self.env['runtime']['brailleDriver'].writeText('notflush'+displayText) else: displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset']) self.env['runtime']['brailleDriver'].writeText('flush'+displayText) def getBrailleCursor(self): - if self.env['runtime']['settingsManager'].getSetting('focus', 'brailleFocusMode') == 'review': + if self.env['runtime']['settingsManager'].getSetting('focus', 'cursorFollowMode') == 'review': return self.env['runtime']['cursorManager'].getReviewOrTextCursor() - + self.env['runtime']['settingsManager'].getSetting('focus', 'cursorFollowMode') == 'manual': + pass + self.env['runtime']['settingsManager'].getSetting('focus', 'cursorFollowMode') == 'last': + pass def getCursorCell(self): if self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell') == -1: return self.env['runtime']['brailleDriver'].getDeviceSize()[0] return self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell') - def getBrailleTextWithOffset(self, text, offset = {'x':0,'y':0}, cursor = {'x':0,'y':0}, flush=True): + def getBrailleTextWithOffset(self, text, offset = None, cursor = None): if text == '': return '' size = self.env['runtime']['brailleDriver'].getDeviceSize() cursorCell = self.getCursorCell() offsetText = text - offsetStart = cursor['x'] + offset['x'] - if offsetStart < size[0]: - if offsetStart <= cursorCell: - return offsetText[0: size[0]] + if cursor and not offset: + offsetStart = cursor['x'] + if offsetStart < size[0]: + if offsetStart <= cursorCell: + return offsetText[0: size[0]] - offsetStart -= cursorCell - if offsetStart >= len(offsetText): - offsetStart = len(offsetText) - 1 + offsetStart -= cursorCell + if offsetStart >= len(offsetText): + offsetStart = len(offsetText) - 1 + else: + if not offset: + offset = {'x':0,'y':0} + offsetStart = offset['x'] + if offsetStart >= len(offsetText): + offsetStart = len(offsetText) - size[0] + if offsetStart < 0: - offsetStart = 0 + offsetStart = 0 offsetEnd = offsetStart + size[0] - offsetText = offsetText[offsetStart: offsetEnd] + offsetText = offsetText[offsetStart: offsetEnd] return offsetText def interruptOutput(self): self.env['runtime']['speechDriver'].cancel() diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 93b11335..469d72b1 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -34,6 +34,8 @@ settings = { 'flushMode': 'word', #NONE,FIX,CHAR,WORD 'flushTimeout': 3, 'fixCursorOnCell': -1, + 'cursorFollowMode': 'review', # none, review, last, text + 'panSize': 0 # 0 display size }, 'screen':{ 'driver': 'vcsaDriver', @@ -61,7 +63,6 @@ settings = { 'focus':{ 'cursor': True, 'highlight': False, - 'brailleFocusMode': 'review', # none, review, last, text }, 'review':{ 'lineBreak': True,