add panning functionality; commands to move panning and reset to cursor; add the commands unbound

This commit is contained in:
chrys 2017-02-03 00:11:01 +01:00
parent d88945ee01
commit d440147340
8 changed files with 119 additions and 19 deletions

View File

@ -34,7 +34,10 @@ KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
#=cursor_read_to_end_of_line
#=cursor_column
#=cursor_lineno
#=flush_braille
#=braille_flush
#=braille_return_to_cursor
#=braille_pan_left
#=braille_pan_right
KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1
KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1
KEY_FENRIR,KEY_1=bookmark_1

View File

@ -33,7 +33,10 @@ KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor
#=cursor_read_to_end_of_line
#=cursor_column
#=cursor_lineno
#=flush_braille
#=braille_flush
#=braille_return_to_cursor
#=braille_pan_left
#=braille_pan_right
KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1
KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1
KEY_FENRIR,KEY_1=bookmark_1

View File

@ -34,7 +34,10 @@ 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
#=braille_flush
#=braille_return_to_cursor
#=braille_pan_left
#=braille_pan_right
KEY_FENRIR,KEY_CTRL,KEY_1=clear_bookmark_1
KEY_FENRIR,KEY_SHIFT,KEY_1=set_bookmark_1
KEY_FENRIR,KEY_1=bookmark_1

View File

@ -0,0 +1,21 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'Move braille view to the left.'
def run(self):
panned = self.env['runtime']['outputManager'].setPanLeft()
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'Move braille view to the right.'
def run(self):
panned = self.env['runtime']['outputManager'].setPanRight()
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'Set the braille view back to cursor.'
def run(self):
self.env['runtime']['outputManager'].removePanning()
def setCallback(self, callback):
pass

View File

@ -118,9 +118,9 @@ class outputManager():
if self.env['output']['messageOffset'] != None:
self.env['output']['messageOffset'] = None
cursor = self.getBrailleCursor()
x, y, currLine = \
x, y, self.env['output']['brlText'] = \
line_utils.getCurrentLine(cursor['x'], cursor['y'], self.env['screenData']['newContentText'])
displayText = self.getBrailleTextWithOffset(currLine, self.env['output']['cursorOffset'], cursor)
displayText = self.getBrailleTextWithOffset(self.env['screenData']['newContentText'], self.env['output']['cursorOffset'], cursor)
self.env['runtime']['brailleDriver'].writeText('notflush'+displayText)
else:
displayText = self.getBrailleTextWithOffset(self.env['output']['messageText'], self.env['output']['messageOffset'])
@ -136,13 +136,19 @@ class outputManager():
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')
def getActiveOffset(self):
size = self.env['runtime']['brailleDriver'].getDeviceSize()[0]
fixCell = self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'fixCursorOnCell')
if fixCell <= -1:
return size[0]
if fixCell >= size[0]:
return size[0]
return fixCell
def getActiveOffsetAndText(self):
if self.env['output']['messageOffset']:
return self.env['output']['messageOffset']
return self.env['output']['cursorOffset']
return self.env['output']['messageOffset'], self.env['output']['messageText']
if not self.env['output']['cursorOffset']:
return self.getBrailleCursor(), self.env['screenData']['newContentText']
return self.env['output']['cursorOffset'], self.env['screenData']['newContentText']
def getHorizontalPanSize(self):
size = self.env['runtime']['brailleDriver'].getDeviceSize()
if self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'panSizeHorizontal') <= 0:
@ -151,15 +157,37 @@ class outputManager():
return size[0]
return self.env['runtime']['settingsManager'].getSettingAsInt('braille', 'panSizeHorizontal')
def getHorizontalPanLevel(self,offsetChange = 0):
panned = True
panSize = self.getHorizontalPanSize()
offset = self.getActiveOffset()
if not offset:
offset = self.getBrailleCursor()
offsetStart = (int(offset['x'] / panSize) + offsetChange) * panSize
def panLeft(self):
return self.getHorizontalPanLevel(-1)
def panRight(self):
return self.getHorizontalPanLevel(1)
offset, text = self.getActiveOffsetAndText()
currline = text.split('\n')[offset['y']]
newOffsetStart = (int(offset['x'] / panSize) + offsetChange) * panSize
if newOffsetStart < 0:
newOffsetStart = 0
panned = False
if newOffsetStart >= len(text):
newOffsetStart = int((len(text) - panSize - 1) / panSize)
panned = False
return newOffsetStart, panned
def setPanLeft(self):
newPan, panned = self.getHorizontalPanLevel(-1)
if self.env['output']['messageOffset']:
self.env['output']['messageOffset'] = newPan.copy()
else:
self.env['output']['cursorOffset'] = newPan.copy()
return panned
def setPanRight(self):
newPan, panned = self.getHorizontalPanLevel(1)
if self.env['output']['messageOffset']:
self.env['output']['messageOffset'] = newPan.copy()
else:
self.env['output']['cursorOffset'] = newPan.copy()
return panned
def removePanning(self):
if self.env['output']['messageOffset']:
self.env['output']['messageOffset'] = None
else:
self.env['output']['cursorOffset'] = None
def getBrailleTextWithOffset(self, text, offset = None, cursor = None):
if text == '':
return ''