add offset

This commit is contained in:
chrys 2017-02-02 19:06:53 +01:00
parent a35e33d423
commit 87a9672c03
7 changed files with 64 additions and 43 deletions

View File

@ -80,6 +80,14 @@ flushTimeout=3
# -1 = last cell on device # -1 = last cell on device
# >0 = fix cell number # >0 = fix cell number
fixCursorOnCell=-1 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] [screen]
driver=vcsaDriver driver=vcsaDriver
@ -130,12 +138,6 @@ scriptPath=/usr/share/fenrir/scripts
[focus] [focus]
cursor=True cursor=True
highlight=False 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] [review]
lineBreak=True lineBreak=True

View File

@ -81,6 +81,14 @@ flushTimeout=3
# -1 = last cell on device # -1 = last cell on device
# >0 = fix cell number # >0 = fix cell number
fixCursorOnCell=-1 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] [screen]
driver=vcsaDriver driver=vcsaDriver
@ -133,13 +141,7 @@ scriptPath=/usr/share/fenrir/scripts
cursor=True cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False 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] [review]
lineBreak=True lineBreak=True
endOfScreen=True endOfScreen=True

View File

@ -80,6 +80,14 @@ flushTimeout=3
# -1 = last cell on device # -1 = last cell on device
# >0 = fix cell number # >0 = fix cell number
fixCursorOnCell=-1 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] [screen]
driver=vcsaDriver driver=vcsaDriver
@ -132,12 +140,6 @@ scriptPath=/usr/share/fenrir/scripts
cursor=True cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False 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] [review]
lineBreak=True lineBreak=True

View File

@ -38,6 +38,14 @@ flushTimeout=3
# -1 = last cell on device # -1 = last cell on device
# >0 = fix cell number # >0 = fix cell number
fixCursorOnCell=-1 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] [screen]
driver=vcsaDriver driver=vcsaDriver
@ -83,12 +91,6 @@ scriptPath=/usr/share/fenrir/scripts
cursor=True cursor=True
#follow highlighted text changes #follow highlighted text changes
highlight=False 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] [review]
lineBreak=True lineBreak=True

View File

@ -10,6 +10,6 @@ from core import debug
output = { output = {
'nextFlush': time.time(), 'nextFlush': time.time(),
'messageText': '', 'messageText': '',
'messageOffset': {'x':0,'y':0}, 'messageOffset': None,
'textOffset': {'x':0,'y':0}, 'cursorOffset': None,
} }

View File

@ -107,6 +107,7 @@ class outputManager():
return return
if flush: if flush:
self.env['output']['nextFlush'] = time.time() + self.getFlushTime(text) self.env['output']['nextFlush'] = time.time() + self.getFlushTime(text)
self.env['output']['messageOffset'] = {'x':0,'y':0}
self.env['output']['messageText'] = text self.env['output']['messageText'] = text
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset']) displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['runtime']['brailleDriver'].writeText('flush'+displayText) self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
@ -114,44 +115,55 @@ class outputManager():
if self.env['output']['nextFlush'] < time.time(): if self.env['output']['nextFlush'] < time.time():
if self.env['output']['messageText'] != '': if self.env['output']['messageText'] != '':
self.env['output']['messageText'] = '' self.env['output']['messageText'] = ''
if self.env['output']['messageOffset'] != {'x':0,'y':0}: if self.env['output']['messageOffset'] != None:
self.env['output']['messageOffset'] = {'x':0,'y':0} self.env['output']['messageOffset'] = None
cursor = self.getBrailleCursor() cursor = self.getBrailleCursor()
x, y, currLine = \ x, y, currLine = \
line_utils.getCurrentLine(cursor['x'], cursor['y'], self.env['screenData']['newContentText']) 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) self.env['runtime']['brailleDriver'].writeText('notflush'+displayText)
else: else:
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset']) displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['runtime']['brailleDriver'].writeText('flush'+displayText) self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
def getBrailleCursor(self): 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() 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): def getCursorCell(self):
if self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell') == -1: if self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell') == -1:
return self.env['runtime']['brailleDriver'].getDeviceSize()[0] return self.env['runtime']['brailleDriver'].getDeviceSize()[0]
return self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell') 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 == '': if text == '':
return '' return ''
size = self.env['runtime']['brailleDriver'].getDeviceSize() size = self.env['runtime']['brailleDriver'].getDeviceSize()
cursorCell = self.getCursorCell() cursorCell = self.getCursorCell()
offsetText = text offsetText = text
offsetStart = cursor['x'] + offset['x'] if cursor and not offset:
if offsetStart < size[0]: offsetStart = cursor['x']
if offsetStart <= cursorCell: if offsetStart < size[0]:
return offsetText[0: size[0]] if offsetStart <= cursorCell:
return offsetText[0: size[0]]
offsetStart -= cursorCell offsetStart -= cursorCell
if offsetStart >= len(offsetText): if offsetStart >= len(offsetText):
offsetStart = len(offsetText) - 1 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: if offsetStart < 0:
offsetStart = 0 offsetStart = 0
offsetEnd = offsetStart + size[0] offsetEnd = offsetStart + size[0]
offsetText = offsetText[offsetStart: offsetEnd] offsetText = offsetText[offsetStart: offsetEnd]
return offsetText return offsetText
def interruptOutput(self): def interruptOutput(self):
self.env['runtime']['speechDriver'].cancel() self.env['runtime']['speechDriver'].cancel()

View File

@ -34,6 +34,8 @@ settings = {
'flushMode': 'word', #NONE,FIX,CHAR,WORD 'flushMode': 'word', #NONE,FIX,CHAR,WORD
'flushTimeout': 3, 'flushTimeout': 3,
'fixCursorOnCell': -1, 'fixCursorOnCell': -1,
'cursorFollowMode': 'review', # none, review, last, text
'panSize': 0 # 0 display size
}, },
'screen':{ 'screen':{
'driver': 'vcsaDriver', 'driver': 'vcsaDriver',
@ -61,7 +63,6 @@ settings = {
'focus':{ 'focus':{
'cursor': True, 'cursor': True,
'highlight': False, 'highlight': False,
'brailleFocusMode': 'review', # none, review, last, text
}, },
'review':{ 'review':{
'lineBreak': True, 'lineBreak': True,