diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 5b8854dd..b9657590 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -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 diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index c9ee2052..921c3f42 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -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 diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index f85d7964..e6f0f92c 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -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 diff --git a/src/fenrir/commands/commands/flush_braille.py b/src/fenrir/commands/commands/braille_flush.py similarity index 100% rename from src/fenrir/commands/commands/flush_braille.py rename to src/fenrir/commands/commands/braille_flush.py diff --git a/src/fenrir/commands/commands/braille_pan_left.py b/src/fenrir/commands/commands/braille_pan_left.py new file mode 100644 index 00000000..91eaa66b --- /dev/null +++ b/src/fenrir/commands/commands/braille_pan_left.py @@ -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 diff --git a/src/fenrir/commands/commands/braille_pan_right.py b/src/fenrir/commands/commands/braille_pan_right.py new file mode 100644 index 00000000..b1858237 --- /dev/null +++ b/src/fenrir/commands/commands/braille_pan_right.py @@ -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 diff --git a/src/fenrir/commands/commands/braille_return_to_cursor.py b/src/fenrir/commands/commands/braille_return_to_cursor.py new file mode 100644 index 00000000..687ce776 --- /dev/null +++ b/src/fenrir/commands/commands/braille_return_to_cursor.py @@ -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 diff --git a/src/fenrir/core/outputManager.py b/src/fenrir/core/outputManager.py index 12d06b95..63a34d84 100644 --- a/src/fenrir/core/outputManager.py +++ b/src/fenrir/core/outputManager.py @@ -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 ''