major rework, performance boost and bigger accuracy

This commit is contained in:
chrys 2016-08-06 04:34:37 +02:00
parent 7f8a03ae6c
commit 6373b3d8b8
12 changed files with 37 additions and 58 deletions

View File

@ -1,4 +1,3 @@
[sound]
enabled=True
driver=sox
@ -6,17 +5,13 @@ theme=default
[speech]
enabled=True
#driver=espeak
#language=en-us
#voice=en-us
driver=speechd
#rate=800
rate=50
volume=100
driver=espeak
rate=800
pitch=50
module=espeak
voice=de
language=de
voice=en-us
language=en-us
volume=200
[braille]
enabled=False
@ -28,9 +23,8 @@ driver=linux
[keyboard]
keyboardLayout=desktop
charEcho=False
wordEcho=True
wordEcho=False
[general]
debugLevel=0
punctuationLevel=1

View File

@ -4,6 +4,7 @@ class command():
def __init__(self):
pass
def run(self, environment):
return environment
if environment['screenData']['newCursor'] == environment['screenData']['oldCursor'] and\
environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
return environment

View File

@ -1,21 +0,0 @@
#!/bin/python
class command():
def __init__(self):
pass
def run(self, environment):
if environment['screenData']['newCursor']['x'] > environment['screenData']['oldCursor']['x']:
return environment
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
return environment
if environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
return environment
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -4,6 +4,9 @@ class command():
def __init__(self):
pass
def run(self, environment):
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']:
return environment
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
return environment
@ -11,7 +14,7 @@ class command():
pass
#environment['runtime']['outputManager'].presentText(environment, "blank",True)
else:
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']],True)
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']],interrupt=True)
return environment
def setCallback(self, callback):

View File

@ -4,6 +4,7 @@ class command():
def __init__(self):
pass
def run(self, environment):
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']:
return environment
if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']:

View File

@ -4,6 +4,7 @@ class command():
def __init__(self):
pass
def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho'):
return environment
if environment['screenData']['newCursor']['x'] <= environment['screenData']['oldCursor']['x']:

View File

@ -5,7 +5,7 @@ class command():
def __init__(self):
pass
def run(self, environment):
return environment
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho') and\
environment['screenData']['newCursor']['x'] <= environment['screenData']['oldCursor']['x']:
return environment
@ -22,7 +22,7 @@ class command():
if environment['screenData']['newCursor']['x'] > 0 and \
newContent[environment['screenData']['newCursor']['x'] - 1] == ' ':
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True)
print('word')
return environment
def setCallback(self, callback):
pass

View File

@ -4,16 +4,16 @@ class command():
def __init__(self):
pass
def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho') and\
environment['screenData']['newCursor']['x'] - environment['screenData']['oldCursor']['x'] ==1:
if environment['screenData']['newCursor']['x'] > environment['screenData']['oldCursor']['x']:
return environment
ttyChanged = environment['screenData']['newTTY'] != environment['screenData']['oldTTY']
if environment['screenData']['newDelta'] == environment['screenData']['oldDelta'] and \
not ttyChanged:
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
return environment
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], soundIconName='', interrupt=ttyChanged)
if environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
return environment
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=False)
return environment
def setCallback(self, callback):
pass

View File

@ -31,13 +31,9 @@ class fenrir():
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment)
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput')
if not timeout:
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
else:
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
if self.environment['commandInfo']['currCommand'] != '':
self.environment['input']['currShortcut'] = {}
self.environment['input']['currShortcutString'] = ''
self.handleCommands()
self.environment['runtime']['globalLock'].release()

View File

@ -64,19 +64,23 @@ class screen():
# changes on the screen
if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \
(environment['screenData']['newContentText'] != '' ):
# diff = difflib.ndiff(environment['screenData']['oldContentText'], environment['screenData']['newContentText'])
if environment['screenData']['oldContentText'] == '' and\
environment['screenData']['newContentText'] != '':
environment['screenData']['newDelta'] = environment['screenData']['newContentText']
else:
diffStart = 0
lastLine = len(environment['screenData']['newContentText']) - environment['screenData']['columns']
if environment['screenData']['newContentText'][:lastLine] == environment['screenData']['oldContentText'][:lastLine]:
diffStart = lastLine + 1
diff = difflib.ndiff(re.sub('[ \t]+', ' ', environment['screenData']['oldContentText'][diffStart:]),\
re.sub('[ \t]+', ' ', environment['screenData']['newContentText'][diffStart:]))
environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ '))
environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diff if x.startswith('- '))
if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \
environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \
environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]:
diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['newCursor']['x'] + environment['screenData']['newCursor']['y']
diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:],\
environment['screenData']['newContentText'][diffStart:])
else:
diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].splitlines(),\
environment['screenData']['newContentText'][diffStart:].splitlines())
diffList = list(diff)
environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ '))
environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- '))
return environment