add set_window

This commit is contained in:
chrys 2016-09-24 21:35:21 +02:00
parent 8fc5472195
commit 10e1bed491
4 changed files with 92 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -18,6 +18,7 @@ commandBuffer = {
'currClipboard': 0,
'Marks':{'1':None, '2':None},
'bookMarks':{},
'windowArea':{},
}
# used by the commandManager