add initial cursor tracking

This commit is contained in:
chrys 2017-02-02 00:39:22 +01:00
parent 9864f924aa
commit 1b05bbfc1c
2 changed files with 36 additions and 9 deletions

View File

@ -32,6 +32,6 @@ class command():
self.env['runtime']['outputManager'].presentText('end of screen' ,interrupt=True, soundIcon='EndOfScreen') self.env['runtime']['outputManager'].presentText('end of screen' ,interrupt=True, soundIcon='EndOfScreen')
if lineBreak: if lineBreak:
if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'lineBreak'): if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'lineBreak'):
self.env['runtime']['outputManager'].presentText('line break' ,interrupt=False, soundIcon='EndOfLine) self.env['runtime']['outputManager'].presentText('line break' ,interrupt=False, soundIcon='EndOfLine')
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -105,27 +105,54 @@ class outputManager():
return return
if self.env['runtime']['brailleDriver'] == None: if self.env['runtime']['brailleDriver'] == None:
return return
size = self.env['runtime']['brailleDriver'].getDeviceSize()
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']['messageText'] = text self.env['output']['messageText'] = text
self.env['runtime']['brailleDriver'].writeText('flush'+self.env['output']['messageText'] [self.env['output']['messageOffset']['x']: \ displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['output']['messageOffset']['x']+size[0]]) self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
else: else:
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'] != {'x':0,'y':0}:
self.env['output']['messageOffset'] = {'x':0,'y':0} self.env['output']['messageOffset'] = {'x':0,'y':0}
cursor = self.env['runtime']['cursorManager'].getReviewOrTextCursor() 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)
self.env['runtime']['brailleDriver'].writeText('notflush<>' + currLine +'<>'+currLine[cursor['x']:cursor['x'] + size[0]]) self.env['runtime']['brailleDriver'].writeText('notflush'+displayText)
else: else:
self.env['runtime']['brailleDriver'].writeText('flush'+self.env['output']['messageText'] [self.env['output']['messageOffset']['x']: \ displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
self.env['output']['messageOffset']['x']+size[0]]) self.env['runtime']['brailleDriver'].writeText('flush'+displayText)
def getBrailleCursor(self):
if self.env['runtime']['settingsManager'].getSetting('focus', 'brailleFocusMode') == 'review':
return self.env['runtime']['cursorManager'].getReviewOrTextCursor()
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):
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]]
offsetStart -= cursorCell
if offsetStart >= len(offsetText):
offsetStart = len(offsetText) - 1
if offsetStart < 0:
offsetStart = 0
offsetEnd = offsetStart + size[0]
offsetText = offsetText[offsetStart: offsetEnd]
return offsetText
def interruptOutput(self): def interruptOutput(self):
self.env['runtime']['speechDriver'].cancel() self.env['runtime']['speechDriver'].cancel()
self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Interrupt speech",debug.debugLevel.INFO)