diff --git a/TODO b/TODO index 6d3ea8f5..1198776d 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,8 @@ ToDos in Priority order: possiblity to forewart shortcut (or use them as shortcut) [pressing twice while timeout] cleanup inputManager 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 - punctuation @@ -27,8 +28,6 @@ ToDos in Priority order: per application onInput - per application shortcuts - implement commands - define_window - remove_window attributes_curr_char toggle_highlighted_mode 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 curr_clipboard paste_clipboard + define_window + remove_window reset_review_on_screen_change remove_clipboard_marks copy_marked diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index a3f4bbd1..bfa1a6a7 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -24,6 +24,8 @@ KEY_FENRIR,KEY_KP2=curr_screen_after_cursor #=clear_bookmark_1 #=set_bookmark_1 #=bookmark_1 +#=set_window_application +#=clear_window_application KEY_KPPLUS=last_incomming KEY_FENRIR,KEY_F2=toggle_braille KEY_FENRIR,KEY_F3=toggle_sound diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 4ab6d61a..bde22725 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -23,6 +23,8 @@ KEY_FENRIR,KEY_SHIFT,KEY_COMMA=curr_screen_after_cursor #=clear_bookmark_1 #=set_bookmark_1 #=bookmark_1 +#=set_window_application +#=clear_window_application 2,KEY_FENRIR,KEY_I=indent_curr_line KEY_FENRIR,KEY_SEMICOLON=last_incomming KEY_FENRIR,KEY_F2=toggle_braille diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index b66929ea..c961fe3f 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -21,7 +21,8 @@ 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_1=set_window_application +KEY_FENRIR,KEY_3=clear_window_application KEY_FENRIR,KEY_3=clear_bookmark_1 #KEY_FENRIR,KEY_1=set_bookmark_1 KEY_FENRIR,KEY_2=bookmark_1 diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 9c2a8a2d..89803b74 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -79,7 +79,7 @@ device=all grabDevices=True ignoreShortcuts=False # the current shortcut layout located in /etc/fenrir/keyboard -keyboardLayout=desktop +keyboardLayout=test # echo chars while typing. charEcho=False # echo deleted chars diff --git a/src/fenrir-package/commands/commands/clear_window_application.py b/src/fenrir-package/commands/commands/clear_window_application.py new file mode 100644 index 00000000..5d6b6c18 --- /dev/null +++ b/src/fenrir-package/commands/commands/clear_window_application.py @@ -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 diff --git a/src/fenrir-package/commands/commands/set_window.py b/src/fenrir-package/commands/commands/set_window.py deleted file mode 100644 index d1521296..00000000 --- a/src/fenrir-package/commands/commands/set_window.py +++ /dev/null @@ -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 diff --git a/src/fenrir-package/commands/commands/set_window_application.py b/src/fenrir-package/commands/commands/set_window_application.py new file mode 100644 index 00000000..aead0c7f --- /dev/null +++ b/src/fenrir-package/commands/commands/set_window_application.py @@ -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 diff --git a/src/fenrir-package/core/cursorManager.py b/src/fenrir-package/core/cursorManager.py index afe8c8d5..2115232d 100644 --- a/src/fenrir-package/core/cursorManager.py +++ b/src/fenrir-package/core/cursorManager.py @@ -42,4 +42,33 @@ class cursorManager(): def enterReviewModeCurrTextCursor(self): self.env['screenData']['oldCursorReview'] = 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 diff --git a/src/fenrir-package/core/screenManager.py b/src/fenrir-package/core/screenManager.py index be344d72..b75f10ed 100644 --- a/src/fenrir-package/core/screenManager.py +++ b/src/fenrir-package/core/screenManager.py @@ -33,3 +33,14 @@ class screenManager(): (currScreen in self.autoIgnoreScreens)) def isScreenChange(self): 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 + diff --git a/src/fenrir-package/screenDriver/linux.py b/src/fenrir-package/screenDriver/linux.py index 2d7514cf..4cd8ee7e 100644 --- a/src/fenrir-package/screenDriver/linux.py +++ b/src/fenrir-package/screenDriver/linux.py @@ -122,6 +122,9 @@ class driver(): self.env['screenData']['newNegativeDelta'] = '' self.env['screenData']['newDelta'] = '' # 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 \ (self.env['screenData']['newContentText'] != '' ): if self.env['screenData']['oldContentText'] == '' and\