diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 1e599640..b66929ea 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -21,8 +21,9 @@ KEY_FENRIR,KEY_KPDOT=exit_review KEY_FENRIR,KEY_KP5=curr_screen KEY_FENRIR,KEY_KP8=curr_screen_before_cursor KEY_FENRIR,KEY_KP2=curr_screen_after_cursor +KEY_FENRIR,KEY_1=set_window KEY_FENRIR,KEY_3=clear_bookmark_1 -KEY_FENRIR,KEY_1=set_bookmark_1 +#KEY_FENRIR,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_2=bookmark_1 KEY_KPPLUS=last_incomming KEY_FENRIR,KEY_F2=toggle_braille diff --git a/src/fenrir-package/commands/commands/bookmark_1.py b/src/fenrir-package/commands/commands/bookmark_1.py new file mode 100644 index 00000000..0ecd7285 --- /dev/null +++ b/src/fenrir-package/commands/commands/bookmark_1.py @@ -0,0 +1,48 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug +from utils import mark_utils +from utils import line_utils + +class command(): + def __init__(self): + self.ID = '1' + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + return 'read Bookmark ' + self.ID + + def run(self): + currApp = self.env['runtime']['applicationManager'].getCurrentApplication() + if not self.env['commandBuffer']['bookMarks'][self.ID]: + self.env['runtime']['outputManager'].presentText("Bookmark " + self.ID + "not set", interrupt=True) + return + if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]: + self.env['runtime']['outputManager'].presentText("Bookmark for application " + currApp + " not set", interrupt=True) + return + if not self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']: + self.env['runtime']['outputManager'].presentText("Bookmark for application " + currApp + " not set", interrupt=True) + return + print('i',self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1']) + # set marks + marked = '' + startMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['1'].copy() + if self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2']: + endMark = self.env['commandBuffer']['bookMarks'][self.ID][currApp]['2'].copy() + marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText']) + else: + x, y, marked = \ + line_utils.getCurrentLine(startMark['x'], startMark['y'], self.env['screenData']['newContentText']) + if marked.strip(" \t\n") == '': + self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText(marked, interrupt=True) + + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/commands/commands/set_window.py b/src/fenrir-package/commands/commands/set_window.py new file mode 100644 index 00000000..d1521296 --- /dev/null +++ b/src/fenrir-package/commands/commands/set_window.py @@ -0,0 +1,41 @@ +#!/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 Window Mode, needs 2 marks ' + + def run(self): + if not self.env['commandBuffer']['Marks']['1']: + self.env['runtime']['outputManager'].presentText("No Mark found", interrupt=True) + return + if not self.env['commandBuffer']['Marks']['2']: + self.env['runtime']['outputManager'].presentText("to few makrs found", interrupt=True) + return + currApp = self.env['runtime']['applicationManager'].getCurrentApplication() + self.env['commandBuffer']['windowArea'][currApp] = {} + + if self.env['commandBuffer']['Marks']['1']['x'] * self.env['commandBuffer']['Marks']['1']['y'] <= \ + self.env['commandBuffer']['Marks']['2']['x'] * self.env['commandBuffer']['Marks']['2']['y']: + self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['1'].copy() + self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['2'].copy() + else: + self.env['commandBuffer']['windowArea'][currApp]['1'] = self.env['commandBuffer']['Marks']['2'].copy() + self.env['commandBuffer']['windowArea'][currApp]['2'] = self.env['commandBuffer']['Marks']['1'].copy() + + self.env['runtime']['outputManager'].presentText('Window Mode set for application ' + currApp, interrupt=True) + self.env['commandBuffer']['Marks']['1'] = None + self.env['commandBuffer']['Marks']['2'] = None + def setCallback(self, callback): + pass diff --git a/src/fenrir-package/core/commands.py b/src/fenrir-package/core/commands.py index 04b54489..3e8ead6a 100644 --- a/src/fenrir-package/core/commands.py +++ b/src/fenrir-package/core/commands.py @@ -18,6 +18,7 @@ commandBuffer = { 'currClipboard': 0, 'Marks':{'1':None, '2':None}, 'bookMarks':{}, +'windowArea':{}, } # used by the commandManager