From e9332caa93dae7d9c5796a83aea877c473d27efa Mon Sep 17 00:00:00 2001 From: chrys Date: Thu, 2 Feb 2017 19:31:47 +0100 Subject: [PATCH] add page mode. make fixCell/page mode configurable --- config/settings/espeak.settings.conf | 4 ++++ config/settings/settings.conf | 4 ++++ config/settings/settings.conf.chrys | 4 ++++ config/settings/settings.conf.storm | 4 ++++ src/fenrir/core/outputManager.py | 36 +++++++++++++++++----------- src/fenrir/core/settings.py | 1 + 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/config/settings/espeak.settings.conf b/config/settings/espeak.settings.conf index 017e3e7a..f91a7ab9 100644 --- a/config/settings/espeak.settings.conf +++ b/config/settings/espeak.settings.conf @@ -75,6 +75,10 @@ flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) flushTimeout=3 +# how should the cursor be focused? +# page = if cursor cross the border move to next page and start at beginn +# fixCell = ajust the cursor on an special cell where it is always placed. the display scroll here more smooth. +cursorFocusMode=page # define the cell on the Braille device where fenrir should scroll and keep the cursor # 0 = first cell on device # -1 = last cell on device diff --git a/config/settings/settings.conf b/config/settings/settings.conf index e5e63eed..6cbed664 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -76,6 +76,10 @@ flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) flushTimeout=3 +# how should the cursor be focused? +# page = if cursor cross the border move to next page and start at beginn +# fixCell = ajust the cursor on an special cell where it is always placed. the display scroll here more smooth. +cursorFocusMode=page # define the cell on the Braille device where fenrir should scroll and keep the cursor # 0 = first cell on device # -1 = last cell on device diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index c6a99c5e..c154090c 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -75,6 +75,10 @@ flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) flushTimeout=3 +# how should the cursor be focused? +# page = if cursor cross the border move to next page and start at beginn +# fixCell = ajust the cursor on an special cell where it is always placed. the display scroll here more smooth. +cursorFocusMode=page # define the cell on the Braille device where fenrir should scroll and keep the cursor # 0 = first cell on device # -1 = last cell on device diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index c1107bde..8efa1b0f 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -33,6 +33,10 @@ flushMode=word # seconds to flush or # -1 = no automatic flush (manual via shortcut) flushTimeout=3 +# how should the cursor be focused? +# page = if cursor cross the border move to next page and start at beginn +# fixCell = ajust the cursor on an special cell where it is always placed. the display scroll here more smooth. +cursorFocusMode=page # define the cell on the Braille device where fenrir should scroll and keep the cursor # 0 = first cell on device # -1 = last cell on device diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index 9323a19a..73ac8760 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -127,13 +127,15 @@ class outputManager(): self.env['runtime']['brailleDriver'].writeText('flush'+displayText) def getBrailleCursor(self): - if self.env['runtime']['settingsManager'].getSetting('focus', 'cursorFollowMode') == 'review': + if self.env['runtime']['settingsManager'].getSetting('braille', 'cursorFollowMode').upper() == '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'].getSetting('braille', 'cursorFollowMode').upper() == 'MANUAL': + return self.env['runtime']['cursorManager'].getReviewOrTextCursor() + if self.env['runtime']['settingsManager'].getSetting('braille', 'cursorFollowMode').upper() == 'LAST': + return self.env['runtime']['cursorManager'].getReviewOrTextCursor() + return self.env['runtime']['cursorManager'].getReviewOrTextCursor() + + def getFixCursorCell(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') @@ -142,17 +144,23 @@ class outputManager(): if text == '': return '' size = self.env['runtime']['brailleDriver'].getDeviceSize() - cursorCell = self.getCursorCell() + offsetText = text if cursor and not offset: - offsetStart = cursor['x'] - if offsetStart < size[0]: - if offsetStart <= cursorCell: - return offsetText[0: size[0]] + if self.env['runtime']['settingsManager'].getSetting('braille', 'cursorFollowMode').upper() == 'FIXCELL': + #fix cell + cursorCell = self.getFixCursorCell() + 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: + # page and fallback + offsetStart = int(cursor / size[0]) * size[0] else: if not offset: offset = {'x':0,'y':0} diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 469d72b1..45ccb131 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -33,6 +33,7 @@ settings = { 'layout': 'en', 'flushMode': 'word', #NONE,FIX,CHAR,WORD 'flushTimeout': 3, + 'cursorFocusMode':'page', # page,fixCell 'fixCursorOnCell': -1, 'cursorFollowMode': 'review', # none, review, last, text 'panSize': 0 # 0 display size