From db7bc95d1a69b517c655ca285c665690942ca03c Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 23 Oct 2016 09:30:47 +0200 Subject: [PATCH 01/36] try to improve the differ --- src/fenrir/screenDriver/linux.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index a471fc96..442e7635 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -118,19 +118,19 @@ class driver(): typing = False if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \ (self.env['screenData']['newContentText'] != '' ): - if oldScreenText == '' and\ + if self.env['screenData']['oldContentText'] == '' and\ newScreenText != '': self.env['screenData']['newDelta'] = newScreenText else: - cursorLineStart = self.env['screenData']['newCursor']['y'] * self.env['screenData']['columns'] + self.env['screenData']['newCursor']['y'] + cursorLineStart = self.env['screenData']['lines'] * self.env['screenData']['columns'] + self.env['screenData']['lines'] cursorLineEnd = cursorLineStart + self.env['screenData']['columns'] if self.env['screenData']['oldCursor']['x'] != self.env['screenData']['newCursor']['x'] and \ self.env['screenData']['oldCursor']['y'] == self.env['screenData']['newCursor']['y'] and \ - self.env['screenData']['newContentText'][:cursorLineStart] == self.env['screenData']['oldContentText'][:cursorLineStart]: - - oldScreenText = self.env['screenData']['oldContentText'][cursorLineStart:cursorLineEnd] + self.env['screenData']['newContentText'][:cursorLineStart] == self.env['screenData']['oldContentText'][:cursorLineStart] and \ + self.env['screenData']['newContentText'][cursorLineEnd:] == self.env['screenData']['oldContentText'][cursorLineEnd:]: + oldScreenText = self.env['screenData']['oldContentText'][cursorLineStart:cursorLineEnd + 1] oldScreenText = re.sub(' +',' ',oldScreenText) - newScreenText = self.env['screenData']['newContentText'][cursorLineStart:cursorLineEnd] + newScreenText = self.env['screenData']['newContentText'][cursorLineStart:cursorLineEnd + 1] newScreenText = re.sub(' +',' ',newScreenText) diff = difflib.ndiff(oldScreenText, newScreenText) typing = True From 05f44f9fb98e38cb82484ba9a59a6efde27ae23a Mon Sep 17 00:00:00 2001 From: chrys87 Date: Sun, 23 Oct 2016 18:44:09 +0200 Subject: [PATCH 02/36] optimize input --- src/fenrir/inputDriver/evdev.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index bfe193f7..2815a818 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -35,16 +35,16 @@ class driver(): for fd in r: event = self.iDevices[fd].read_one() while(event): - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.code != 0: currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) if not currMapEvent: return currMapEvent if currMapEvent['EventState'] in [0,1,2]: return currMapEvent - - + else: + self.writeUInput(self.uDevices[fd], event) event = self.iDevices[fd].read_one() return None @@ -102,10 +102,10 @@ class driver(): # 0 = Numlock # 1 = Capslock # 2 = Rollen - if self.ledDevices == {}: - return False if self.ledDevices == None: - return False + return False + if self.ledDevices == {}: + return False for fd, dev in self.ledDevices.items(): return led in dev.leds() return False From 1fa9259bd73d1f7936f29c83d83244ef1ec2f84f Mon Sep 17 00:00:00 2001 From: chrys87 Date: Sun, 23 Oct 2016 23:43:39 +0200 Subject: [PATCH 03/36] change the sorting of events may not be a good idea --- src/fenrir/inputDriver/evdev.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index 2815a818..e3320997 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -35,16 +35,14 @@ class driver(): for fd in r: event = self.iDevices[fd].read_one() while(event): + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.code != 0: currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) if not currMapEvent: return currMapEvent if currMapEvent['EventState'] in [0,1,2]: - return currMapEvent - else: - self.writeUInput(self.uDevices[fd], event) + return currMapEvent event = self.iDevices[fd].read_one() return None From 5a46b3320e09ce4573dcdb4003b0181d70e56f91 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 23 Oct 2016 19:58:04 -0400 Subject: [PATCH 04/36] Revert "change the sorting of events may not be a good idea" This reverts commit 1fa9259bd73d1f7936f29c83d83244ef1ec2f84f. --- src/fenrir/inputDriver/evdev.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index e3320997..2815a818 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -35,14 +35,16 @@ class driver(): for fd in r: event = self.iDevices[fd].read_one() while(event): - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.code != 0: currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) if not currMapEvent: return currMapEvent if currMapEvent['EventState'] in [0,1,2]: - return currMapEvent + return currMapEvent + else: + self.writeUInput(self.uDevices[fd], event) event = self.iDevices[fd].read_one() return None From 4ed32299f9e1c317d2e32c6e39a1cf76894e0ae9 Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Sun, 23 Oct 2016 20:01:18 -0400 Subject: [PATCH 05/36] Revert "try to improve the differ" This reverts commit db7bc95d1a69b517c655ca285c665690942ca03c. Reverted changes. --- src/fenrir/screenDriver/linux.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 442e7635..a471fc96 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -118,19 +118,19 @@ class driver(): typing = False if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \ (self.env['screenData']['newContentText'] != '' ): - if self.env['screenData']['oldContentText'] == '' and\ + if oldScreenText == '' and\ newScreenText != '': self.env['screenData']['newDelta'] = newScreenText else: - cursorLineStart = self.env['screenData']['lines'] * self.env['screenData']['columns'] + self.env['screenData']['lines'] + cursorLineStart = self.env['screenData']['newCursor']['y'] * self.env['screenData']['columns'] + self.env['screenData']['newCursor']['y'] cursorLineEnd = cursorLineStart + self.env['screenData']['columns'] if self.env['screenData']['oldCursor']['x'] != self.env['screenData']['newCursor']['x'] and \ self.env['screenData']['oldCursor']['y'] == self.env['screenData']['newCursor']['y'] and \ - self.env['screenData']['newContentText'][:cursorLineStart] == self.env['screenData']['oldContentText'][:cursorLineStart] and \ - self.env['screenData']['newContentText'][cursorLineEnd:] == self.env['screenData']['oldContentText'][cursorLineEnd:]: - oldScreenText = self.env['screenData']['oldContentText'][cursorLineStart:cursorLineEnd + 1] + self.env['screenData']['newContentText'][:cursorLineStart] == self.env['screenData']['oldContentText'][:cursorLineStart]: + + oldScreenText = self.env['screenData']['oldContentText'][cursorLineStart:cursorLineEnd] oldScreenText = re.sub(' +',' ',oldScreenText) - newScreenText = self.env['screenData']['newContentText'][cursorLineStart:cursorLineEnd + 1] + newScreenText = self.env['screenData']['newContentText'][cursorLineStart:cursorLineEnd] newScreenText = re.sub(' +',' ',newScreenText) diff = difflib.ndiff(oldScreenText, newScreenText) typing = True From f6eb8a7b6730098629803e9b2a2c72afabf89531 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 24 Oct 2016 10:21:10 +0200 Subject: [PATCH 06/36] Update evdev.py --- src/fenrir/inputDriver/evdev.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index 2815a818..ac80db0c 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -35,16 +35,14 @@ class driver(): for fd in r: event = self.iDevices[fd].read_one() while(event): + self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.type == evdev.events.EV_KEY: - self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) if event.code != 0: currMapEvent = self.env['runtime']['inputDriver'].mapEvent(event) if not currMapEvent: return currMapEvent if currMapEvent['EventState'] in [0,1,2]: return currMapEvent - else: - self.writeUInput(self.uDevices[fd], event) event = self.iDevices[fd].read_one() return None From 251e4eda3e5152316c5bafe14fe9e4897487f7c7 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 24 Oct 2016 17:46:18 +0200 Subject: [PATCH 07/36] Fix Typo, add optional parameters --- src/fenrir/soundDriver/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fenrir/soundDriver/generic.py b/src/fenrir/soundDriver/generic.py index ebbe1dc7..fa39a6fc 100644 --- a/src/fenrir/soundDriver/generic.py +++ b/src/fenrir/soundDriver/generic.py @@ -21,12 +21,12 @@ class driver(): if self.soundFileCommand == '': self.soundFileCommand = 'play -q -v fenrirVolume fenrirSoundFile' if self.frequenceCommand == '': - self.frequenceCommand = '=play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence' + self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence' return def shutdown(self): self.cancel() return - def playFrequence(self, frequence, duration, adjustVolume): + def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0): if interrupt: self.cancel() popenFrequenceCommand = self.frequenceCommand.replace('fenrirVolume', str(self.volume + adjustVolume )) From c0adc2c30976d9116f6fc90c0f2ae0f966f44587 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 24 Oct 2016 17:47:45 +0200 Subject: [PATCH 08/36] remove unneeded returns --- src/fenrir/soundDriver/generic.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/fenrir/soundDriver/generic.py b/src/fenrir/soundDriver/generic.py index fa39a6fc..e0155531 100644 --- a/src/fenrir/soundDriver/generic.py +++ b/src/fenrir/soundDriver/generic.py @@ -22,10 +22,8 @@ class driver(): self.soundFileCommand = 'play -q -v fenrirVolume fenrirSoundFile' if self.frequenceCommand == '': self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence' - return def shutdown(self): self.cancel() - return def playFrequence(self, frequence = 1000, duration = 0.3, adjustVolume = 0): if interrupt: self.cancel() From c610c121d80a93fe5539f2adb93287da68b8d1b7 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 25 Oct 2016 17:57:33 +0200 Subject: [PATCH 09/36] Try to fix fenrir key going crazy --- src/fenrir/core/inputManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fenrir/core/inputManager.py b/src/fenrir/core/inputManager.py index a8464fda..e99e9419 100644 --- a/src/fenrir/core/inputManager.py +++ b/src/fenrir/core/inputManager.py @@ -168,10 +168,10 @@ class inputManager(): self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) def isFenrirKeyPressed(self): - return 'KEY_FENRIR' in self.env['input']['currInput'] + return 'KEY_FENRIR' in self.env['input']['prevDeepestInput'] def isScriptKeyPressed(self): - return 'KEY_SCRIPT' in self.env['input']['currInput'] + return 'KEY_SCRIPT' in self.env['input']['prevDeepestInput'] def noKeyPressed(self): return self.env['input']['currInput'] == [] From b7fcec0fbe801ebcdfcd217a5e224d2250fae25e Mon Sep 17 00:00:00 2001 From: chrys87 Date: Tue, 25 Oct 2016 18:05:13 +0200 Subject: [PATCH 10/36] reduce code --- src/fenrir/core/inputManager.py | 35 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/fenrir/core/inputManager.py b/src/fenrir/core/inputManager.py index e99e9419..fbd300db 100644 --- a/src/fenrir/core/inputManager.py +++ b/src/fenrir/core/inputManager.py @@ -43,7 +43,7 @@ class inputManager(): if len(self.env['input']['currInput']) == 0: self.env['input']['prevDeepestInput'] = [] self.env['input']['shortcutRepeat'] = 1 - self.handleLedStates(mEvent) + self.setLedState = self.handleLedStates(mEvent) self.env['input']['lastInputTime'] = time.time() elif mEvent['EventState'] == 1: if not mEvent['EventName'] in self.env['input']['currInput']: @@ -57,7 +57,7 @@ class inputManager(): self.env['input']['shortcutRepeat'] += 1 else: self.env['input']['shortcutRepeat'] = 1 - self.handleLedStates(mEvent) + self.setLedState = self.handleLedStates(mEvent) self.env['input']['lastInputTime'] = time.time() elif mEvent['EventState'] == 2: self.env['input']['lastInputTime'] = time.time() @@ -77,34 +77,29 @@ class inputManager(): def handleLedStates(self, mEvent): if not self.setLedState: - return + return self.setLedState if mEvent['EventName'] == 'KEY_NUMLOCK': if mEvent['EventState'] == 1 and not self.env['input']['newNumLock'] == 1: self.env['runtime']['inputDriver'].toggleLedState() - self.setLedState = False - return + return False if mEvent['EventState'] == 0 and not self.env['input']['newNumLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState() - self.setLedState = False - return + self.env['runtime']['inputDriver'].toggleLedState() + return False if mEvent['EventName'] == 'KEY_CAPSLOCK': if mEvent['EventState'] == 1 and not self.env['input']['newCapsLock'] == 1: - self.env['runtime']['inputDriver'].toggleLedState(1) - self.setLedState = False - return + self.env['runtime']['inputDriver'].toggleLedState(1) + return False if mEvent['EventState'] == 0 and not self.env['input']['newCapsLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState(1) - self.setLedState = False - return + self.env['runtime']['inputDriver'].toggleLedState(1) + return False if mEvent['EventName'] == 'KEY_SCROLLLOCK': if mEvent['EventState'] == 1 and not self.env['input']['newScrollLock'] == 1: - self.env['runtime']['inputDriver'].toggleLedState(2) - self.setLedState = False - return + self.env['runtime']['inputDriver'].toggleLedState(2) + return False if mEvent['EventState'] == 0 and not self.env['input']['newScrollLock'] == 0: - self.env['runtime']['inputDriver'].toggleLedState(2) - self.setLedState = False - return + self.env['runtime']['inputDriver'].toggleLedState(2) + return False + return self.setLedState def grabDevices(self): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): From c395e72d50036ff2e39f08875cd0ca39d5e39db1 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Oct 2016 14:12:55 +0200 Subject: [PATCH 11/36] Update TODO --- TODO | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/TODO b/TODO index 1cfb1673..a0b85969 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,25 @@ ToDos in Priority order: For example, in screen, it just tells me bell in window, but doesn't tell me which one. (southernprince) in special cases next word skipps a word, "word<12 spaces>word2<12 spaces>word3 (storm_dragon) spellcheck triggers twice if there are two spaces after an word and you arrow over them + fenrir is not able to detect the current application inside of screen. + +- implement onScreenUpdate commands + read highlighted text mode +- implement onInput commands + read highlighted vertiacl + read highlighted horizontal + +- implement commands + attributes_curr_char + toggle_highlighted_mode + generic list command (convert clipboard management) + next item + pref item + curr item + first item + last item + - implement braille output to braille device virtual buffer area for scroll left/right if the line is to long for device @@ -22,37 +40,16 @@ ToDos in Priority order: tweak current commands and output http://mielke.cc/brltty/doc/Manual-BrlAPI/English/BrlAPI.html https://git.gnome.org/browse/orca/tree/src/orca/braille.py -https://wiki.gnome.org/Attic/LSR/ScratchPad/Braille/BrlAPI +https://wiki.gnome.org/Attic/LSR/ScratchPad/Braille/BrlAPI + +- implement autodetection of plugged and removed input devices (python-pyudev) +http://askubuntu.com/questions/508236/how-can-i-run-code-whenever-a-usb-device-is-unplugged-without-requiring-root - add perApplicationTrigger trigger per application commands per application onScreenChange per application onInput - per application shortcuts -- implement commands - next_char_phonetic - prev_char_phonetic - next_word_phonetic - prev_word_phonetic - attributes_curr_char - - toggle_highlighted_mode - generic list command (convert clipboard management) - next item - pref item - curr item - first item - last item - -- implement onScreenUpdate commands - read highlighted text mode -- add the debugging to core -- autostart systemd -https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html - -- implement autodetection of plugged and removed input devices (python-pyudev) -http://askubuntu.com/questions/508236/how-can-i-run-code-whenever-a-usb-device-is-unplugged-without-requiring-root - - configuration should be overwriteable with parameter and alternative paths - write settings - menue for settings configuration #storm @@ -199,7 +196,11 @@ ps a -o tty,comm | grep -e Xorg | grep -v "grep -e Xorg" "papa", "quebec", "romeo", "sierra", "tango", "uniform", "victor", "whisky", "x ray", "yankee", "zulu" - + next_char_phonetic + prev_char_phonetic + next_word_phonetic + prev_word_phonetic + - implement onInput commands read_line_if_cursor_change_vertical (needed if you arrow up and down, we want to announce the line) read_char_if_cursur_change_horizontal (needed if you arrow left and right, we want to announce the char under the cursor) @@ -254,3 +255,7 @@ https://web.archive.org/web/20131017130434/http://www.jejik.com/articles/2007/02 - announce capslock - anounce numlock - anounce scroll +- add the debugging to core + +- autostart systemd +https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/sect-Managing_Services_with_systemd-Unit_Files.html From 4ebd476c63b5f72c3ec3e8d1e501fd54ad847ad1 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Oct 2016 14:27:23 +0200 Subject: [PATCH 12/36] Update line_utils.py --- src/fenrir/utils/line_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index 2de24fad..88c99298 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -39,3 +39,9 @@ def getNextLine(currX,currY, currText): x = 0 currLine = wrappedLines[y] return x, y, currLine + +def insertNewlines(string, every=64): + return b'\n'.join(string[i:i+every] for i in range(0, len(string), every)) + +def splitAtrrLines(string, every=64): + return list(string[i:i+every] for i in range(0, len(string), every)) From 3ec6697b58e222b55f08f56ded6c7e35d5e313e8 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Fri, 28 Oct 2016 14:52:51 +0200 Subject: [PATCH 13/36] Update line_utils.py --- src/fenrir/utils/line_utils.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index 88c99298..21088b56 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -40,8 +40,35 @@ def getNextLine(currX,currY, currText): currLine = wrappedLines[y] return x, y, currLine +#!/bin/python + def insertNewlines(string, every=64): - return b'\n'.join(string[i:i+every] for i in range(0, len(string), every)) + return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) def splitAtrrLines(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) + +old = b'das ist ein test' +new = b'das axd ein test' +text = 'das iet ein test' + +text = insertNewlines(text,4) +alts = splitAtrrLines(old,4) +neus = splitAtrrLines(new,4) + +def trackHighlights(old, new, text): + result = '' + text = text.split('\n') + if len(old) != len(new): + return result + if len(text) != len(new): + return result + for line in range(len(new)): + if old[line] != new[line]: + for column in range(len(new)): + if old[line][column] != new[line][column]: + result += text[line][column] + result += ' ' + return result + +print(trackHighlights(alts,neus,text)) From 5839a8fbcbdf68bf203a3b82f7aed97f0875a13d Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 29 Oct 2016 16:40:34 +0200 Subject: [PATCH 14/36] create screen_utils --- src/fenrir/utils/line_utils.py | 34 +-------------------- src/fenrir/utils/screen_utils.py | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 33 deletions(-) create mode 100644 src/fenrir/utils/screen_utils.py diff --git a/src/fenrir/utils/line_utils.py b/src/fenrir/utils/line_utils.py index 21088b56..7b16717e 100644 --- a/src/fenrir/utils/line_utils.py +++ b/src/fenrir/utils/line_utils.py @@ -5,6 +5,7 @@ # By Chrys, Storm Dragon, and contributers. from core import debug +from collections import Counter def getPrevLine(currX,currY, currText): if currText == '': @@ -39,36 +40,3 @@ def getNextLine(currX,currY, currText): x = 0 currLine = wrappedLines[y] return x, y, currLine - -#!/bin/python - -def insertNewlines(string, every=64): - return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) - -def splitAtrrLines(string, every=64): - return list(string[i:i+every] for i in range(0, len(string), every)) - -old = b'das ist ein test' -new = b'das axd ein test' -text = 'das iet ein test' - -text = insertNewlines(text,4) -alts = splitAtrrLines(old,4) -neus = splitAtrrLines(new,4) - -def trackHighlights(old, new, text): - result = '' - text = text.split('\n') - if len(old) != len(new): - return result - if len(text) != len(new): - return result - for line in range(len(new)): - if old[line] != new[line]: - for column in range(len(new)): - if old[line][column] != new[line][column]: - result += text[line][column] - result += ' ' - return result - -print(trackHighlights(alts,neus,text)) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py new file mode 100644 index 00000000..bb9504c7 --- /dev/null +++ b/src/fenrir/utils/screen_utils.py @@ -0,0 +1,52 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from core import debug +from collections import Counter + +def insertNewlines(string, every=64): + return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) + +def splitAtrrLines(string, every=64): + return list(string[i:i+every] for i in range(0, len(string), every)) + +old = b'eeeemmmeeeeeeeee' +new = b'eeeeeueeeeeeeeee' +text = 'das ist ein test' + +def trackHighlights(oldAttr, newAttr, text): + result = '' + currCursor = None + if oldAttr == newAttr: + return result, currCursor + if len(newAttr) == 0: + return result, currCursor + textLines = insertNewlines(text,4) + textLines = textLines.split('\n') + old = splitAtrrLines(oldAttr,4) + new = splitAtrrLines(newAttr,4) + if len(old) != len(new): + return result, currCursor + if len(text) != len(new): + return result, currCursor + try: + background = Counter(newAttr).most_common(1) + background = background[0][0] + except Exception as e: + background = chr(7) + for line in range(len(new)): + if old[line] != new[line]: + for column in range(len(new)): + if old[line][column] != new[line][column]: + if new[line][column] != background: + if not currCursor: + currCursor['x'] = column + currCursor['y'] = line + result += textLines[line][column] + result += ' ' + return result, currCursor + +print(trackHighlights(alts,neus,text)) From 227e136bddbb489ea097dcf845a76b1ee00f60e6 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 29 Oct 2016 16:44:26 +0200 Subject: [PATCH 15/36] add highlight tracking to screenData --- src/fenrir/core/screenData.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fenrir/core/screenData.py b/src/fenrir/core/screenData.py index da6e771d..d3521508 100644 --- a/src/fenrir/core/screenData.py +++ b/src/fenrir/core/screenData.py @@ -11,8 +11,10 @@ screenData = { 'columns': 0, 'lines': 0, 'oldDelta': '', +'oldAttribDelta': '', 'oldNegativeDelta': '', 'oldCursorReview':None, +'oldCursorAttrib':None, 'oldCursor':{'x':0,'y':0}, 'oldContentBytes': b'', 'oldContentText': '', @@ -21,7 +23,9 @@ screenData = { 'oldTTY':None, 'newDelta': '', 'newNegativeDelta': '', +'newAttribDelta': '', 'newCursorReview':None, +'newCursorAttrib':None, 'newCursor':{'x':0,'y':0}, 'newContentBytes': b'', 'newContentText': '', From ad036e6c626ed1c51f38c69541c473eff550feb6 Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 29 Oct 2016 16:50:51 +0200 Subject: [PATCH 16/36] add higlight tracking data to screen driver --- src/fenrir/screenDriver/linux.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index a471fc96..165d0d2d 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -8,6 +8,7 @@ import difflib import re import subprocess from core import debug +from utils import screen_utils class driver(): def __init__(self): @@ -86,9 +87,9 @@ class driver(): self.env['screenData']['oldContentBytes'] = self.env['screenData']['newContentBytes'] self.env['screenData']['oldContentText'] = self.env['screenData']['newContentText'] self.env['screenData']['oldContentTextAttrib'] = self.env['screenData']['newContentAttrib'] - self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x'] - self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y'] + self.env['screenData']['oldCursor'] = self.env['screenData']['newCursor'].copy() self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] + self.env['screenData']['oldAttribDelta'] = self.env['screenData']['newAttribDelta'] self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta'] self.env['screenData']['newContentBytes'] = newContentBytes # get metadata like cursor or screensize @@ -108,10 +109,13 @@ class driver(): self.env['screenData']['oldCursor']['x'] = 0 self.env['screenData']['oldCursor']['y'] = 0 self.env['screenData']['oldDelta'] = '' + self.env['screenData']['oldAttribDelta'] = '' + self.env['screenData']['oldCursorAttrib'] = None self.env['screenData']['oldNegativeDelta'] = '' - # always clear current deltas + # initialize current deltas self.env['screenData']['newNegativeDelta'] = '' - self.env['screenData']['newDelta'] = '' + self.env['screenData']['newDelta'] = '' + self.env['screenData']['newAttribDelta'] = '' # changes on the screen oldScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['oldContentText'])) newScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['newContentText'])) From 2ec4102f8b336f0425b20f752ed4eebc4a995b23 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 30 Oct 2016 00:27:07 +0200 Subject: [PATCH 17/36] make install executeable --- install.sh | 0 src/fenrir/screenDriver/linux.py | 5 +++++ src/fenrir/utils/screen_utils.py | 10 +++++----- 3 files changed, 10 insertions(+), 5 deletions(-) mode change 100644 => 100755 install.sh diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 165d0d2d..bd4a8e28 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -116,6 +116,7 @@ class driver(): self.env['screenData']['newNegativeDelta'] = '' self.env['screenData']['newDelta'] = '' self.env['screenData']['newAttribDelta'] = '' + # changes on the screen oldScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['oldContentText'])) newScreenText = re.sub(' +',' ',self.env['runtime']['screenManager'].getWindowAreaInText(self.env['screenData']['newContentText'])) @@ -149,4 +150,8 @@ class driver(): else: self.env['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x[0] == '+') self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') + + # track highlighted + if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: + pass diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index bb9504c7..554f7720 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -10,24 +10,24 @@ from collections import Counter def insertNewlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) -def splitAtrrLines(string, every=64): +def splitOnPos(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) old = b'eeeemmmeeeeeeeee' new = b'eeeeeueeeeeeeeee' text = 'das ist ein test' -def trackHighlights(oldAttr, newAttr, text): +def trackHighlights(oldAttr, newAttr, text, lenght): result = '' currCursor = None if oldAttr == newAttr: return result, currCursor if len(newAttr) == 0: return result, currCursor - textLines = insertNewlines(text,4) + textLines = insertNewlines(text,lenght) textLines = textLines.split('\n') - old = splitAtrrLines(oldAttr,4) - new = splitAtrrLines(newAttr,4) + old = splitOnPos(oldAttr,lenght) + new = splitOnPos(newAttr,lenght) if len(old) != len(new): return result, currCursor if len(text) != len(new): From f91a493c4b18187f896fe3ed58e7e9c7b27e8dc2 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 30 Oct 2016 00:31:40 +0200 Subject: [PATCH 18/36] fix oops --- src/fenrir/utils/screen_utils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 554f7720..d9e22570 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -47,6 +47,4 @@ def trackHighlights(oldAttr, newAttr, text, lenght): currCursor['y'] = line result += textLines[line][column] result += ' ' - return result, currCursor - -print(trackHighlights(alts,neus,text)) + return result, currCursor From 965c850ca2954f14ac921983fc7cd322386fe0b2 Mon Sep 17 00:00:00 2001 From: chrys Date: Sun, 30 Oct 2016 01:16:07 +0200 Subject: [PATCH 19/36] sync --- src/fenrir/screenDriver/linux.py | 11 +++++------ src/fenrir/utils/screen_utils.py | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index bd4a8e28..88bafca0 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -17,9 +17,6 @@ class driver(): self.env = environment def shutdown(self): pass - def insert_newlines(self, string, every=64): - return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) - def getCurrScreen(self): self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] try: @@ -86,7 +83,7 @@ class driver(): # set new "old" values self.env['screenData']['oldContentBytes'] = self.env['screenData']['newContentBytes'] self.env['screenData']['oldContentText'] = self.env['screenData']['newContentText'] - self.env['screenData']['oldContentTextAttrib'] = self.env['screenData']['newContentAttrib'] + self.env['screenData']['oldContentAttrib'] = self.env['screenData']['newContentAttrib'] self.env['screenData']['oldCursor'] = self.env['screenData']['newCursor'].copy() self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldAttribDelta'] = self.env['screenData']['newAttribDelta'] @@ -100,7 +97,7 @@ class driver(): # analyze content self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2] - self.env['screenData']['newContentText'] = self.insert_newlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) + self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: self.env['screenData']['oldContentBytes'] = b'' @@ -152,6 +149,8 @@ class driver(): self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') # track highlighted + #print(self.env['screenData']['oldContentAttrib'] , self.env['screenData']['newContentAttrib']) if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: - pass + self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) + #print('drin',self.env['screenData']['newAttribDelta']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index d9e22570..979fe657 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -10,7 +10,7 @@ from collections import Counter def insertNewlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) -def splitOnPos(string, every=64): +def splitEvery(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) old = b'eeeemmmeeeeeeeee' @@ -26,8 +26,8 @@ def trackHighlights(oldAttr, newAttr, text, lenght): return result, currCursor textLines = insertNewlines(text,lenght) textLines = textLines.split('\n') - old = splitOnPos(oldAttr,lenght) - new = splitOnPos(newAttr,lenght) + old = splitEvery(oldAttr,lenght) + new = splitEvery(newAttr,lenght) if len(old) != len(new): return result, currCursor if len(text) != len(new): From 0221ba358f1d968c5893b5f31791f2f706b45f77 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 1 Nov 2016 21:55:08 +0100 Subject: [PATCH 20/36] make highlighted mode work in driver --- README.md | 1 + config/settings/settings.conf | 4 ++-- config/settings/settings.conf.chrys | 4 ++-- config/settings/settings.conf.storm | 4 ++-- src/fenrir/inputDriver/evdev.py | 2 +- src/fenrir/screenDriver/linux.py | 6 +++--- src/fenrir/utils/screen_utils.py | 17 +++++++++-------- 7 files changed, 20 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index db1af81d..39f10454 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ ReadWrite permission - brltty, python-brlapi [using braille] # (not implemented yet) - gstreamer [soundicons via gstreamer] # not working yet - python-pyenchant [spell check functionality] +- aspell- [your languagedata for spellchecker, english support "aspell-en"] - python-daemonize [use fenrir as background service on Unix like systems] # installation diff --git a/config/settings/settings.conf b/config/settings/settings.conf index e37308f5..0ad96f33 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -77,8 +77,8 @@ autodetectSuspendingScreen=True [keyboard] driver=evdev -# filter input devices AUTO, ALL or a DEVICE NAME -device=AUTO +# filter input devices NOMICE, ALL or a DEVICE NAME +device=ALL # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. grabDevices=True ignoreShortcuts=False diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index d690dffc..10a99707 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -77,8 +77,8 @@ autodetectSuspendingScreen=True [keyboard] driver=evdev -# filter input devices AUTO, ALL or a DEVICE NAME -device=AUTO +# filter input devices NOMICE, ALL or a DEVICE NAME +device=ALL # gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. grabDevices=True ignoreShortcuts=False diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 1fbe784e..e52c4e95 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -34,8 +34,8 @@ autodetectSuspendingScreen=False [keyboard] driver=evdev -# filter input devices AUTO, ALL or a DEVICE NAME -device=AUTO +# filter input devices NOMICE, ALL or a DEVICE NAME +device=ALL grabDevices=True ignoreShortcuts=False keyboardLayout=desktop diff --git a/src/fenrir/inputDriver/evdev.py b/src/fenrir/inputDriver/evdev.py index ac80db0c..5805d346 100644 --- a/src/fenrir/inputDriver/evdev.py +++ b/src/fenrir/inputDriver/evdev.py @@ -75,7 +75,7 @@ class driver(): if self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'ALL': self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities()} self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities()} - elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'AUTO': + elif self.env['runtime']['settingsManager'].getSetting('keyboard', 'device').upper() == 'NOMICE': self.iDevices = {dev.fd: dev for dev in self.iDevices if 1 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()} self.ledDevices = {dev.fd: dev for dev in self.ledDevices if 1 in dev.capabilities() and 17 in dev.capabilities() and not 3 in dev.capabilities() and not 2 in dev.capabilities()} else: diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 88bafca0..6269d4ea 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -5,7 +5,7 @@ # By Chrys, Storm Dragon, and contributers. import difflib -import re +import re, time import subprocess from core import debug from utils import screen_utils @@ -20,6 +20,7 @@ class driver(): def getCurrScreen(self): self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] try: + time.sleep(0.1) currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') self.env['screenData']['newTTY'] = str(currScreenFile.read()[3:-1]) currScreenFile.close() @@ -149,8 +150,7 @@ class driver(): self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x[0] == '-') # track highlighted - #print(self.env['screenData']['oldContentAttrib'] , self.env['screenData']['newContentAttrib']) if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) - #print('drin',self.env['screenData']['newAttribDelta']) + print('drin',self.env['screenData']['newAttribDelta']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 979fe657..8efd4175 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -24,14 +24,14 @@ def trackHighlights(oldAttr, newAttr, text, lenght): return result, currCursor if len(newAttr) == 0: return result, currCursor - textLines = insertNewlines(text,lenght) - textLines = textLines.split('\n') + if len(oldAttr) != len(newAttr): + return result, currCursor old = splitEvery(oldAttr,lenght) - new = splitEvery(newAttr,lenght) - if len(old) != len(new): - return result, currCursor - if len(text) != len(new): - return result, currCursor + new = splitEvery(newAttr,lenght) + textLines = text.split('\n') + if len(textLines) != len(new): + return result, currCursor + try: background = Counter(newAttr).most_common(1) background = background[0][0] @@ -39,10 +39,11 @@ def trackHighlights(oldAttr, newAttr, text, lenght): background = chr(7) for line in range(len(new)): if old[line] != new[line]: - for column in range(len(new)): + for column in range(len(new[line])): if old[line][column] != new[line][column]: if new[line][column] != background: if not currCursor: + currCursor = {} currCursor['x'] = column currCursor['y'] = line result += textLines[line][column] From 99534c8c6c4a1a50aa75227986376617105ab82f Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 1 Nov 2016 22:03:38 +0100 Subject: [PATCH 21/36] remove debug sleep --- src/fenrir/screenDriver/linux.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 6269d4ea..954bed56 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -5,7 +5,7 @@ # By Chrys, Storm Dragon, and contributers. import difflib -import re, time +import re import subprocess from core import debug from utils import screen_utils @@ -20,7 +20,6 @@ class driver(): def getCurrScreen(self): self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] try: - time.sleep(0.1) currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') self.env['screenData']['newTTY'] = str(currScreenFile.read()[3:-1]) currScreenFile.close() From d161275465461f6ce01bfde55fccbd507ebb624a Mon Sep 17 00:00:00 2001 From: chrys87 Date: Thu, 3 Nov 2016 15:36:48 +0100 Subject: [PATCH 22/36] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 4bd95d5a..d75cf798 100755 --- a/install.sh +++ b/install.sh @@ -3,7 +3,7 @@ read -p "This will install fenrir. Press ctrl+c to cancil, or enter to continue." continue install -m755 -d /opt/fenrir install -m755 -d /usr/share/fenrir/scripts - install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf" + install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf install -m644 -D "config/punctuation/default.conf" /etc/fenrir/punctuation/default.conf install -m644 -D "config/settings/settings.conf" /etc/fenrir/settings/settings.conf From f540b9658d0b53aedae77ea117dfe24ce80ad15c Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 21:25:54 +0100 Subject: [PATCH 23/36] remove nonprintable chars --- src/fenrir/screenDriver/linux.py | 1 + src/fenrir/utils/screen_utils.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 954bed56..4c480412 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -96,6 +96,7 @@ class driver(): self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3]) # analyze content self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') + self.env['screenData']['newContentText'] = screen_utils.removeNonprintable(self.env['screenData']['newContentText']) self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2] self.env['screenData']['newContentText'] = screen_utils.insertNewlines(self.env['screenData']['newContentText'], self.env['screenData']['columns']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 8efd4175..5de55a9d 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -6,6 +6,13 @@ from core import debug from collections import Counter +import string + +def removeNonprintable(text): + # Get the difference of all ASCII characters from the set of printable characters + nonprintable = set([chr(i) for i in range(128)]).difference(string.printable) + # Use translate to remove all non-printable characters + return text.translate({ord(character):None for character in nonprintable}) def insertNewlines(string, every=64): return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) From ab56b61a28c086d473399f0a6a8e82b97a135bf2 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 21:31:42 +0100 Subject: [PATCH 24/36] correct script path --- config/settings/settings.conf | 4 ++-- config/settings/settings.conf.chrys | 2 +- config/settings/settings.conf.storm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 0ad96f33..8e9aa889 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -79,7 +79,7 @@ autodetectSuspendingScreen=True driver=evdev # filter input devices NOMICE, ALL or a DEVICE NAME device=ALL -# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. +# gives fenrir exclusive access to the keyboard and let consume keystrokes. grabDevices=True ignoreShortcuts=False # the current shortcut layout located in /etc/fenrir/keyboard @@ -110,7 +110,7 @@ timeFormat=%H:%M:%P dateFormat=%A, %B %d, %Y autoSpellCheck=True spellCheckLanguage=en_US -scriptPath=/etc/fenrir/scripts +scriptPath=/usr/share/fenrir/scripts [promote] enabled=True diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index 10a99707..587e34db 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -110,7 +110,7 @@ timeFormat=%H:%M:%P dateFormat=%A, %B %d, %Y autoSpellCheck=True spellCheckLanguage=en_US -scriptPath=/etc/fenrir/scripts +scriptPath=/usr/share/fenrir/scripts [promote] enabled=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index e52c4e95..137e29c5 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -60,7 +60,7 @@ timeFormat=%H:%M:%P dateFormat="%A, %B %d, %Y" autoSpellCheck=True spellCheckLanguage=en_US -scriptPath=/etc/fenrir/scripts +scriptPath=/usr/share/fenrir/scripts [promote] enabled=True From 8e26484d3f7ef7f9c65b9cad6ea67893494ab0a9 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 21:32:35 +0100 Subject: [PATCH 25/36] remove wrong intention --- install.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index d75cf798..61795eb7 100755 --- a/install.sh +++ b/install.sh @@ -2,16 +2,16 @@ #Basic install script for fenrir. read -p "This will install fenrir. Press ctrl+c to cancil, or enter to continue." continue install -m755 -d /opt/fenrir - install -m755 -d /usr/share/fenrir/scripts - install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf - install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf - install -m644 -D "config/punctuation/default.conf" /etc/fenrir/punctuation/default.conf - install -m644 -D "config/settings/settings.conf" /etc/fenrir/settings/settings.conf - install -d /usr/share/sounds/fenrir - install -m644 -D "autostart/systemd/fenrir.service" /usr/lib/systemd/system/fenrir.service - cp -a src/fenrir/* /opt/fenrir - cp -a config/scripts/* /usr/share/fenrir/scripts - cp -a config/sound/* /usr/share/sounds/fenrir +install -m755 -d /usr/share/fenrir/scripts +install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf +install -m644 -D "config/keyboard/desktop.conf" /etc/fenrir/keyboard/desktop.conf +install -m644 -D "config/punctuation/default.conf" /etc/fenrir/punctuation/default.conf +install -m644 -D "config/settings/settings.conf" /etc/fenrir/settings/settings.conf +install -d /usr/share/sounds/fenrir +install -m644 -D "autostart/systemd/fenrir.service" /usr/lib/systemd/system/fenrir.service +cp -a src/fenrir/* /opt/fenrir +cp -a config/scripts/* /usr/share/fenrir/scripts +cp -a config/sound/* /usr/share/sounds/fenrir ln -s /opt/fenrir/fenrir-daemon /usr/bin/fenrir cat << EOF To have fenrir start at boot: From 643e755bd2c00f232f3dffa2eec2344eca60d157 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 21:39:02 +0100 Subject: [PATCH 26/36] try to reconnect to speechd --- src/fenrir/speechDriver/speechd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fenrir/speechDriver/speechd.py b/src/fenrir/speechDriver/speechd.py index ca8daa15..49fc7894 100644 --- a/src/fenrir/speechDriver/speechd.py +++ b/src/fenrir/speechDriver/speechd.py @@ -34,13 +34,15 @@ class driver(): def speak(self,text, queueable=True): if not self._isInitialized: - return False + self.initialize(self.env) + if not self._isInitialized: + return False if queueable == False: self.cancel() try: self._sd.set_synthesis_voice(self._language) self._sd.set_punctuation(self._punct.NONE) except Exception as e: - pass + self._isInitialized = False self._sd.speak(text) return True From 6a8b1ba5f6a767afc896dd35bb72620338a237e0 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 21:57:55 +0100 Subject: [PATCH 27/36] add settings for hilight mode --- config/settings/settings.conf | 4 ++++ config/settings/settings.conf.chrys | 4 ++++ config/settings/settings.conf.storm | 4 ++++ src/fenrir/core/settings.py | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 8e9aa889..a6267c21 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -112,6 +112,10 @@ autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts +[focus] +cursor=True +highlight=False + [promote] enabled=True inactiveTimeoutSec=120 diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index 587e34db..e94b588a 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -112,6 +112,10 @@ autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts +[focus] +cursor=True +highlight=False + [promote] enabled=True inactiveTimeoutSec=120 diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 137e29c5..e618edf9 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -62,6 +62,10 @@ autoSpellCheck=True spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts +[focus] +cursor=True +highlight=False + [promote] enabled=True inactiveTimeoutSec=120 diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 0d295577..f4c6780a 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -55,6 +55,10 @@ settings = { 'spellCheckLanguage': 'en_US', 'scriptPath':'/etc/fenrir/scripts', }, +'focus':{ + 'cursor': True, + 'highlight': False, +}, 'promote':{ 'enabled': True, 'inactiveTimeoutSec': 120, From 6f479a756143d4540b622586067cd168c3541482 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 22:03:56 +0100 Subject: [PATCH 28/36] add toggle of hilight mode --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 1 + .../commands/toggle_highlight_tracking.py | 29 +++++++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 src/fenrir/commands/commands/toggle_highlight_tracking.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 99f2e789..7b387db4 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output KEY_FENRIR,KEY_CTRL,KEY_E=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read +#=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 7b19304f..03577c25 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_SHIFT,KEY_ENTER=toggle_output KEY_FENRIR,KEY_SHIFT,KEY_E=toggle_emoticons KEY_FENRIR,KEY_ENTER=toggle_auto_read +#=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index c882114d..2c1e4867 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -75,6 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output #=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read +#=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date diff --git a/src/fenrir/commands/commands/toggle_highlight_tracking.py b/src/fenrir/commands/commands/toggle_highlight_tracking.py new file mode 100644 index 00000000..6a987d9b --- /dev/null +++ b/src/fenrir/commands/commands/toggle_highlight_tracking.py @@ -0,0 +1,29 @@ +#!/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 'enables or disables tracking of highlighted' + + def run(self): + currMode=self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight') + + self.env['runtime']['settingsManager'].setSetting('focus', 'highlight', str(not currMode)) + self.env['runtime']['settingsManager'].setSetting('focus', 'cursor', str(currMode)) + if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): + self.env['runtime']['outputManager'].presentText("highlight tracking", soundIcon='', interrupt=True) + else: + self.env['runtime']['outputManager'].presentText("cursor tracking", soundIcon='', interrupt=True) + + def setCallback(self, callback): + pass From a58fe62f87c05360eaf0dfe19b2af4c46039ade8 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 22:23:54 +0100 Subject: [PATCH 29/36] add initial working highlight focus tracking --- .../onInput/45000-present_char_if_cursor_change_horizontal.py | 2 ++ .../onInput/55000-present_line_if_cursor_change_vertical.py | 2 ++ src/fenrir/commands/onInput/72000-history.py | 4 +--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/fenrir/commands/onInput/45000-present_char_if_cursor_change_horizontal.py b/src/fenrir/commands/onInput/45000-present_char_if_cursor_change_horizontal.py index bb7bc291..0316e2f5 100644 --- a/src/fenrir/commands/onInput/45000-present_char_if_cursor_change_horizontal.py +++ b/src/fenrir/commands/onInput/45000-present_char_if_cursor_change_horizontal.py @@ -17,6 +17,8 @@ class command(): return '' def run(self): + if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): + return if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: return if self.env['runtime']['inputManager'].noKeyPressed(): diff --git a/src/fenrir/commands/onInput/55000-present_line_if_cursor_change_vertical.py b/src/fenrir/commands/onInput/55000-present_line_if_cursor_change_vertical.py index da0800f7..c51dc034 100644 --- a/src/fenrir/commands/onInput/55000-present_line_if_cursor_change_vertical.py +++ b/src/fenrir/commands/onInput/55000-present_line_if_cursor_change_vertical.py @@ -17,6 +17,8 @@ class command(): return '' def run(self): + if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'): + return if self.env['runtime']['inputManager'].noKeyPressed(): return if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: diff --git a/src/fenrir/commands/onInput/72000-history.py b/src/fenrir/commands/onInput/72000-history.py index 782c78ed..417ec489 100644 --- a/src/fenrir/commands/onInput/72000-history.py +++ b/src/fenrir/commands/onInput/72000-history.py @@ -29,9 +29,7 @@ class command(): return prevLine = self.env['screenData']['oldContentText'].split('\n')[self.env['screenData']['newCursor']['y']] currLine = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']] - if currLine.isspace(): - self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True) - else: + if not currLine.isspace(): currPrompt = currLine.find('$') rootPrompt = currLine.find('#') if currPrompt <= 0: From e06bd164237a5cd6ea145c5a3740c025e99e8977 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 22:24:15 +0100 Subject: [PATCH 30/36] add command for toggle highlight tracking --- .../onInput/56000-highlight_tracking.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/fenrir/commands/onInput/56000-highlight_tracking.py diff --git a/src/fenrir/commands/onInput/56000-highlight_tracking.py b/src/fenrir/commands/onInput/56000-highlight_tracking.py new file mode 100644 index 00000000..4f75f498 --- /dev/null +++ b/src/fenrir/commands/onInput/56000-highlight_tracking.py @@ -0,0 +1,24 @@ +#!/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 'enables or disables tracking of highlighted' + + def run(self): + if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): + return + self.env['runtime']['outputManager'].presentText(self.env['screenData']['newAttribDelta'], soundIcon='', interrupt=True) + + def setCallback(self, callback): + pass From 144d5828d25b4e19102c5019b2eded1d61f883ff Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 4 Nov 2016 22:28:18 +0100 Subject: [PATCH 31/36] just calculate if hilight is on --- src/fenrir/screenDriver/linux.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index 4c480412..c25016a7 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -151,6 +151,6 @@ class driver(): # track highlighted if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: - self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) - print('drin',self.env['screenData']['newAttribDelta']) + if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): + self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) From def9341ac1e012ec8402b3c8f794aaf18a7e7a0d Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 4 Nov 2016 17:49:14 -0400 Subject: [PATCH 32/36] Updated PKGBUILD stuff. --- contrib/fenrir-git/PKGBUILD | 32 +++++++++++++++------------ contrib/fenrir-git/fenrir-git.install | 4 ++++ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/contrib/fenrir-git/PKGBUILD b/contrib/fenrir-git/PKGBUILD index 09fbdcf5..73c71042 100644 --- a/contrib/fenrir-git/PKGBUILD +++ b/contrib/fenrir-git/PKGBUILD @@ -3,17 +3,19 @@ _gitname='fenrir' pkgname="${_gitname}-git" -pkgver=v0.1.2.gb72614a -pkgrel=1 +pkgver=v0.2.5.g33af5b6 +pkgrel=3 pkgdesc='A user space console screen reader written in python3' arch=('any') url='https://github.com/chrys87/${_pkgname}' license=('MIT') -depends=('python' 'python-espeak' 'python-evdev') +depends=('python' 'python-daemonize' 'python-evdev') optdepends=('brltty: For Braille support' - 'gstreamer: for soundicons via gstreamer' +'gstreamer: for soundicons via gstreamer' 'sox: The default sound driver' - 'python-enchant: for spell check functionality') + 'python-espeak: TTS support' + 'python-pyenchant: for spell check functionality' + 'speech-dispatcher: TTS support') makedepends=('git') provides=('fenrir') conflicts=('fenrir') @@ -21,7 +23,7 @@ install="$pkgname".install source=("git+https://github.com/chrys87/${_gitname}.git" 'fenrir-git.install') md5sums=('SKIP' - '9d1e82fce2e02ae2a1216a18ca576bfb') + '1387fd3851040d03816e2fb6b8fa631f') pkgver() { @@ -33,17 +35,19 @@ pkgver() package() { cd "$srcdir/$_gitname" - install -d "$pkgdir/usr/bin" - install -d "$pkgdir/etc/fenrir/keyboard" - install -d "$pkgdir/etc/fenrir/settings" - install -d "$pkgdir/etc/fenrir/substitution" + install -m755 -d "$pkgdir/opt/fenrir" + install -m755 -d "$pkgdir/usr/share/fenrir/scripts" + install -m755 -d "$pkgdir/usr/share/fenrir/tools" + install -m644 -D "config/keyboard/desktop.conf" "$pkgdir/etc/fenrir/keyboard/desktop.conf" + install -m644 -D "config/keyboard/laptop.conf" "$pkgdir/etc/fenrir/keyboard/laptop.conf" + install -m644 -D "config/punctuation/default.conf" "$pkgdir/etc/fenrir/punctuation/default.conf" + install -m644 -D "config/settings/settings.conf" "$pkgdir/etc/fenrir/settings/settings.conf" install -d "$pkgdir/usr/share/sounds/fenrir" install -m644 -D "autostart/systemd/fenrir.service" "$pkgdir/usr/lib/systemd/system/fenrir.service" - python setup.py install --root="${pkgdir}/" --optimize=1 - cp -a config/keyboard/* "$pkgdir/etc/fenrir/keyboard" - cp -a config/settings/* "$pkgdir/etc/fenrir/settings" + cp -a src/fenrir/* "$pkgdir/opt/fenrir" + cp -a config/scripts/* "$pkgdir/usr/share/fenrir/scripts" + cp -a tools/* "$pkgdir/usr/share/fenrir/tools" cp -a config/sound/* "$pkgdir/usr/share/sounds/fenrir" - cp -a config/substitution/* "$pkgdir/etc/fenrir/substitution" } # vim: set ts=2 sw=2 et: diff --git a/contrib/fenrir-git/fenrir-git.install b/contrib/fenrir-git/fenrir-git.install index 973d87ac..8d6d9877 100644 --- a/contrib/fenrir-git/fenrir-git.install +++ b/contrib/fenrir-git/fenrir-git.install @@ -1,4 +1,5 @@ post_install() { +ln -s /opt/fenrir/fenrir-daemon /usr/bin/fenrir _alert } @@ -6,6 +7,9 @@ _alert() { cat << EOF To have fenrir start at boot: sudo systemctl enable fenrir +Pulseaudio users may want to run +/usr/share/fenrir/tools/configure-pulseaudio +once as their user account and once as root. EOF } From a998a06af3ca7c0d6126cf432275a2908836ac3d Mon Sep 17 00:00:00 2001 From: Storm Dragon Date: Fri, 4 Nov 2016 19:10:16 -0400 Subject: [PATCH 33/36] bound the toggle highlight key. --- config/keyboard/desktop.conf | 2 +- config/keyboard/laptop.conf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 7b387db4..0eb82837 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -75,7 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_BACKSLASH=toggle_output KEY_FENRIR,KEY_CTRL,KEY_E=toggle_emoticons key_FENRIR,KEY_KPENTER=toggle_auto_read -#=toggle_highlight_tracking +KEY_FENRIR,KEY_KPASTERISK=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 03577c25..be214ad7 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -75,7 +75,7 @@ KEY_FENRIR,KEY_RIGHTBRACE=toggle_auto_spell_check KEY_FENRIR,KEY_SHIFT,KEY_ENTER=toggle_output KEY_FENRIR,KEY_SHIFT,KEY_E=toggle_emoticons KEY_FENRIR,KEY_ENTER=toggle_auto_read -#=toggle_highlight_tracking +KEY_FENRIR,KEY_Y=toggle_highlight_tracking KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_T=time 2,KEY_FENRIR,KEY_T=date From 0407d39a3a1aa1e310f82244e532b8d6805b311f Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 5 Nov 2016 00:11:54 +0100 Subject: [PATCH 34/36] respect hilight mode on enter review --- src/fenrir/commands/onInput/72000-history.py | 4 +++- src/fenrir/core/cursorManager.py | 5 +++++ src/fenrir/screenDriver/linux.py | 7 +++++-- src/fenrir/utils/screen_utils.py | 4 ---- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/fenrir/commands/onInput/72000-history.py b/src/fenrir/commands/onInput/72000-history.py index 417ec489..23a5e737 100644 --- a/src/fenrir/commands/onInput/72000-history.py +++ b/src/fenrir/commands/onInput/72000-history.py @@ -18,7 +18,9 @@ class command(): def run(self): if self.env['runtime']['inputManager'].noKeyPressed(): - return + return + if self.env['screenData']['newAttribDelta'] != '': + return if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: return if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y']: diff --git a/src/fenrir/core/cursorManager.py b/src/fenrir/core/cursorManager.py index 32d4cd2f..13320c04 100644 --- a/src/fenrir/core/cursorManager.py +++ b/src/fenrir/core/cursorManager.py @@ -56,6 +56,11 @@ class cursorManager(): self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview'] if not self.env['screenData']['newCursorReview']: self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy() + if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight') and \ + self.env['screenData']['newCursorAttrib'] != None: + if self.env['screenData']['newCursorAttrib']['x'] != 0 and \ + self.env['screenData']['newCursorAttrib']['y'] != 0: + self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursorAttrib'].copy() def setReviewCursorPosition(self, x, y): if not self.isReviewMode(): self.enterReviewModeCurrTextCursor() diff --git a/src/fenrir/screenDriver/linux.py b/src/fenrir/screenDriver/linux.py index c25016a7..7c5d396f 100644 --- a/src/fenrir/screenDriver/linux.py +++ b/src/fenrir/screenDriver/linux.py @@ -85,6 +85,8 @@ class driver(): self.env['screenData']['oldContentText'] = self.env['screenData']['newContentText'] self.env['screenData']['oldContentAttrib'] = self.env['screenData']['newContentAttrib'] self.env['screenData']['oldCursor'] = self.env['screenData']['newCursor'].copy() + if self.env['screenData']['newCursorAttrib']: + self.env['screenData']['oldCursorAttrib'] = self.env['screenData']['newCursorAttrib'].copy() self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldAttribDelta'] = self.env['screenData']['newAttribDelta'] self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta'] @@ -109,6 +111,7 @@ class driver(): self.env['screenData']['oldDelta'] = '' self.env['screenData']['oldAttribDelta'] = '' self.env['screenData']['oldCursorAttrib'] = None + self.env['screenData']['newCursorAttrib'] = None self.env['screenData']['oldNegativeDelta'] = '' # initialize current deltas self.env['screenData']['newNegativeDelta'] = '' @@ -151,6 +154,6 @@ class driver(): # track highlighted if self.env['screenData']['oldContentAttrib'] != self.env['screenData']['newContentAttrib']: - if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): - self.env['screenData']['newAttribDelta'], currCursor = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) + if self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'highlight'): + self.env['screenData']['newAttribDelta'], self.env['screenData']['newCursorAttrib'] = screen_utils.trackHighlights(self.env['screenData']['oldContentAttrib'], self.env['screenData']['newContentAttrib'], self.env['screenData']['newContentText'], self.env['screenData']['columns']) diff --git a/src/fenrir/utils/screen_utils.py b/src/fenrir/utils/screen_utils.py index 5de55a9d..54190ffe 100644 --- a/src/fenrir/utils/screen_utils.py +++ b/src/fenrir/utils/screen_utils.py @@ -20,10 +20,6 @@ def insertNewlines(string, every=64): def splitEvery(string, every=64): return list(string[i:i+every] for i in range(0, len(string), every)) -old = b'eeeemmmeeeeeeeee' -new = b'eeeeeueeeeeeeeee' -text = 'das ist ein test' - def trackHighlights(oldAttr, newAttr, text, lenght): result = '' currCursor = None From b6e39a45429e428b841c60a484d2eabf7d83130e Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 5 Nov 2016 00:20:27 +0100 Subject: [PATCH 35/36] marks hilighted mode as done --- TODO | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index a0b85969..f5227b30 100644 --- a/TODO +++ b/TODO @@ -11,14 +11,9 @@ ToDos in Priority order: - implement onScreenUpdate commands read highlighted text mode - -- implement onInput commands - read highlighted vertiacl - read highlighted horizontal - + - implement commands attributes_curr_char - toggle_highlighted_mode generic list command (convert clipboard management) next item pref item @@ -200,14 +195,16 @@ ps a -o tty,comm | grep -e Xorg | grep -v "grep -e Xorg" prev_char_phonetic next_word_phonetic prev_word_phonetic - + toggle_highlighted_mode + - implement onInput commands read_line_if_cursor_change_vertical (needed if you arrow up and down, we want to announce the line) read_char_if_cursur_change_horizontal (needed if you arrow left and right, we want to announce the char under the cursor) echo_char (echos the last char on pressing space or return) echo_word (echos the last word) echo_deleted_char (echos deleted char on screen - + read highlighted + - implement onScreenChange commands promoted text clear_marks_on_screen_change From 72a739e0999dc0a6c45f444e9a92c02bd810b21a Mon Sep 17 00:00:00 2001 From: chrys Date: Sat, 5 Nov 2016 01:21:28 +0100 Subject: [PATCH 36/36] add some notes to settings.conf --- config/settings/settings.conf | 2 ++ config/settings/settings.conf.chrys | 2 ++ config/settings/settings.conf.storm | 3 +++ 3 files changed, 7 insertions(+) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index a6267c21..8a9f676b 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -113,7 +113,9 @@ spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts [focus] +#follow the text cursor cursor=True +#follow highlighted text changes highlight=False [promote] diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index e94b588a..ba13d46a 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -113,7 +113,9 @@ spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts [focus] +#follow the text cursor cursor=True +#follow highlighted text changes highlight=False [promote] diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index e618edf9..4d2a2c3a 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -63,9 +63,12 @@ spellCheckLanguage=en_US scriptPath=/usr/share/fenrir/scripts [focus] +#follow the text cursor cursor=True +#follow highlighted text changes highlight=False + [promote] enabled=True inactiveTimeoutSec=120