set/remove window for application

This commit is contained in:
chrys 2016-09-24 22:56:18 +02:00
parent 10e1bed491
commit c05382e828
11 changed files with 108 additions and 47 deletions

7
TODO
View File

@ -17,7 +17,8 @@ ToDos in Priority order:
possiblity to forewart shortcut (or use them as shortcut) [pressing twice while timeout] possiblity to forewart shortcut (or use them as shortcut) [pressing twice while timeout]
cleanup inputManager cleanup inputManager
split input driver out of the handler split input driver out of the handler
- respect window mode in differ (getwindow code is already in place)
- dictonary for special chars and string replacements - dictonary for special chars and string replacements
- punctuation - punctuation
@ -27,8 +28,6 @@ ToDos in Priority order:
per application onInput per application onInput
- per application shortcuts - per application shortcuts
- implement commands - implement commands
define_window
remove_window
attributes_curr_char attributes_curr_char
toggle_highlighted_mode toggle_highlighted_mode
generic list command (convert clipboard management) generic list command (convert clipboard management)
@ -175,6 +174,8 @@ ps a -o tty,comm | grep -e Xorg | grep -v "grep -e Xorg"
last_clipboard last_clipboard
curr_clipboard curr_clipboard
paste_clipboard paste_clipboard
define_window
remove_window
reset_review_on_screen_change reset_review_on_screen_change
remove_clipboard_marks remove_clipboard_marks
copy_marked copy_marked

View File

@ -24,6 +24,8 @@ KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
#=clear_bookmark_1 #=clear_bookmark_1
#=set_bookmark_1 #=set_bookmark_1
#=bookmark_1 #=bookmark_1
#=set_window_application
#=clear_window_application
KEY_KPPLUS=last_incomming KEY_KPPLUS=last_incomming
KEY_FENRIR,KEY_F2=toggle_braille KEY_FENRIR,KEY_F2=toggle_braille
KEY_FENRIR,KEY_F3=toggle_sound KEY_FENRIR,KEY_F3=toggle_sound

View File

@ -23,6 +23,8 @@ KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor
#=clear_bookmark_1 #=clear_bookmark_1
#=set_bookmark_1 #=set_bookmark_1
#=bookmark_1 #=bookmark_1
#=set_window_application
#=clear_window_application
2,KEY_FENRIR,KEY_I=indent_curr_line 2,KEY_FENRIR,KEY_I=indent_curr_line
KEY_FENRIR,KEY_SEMICOLON=last_incomming KEY_FENRIR,KEY_SEMICOLON=last_incomming
KEY_FENRIR,KEY_F2=toggle_braille KEY_FENRIR,KEY_F2=toggle_braille

View File

@ -21,7 +21,8 @@ KEY_FENRIR,KEY_KPDOT=exit_review
KEY_FENRIR,KEY_KP5=curr_screen KEY_FENRIR,KEY_KP5=curr_screen
KEY_FENRIR,KEY_KP8=curr_screen_before_cursor KEY_FENRIR,KEY_KP8=curr_screen_before_cursor
KEY_FENRIR,KEY_KP2=curr_screen_after_cursor KEY_FENRIR,KEY_KP2=curr_screen_after_cursor
KEY_FENRIR,KEY_1=set_window KEY_FENRIR,KEY_1=set_window_application
KEY_FENRIR,KEY_3=clear_window_application
KEY_FENRIR,KEY_3=clear_bookmark_1 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_FENRIR,KEY_2=bookmark_1

View File

@ -79,7 +79,7 @@ device=all
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False
# the current shortcut layout located in /etc/fenrir/keyboard # the current shortcut layout located in /etc/fenrir/keyboard
keyboardLayout=desktop keyboardLayout=test
# echo chars while typing. # echo chars while typing.
charEcho=False charEcho=False
# echo deleted chars # echo deleted chars

View File

@ -0,0 +1,26 @@
#!/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 'Turn off window mode for application'
def run(self):
if self.env['runtime']['cursorManager'].clearWindowForApplication():
self.env['runtime']['outputManager'].presentText('Window Mode off for application ' + currApp, interrupt=True)
else:
self.env['runtime']['outputManager'].presentText("Not in window Mode", interrupt=True)
def setCallback(self, callback):
pass

View File

@ -1,41 +0,0 @@
#!/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

@ -0,0 +1,27 @@
#!/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 self.env['runtime']['cursorManager'].setWindowForApplication():
self.env['runtime']['outputManager'].presentText('Window Mode on for application ' + currApp, interrupt=True)
self.env['runtime']['cursorManager'].clearMarks()
else:
self.env['runtime']['outputManager'].presentText("Set window beginn and end marks", interrupt=True)
def setCallback(self, callback):
pass

View File

@ -42,4 +42,33 @@ class cursorManager():
def enterReviewModeCurrTextCursor(self): def enterReviewModeCurrTextCursor(self):
self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if not self.env['screenData']['newCursorReview']: if not self.env['screenData']['newCursorReview']:
self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
def isApplicationWindowSet(self):
try:
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
return self.env['commandBuffer']['windowArea'][currApp]['1'] != None
except:
return False
def setWindowForApplication(self):
if not self.env['commandBuffer']['Marks']['1']:
return False
if not self.env['commandBuffer']['Marks']['2']:
return False
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()
return True
def clearWindowForApplication(self):
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
try:
del self.env['commandBuffer']['windowArea'][currApp]
except:
return False
return True

View File

@ -33,3 +33,14 @@ class screenManager():
(currScreen in self.autoIgnoreScreens)) (currScreen in self.autoIgnoreScreens))
def isScreenChange(self): def isScreenChange(self):
return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY'] return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']
def getWindowAreaInText(self, text):
if not self.env['runtime']['cursorManager'].isApplicationWindowSet():
return text
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
windowText = ''
windowList = text.split('\n')
windowList = windowList[self.env['commandBuffer']['windowArea'][currApp]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1]
for line in windowList:
windowText += line[self.env['commandBuffer']['windowArea'][currApp]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n'
return windowText

View File

@ -122,6 +122,9 @@ class driver():
self.env['screenData']['newNegativeDelta'] = '' self.env['screenData']['newNegativeDelta'] = ''
self.env['screenData']['newDelta'] = '' self.env['screenData']['newDelta'] = ''
# changes on the screen # changes on the screen
oldScreenText = self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['oldContentText'])
newScreenText = self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['newContentText'])
print(newScreenText)
if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \ if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \
(self.env['screenData']['newContentText'] != '' ): (self.env['screenData']['newContentText'] != '' ):
if self.env['screenData']['oldContentText'] == '' and\ if self.env['screenData']['oldContentText'] == '' and\