diff --git a/src/fenrir-package/commands/curr_line.py b/src/fenrir-package/commands/curr_line.py index 49bc8f7c..02b11255 100644 --- a/src/fenrir-package/commands/curr_line.py +++ b/src/fenrir-package/commands/curr_line.py @@ -5,9 +5,14 @@ class command(): pass def run(self, environment): print('fire') - #print(environment['screenData']['newContentText'])i - print(environment['screenData']['newCursor']['x']) - environment['runtime']['speechDriver'].speak(environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['x']-1]) + #print(environment) + environment['runtime']['speechDriver'].cancel() + if environment['screenData']['newContentText'].replace(" ","") == '': + environment['runtime']['speechDriver'].speak("empty screen") + else: + print(environment['screenData']['newCursor']) + print(environment['screenData']['newContentText'].split('\n')) + environment['runtime']['speechDriver'].speak(environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]) def setCallback(self, callback): pass def shutdown(self): diff --git a/src/fenrir-package/fenrir.py b/src/fenrir-package/fenrir.py index 88f3e596..3e1317c8 100755 --- a/src/fenrir-package/fenrir.py +++ b/src/fenrir-package/fenrir.py @@ -1,4 +1,5 @@ #!/bin/python +# -*- coding: utf-8 -*- # Fenrir TTY screen reader # By Chrys, Storm Dragon, and contributers. @@ -58,8 +59,7 @@ class fenrir(): while(self.environment['generalInformation']['running']): self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment) #self.environment['input']['currShortcut'] = {} - #self.environment['input']['currShortcutString'] = '' - if self.environment['input']['currShortcutString'] != '': + if self.environment['commandInfo']['currCommand'] != '': self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment) time.sleep(0.5) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 346a206b..a9de63c9 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -1,8 +1,10 @@ #!/bin/python +# -*- coding: utf-8 -*- import difflib import textwrap import time +import re #import fenrir.utils.debug class screenManager(): @@ -29,10 +31,12 @@ class screenManager(): environment['screenData']['newCursor']['y'] = int( environment['screenData']['newContentBytes'][3]) # analyze content - environment['screenData']['newContentText'] = str(environment['screenData']['newContentBytes'][4:][::2].decode('cp1252').encode('utf-8'))[2:] + environment['screenData']['newContentText'] = str(environment['screenData']['newContentBytes'][4:][::2].decode('WINDOWS-1250')) + #environment['screenData']['newContentText'] = str(environment['screenData']['newContentBytes'][4:][::2].decode('cp1252')).encode('utf-8')[2:] environment['screenData']['newContentAttrib'] = environment['screenData']['newContentBytes'][5:][::2] - environment['screenData']['newContentText'] = '\n'.join(textwrap.wrap(environment['screenData']['newContentText'], environment['screenData']['columns']))[:-2] - + #environment['screenData']['newContentText'] = '\n'.join(textwrap.wrap(environment['screenData']['newContentText'], environment['screenData']['columns']))[:-2] + environment['screenData']['newContentText'] = re.sub("(.{"+ str(environment['screenData']['columns'])+"})", "\\1\n", str(environment['screenData']['newContentText']), 0, re.DOTALL) + if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: environment['screenData']['oldContentBytes'] = b'' environment['screenData']['oldContentAttrib'] = b'' @@ -47,7 +51,6 @@ class screenManager(): diff = difflib.ndiff(environment['screenData']['oldContentText'], environment['screenData']['newContentText']) environment['screenData']['delta'] = ''.join(x[2:] for x in diff if x.startswith('+ ')) environment['runtime']['speechDriver'].speak(environment['screenData']['delta']) - # set new "old" values environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes'] environment['screenData']['oldContentText'] = environment['screenData']['newContentText']