remove environment parameter and pass it via initialisation

This commit is contained in:
chrys 2016-09-21 23:17:54 +02:00
parent 9c571ba032
commit e9b97945a3
84 changed files with 1080 additions and 1057 deletions

View File

@ -9,3 +9,7 @@ from core import debug
class braille(): class braille():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass

View File

@ -10,12 +10,12 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No description found'
def getDescription(self, environment): def run(self):
return 'No Description found'
def run(self, environment):
pass pass
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -18,40 +18,41 @@ class command():
self.language = '' self.language = ''
self.spellChecker = None self.spellChecker = None
def initialize(self, environment): def initialize(self, environment):
self.updateSpellLanguage(environment) self.env = environment
def shutdown(self, environment): self.updateSpellLanguage()
def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'adds the current word to the exceptions dictionary' return 'adds the current word to the exceptions dictionary'
def updateSpellLanguage(self, environment): def updateSpellLanguage(self):
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
def run(self, environment): def run(self):
if not initialized: if not initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True) self.env['runtime']['outputManager'].presentText('pychant is not installed', interrupt=True)
return return
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language: if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try: try:
self.updateSpellLanguage(environment) self.updateSpellLanguage()
except: except:
return return
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
# get the word # get the word
newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']] newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
if currWord != '': if currWord != '':
if self.spellChecker.is_added(currWord): if self.spellChecker.is_added(currWord):
environment['runtime']['outputManager'].presentText(environment, currWord + ' is already in dict',soundIcon='Cancel', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' is already in dict',soundIcon='Cancel', interrupt=True)
else: else:
self.spellChecker.add(currWord) self.spellChecker.add(currWord)
environment['runtime']['outputManager'].presentText(environment, currWord + ' added',soundIcon='Accept', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' added',soundIcon='Accept', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,16 +10,16 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'clears the currently selected clipboard' return 'clears the currently selected clipboard'
def run(self, environment): def run(self):
environment['commandBuffer']['currClipboard'] = -1 self.env['commandBuffer']['currClipboard'] = -1
del environment['commandBuffer']['clipboard'][:] del self.env['commandBuffer']['clipboard'][:]
environment['runtime']['outputManager'].presentText(environment, 'clipboard cleared', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard cleared', interrupt=True)
return return
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,34 +11,34 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'copies marked text to the currently selected clipboard' return 'copies marked text to the currently selected clipboard'
def run(self, environment): def run(self):
if (environment['commandBuffer']['Marks']['1'] == None) or \ if not (self.env['commandBuffer']['Marks']['1'] and \
(environment['commandBuffer']['Marks']['2'] == None): self.env['commandBuffer']['Marks']['2']):
environment['runtime']['outputManager'].presentText(environment, "two marks needed", interrupt=True) self.env['runtime']['outputManager'].presentText("two marks needed", interrupt=True)
return return
# use the last first and the last setted mark as range # use the last first and the last setted mark as range
startMark = environment['commandBuffer']['Marks']['1'].copy() startMark = self.env['commandBuffer']['Marks']['1'].copy()
endMark = environment['commandBuffer']['Marks']['2'].copy() endMark = self.env['commandBuffer']['Marks']['2'].copy()
marked = mark_utils.getTextBetweenMarks(startMark, endMark, environment['screenData']['newContentText']) marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText'])
environment['commandBuffer']['clipboard'] = [marked] + environment['commandBuffer']['clipboard'][:environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'general', 'numberOfClipboards') -1] self.env['commandBuffer']['clipboard'] = [marked] + self.env['commandBuffer']['clipboard'][:self.env['runtime']['settingsManager'].getSettingAsFloat('general', 'numberOfClipboards') -1]
environment['commandBuffer']['currClipboard'] = 0 self.env['commandBuffer']['currClipboard'] = 0
# reset marks # reset marks
environment['commandBuffer']['Marks']['1'] = None self.env['commandBuffer']['Marks']['1'] = None
environment['commandBuffer']['Marks']['2'] = None self.env['commandBuffer']['Marks']['2'] = None
if marked.strip(" \t\n") == '': if marked.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, marked, interrupt=True) self.env['runtime']['outputManager'].presentText(marked, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,26 +11,26 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'phonetically presents the current character' return 'phonetically presents the current character'
def run(self, environment): def run(self):
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
x, y, currChar = \ x, y, currChar = \
char_utils.getCurrentChar(cursorPos['x'], cursorPos['y'], environment['screenData']['newContentText']) char_utils.getCurrentChar(cursorPos['x'], cursorPos['y'], self.env['screenData']['newContentText'])
if currChar.strip(" \t\n") == '': if currChar.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank" ,interrupt=True) self.env['runtime']['outputManager'].presentText("blank" ,interrupt=True)
else: else:
currChar = char_utils.getPhonetic(currChar) currChar = char_utils.getPhonetic(currChar)
environment['runtime']['outputManager'].presentText(environment, currChar ,interrupt=True) self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'speaks the contents of the currently selected clipboard' return 'speaks the contents of the currently selected clipboard'
def run(self, environment): def run(self):
if len(environment['commandBuffer']['clipboard']) == 0: if len(self.env['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'reads the contents of the current screen' return 'reads the contents of the current screen'
def run(self, environment): def run(self):
if environment['screenData']['newContentText'].strip(" \t\n") == '': if self.env['screenData']['newContentText'].strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "screen is empty", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("screen is empty", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'],interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newContentText'],interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,25 +11,25 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'reads from the cursor to the bottom of the screen' return 'reads from the cursor to the bottom of the screen'
def run(self, environment): def run(self):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
textAfterCursor = mark_utils.getTextAfterMark(cursorPos, environment['screenData']['newContentText']) textAfterCursor = mark_utils.getTextAfterMark(cursorPos, self.env['screenData']['newContentText'])
if textAfterCursor.strip(" \t\n") == '': if textAfterCursor.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, textAfterCursor, interrupt=True) self.env['runtime']['outputManager'].presentText(textAfterCursor, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,25 +11,25 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'Reads from the top of the screen to the cursor position' return 'Reads from the top of the screen to the cursor position'
def run(self, environment): def run(self):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
textBeforeCursor = mark_utils.getTextBeforeMark(cursorPos, environment['screenData']['newContentText']) textBeforeCursor = mark_utils.getTextBeforeMark(cursorPos, self.env['screenData']['newContentText'])
if textBeforeCursor.strip(" \t\n") == '': if textBeforeCursor.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, textBeforeCursor, interrupt=True) self.env['runtime']['outputManager'].presentText(textBeforeCursor, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -12,27 +12,27 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'phonetically spells the current word' return 'phonetically spells the current word'
def run(self, environment): def run(self):
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
x, y, currWord = \ x, y, currWord = \
word_utils.getCurrentWord(cursorPos['x'], cursorPos['y'], environment['screenData']['newContentText']) word_utils.getCurrentWord(cursorPos['x'], cursorPos['y'], self.env['screenData']['newContentText'])
if currWord.strip(" \t\n") == '': if currWord.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
firstSequence = True firstSequence = True
for c in currWord: for c in currWord:
currChar = char_utils.getPhonetic(c) currChar = char_utils.getPhonetic(c)
environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=firstSequence) self.env['runtime']['outputManager'].presentText(currChar, interrupt=firstSequence)
firstSequence = False firstSequence = False
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -10,20 +10,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'displays the position of the review cursor' return 'displays the position of the review cursor'
def run(self, environment): def run(self):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
environment['runtime']['outputManager'].presentText(environment, "line "+ str(cursorPos['y']+1) + " column "+ str(cursorPos['x']+1), interrupt=True) self.env['runtime']['outputManager'].presentText("line "+ str(cursorPos['y']+1) + " column "+ str(cursorPos['x']+1), interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'presents the date' return 'presents the date'
def run(self, environment): def run(self):
dateFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'dateFormat') dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
# get the time formatted # get the time formatted
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat) dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
# present the time via speak and braile, there is no soundicon, interrupt the current speech # present the time via speak and braile, there is no soundicon, interrupt the current speech
environment['runtime']['outputManager'].presentText(environment, dateString , soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,22 +11,22 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'decrease sound volume' return 'decrease sound volume'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume') value = self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume')
value = round((math.ceil(10 * value) / 10) - 0.1, 2) value = round((math.ceil(10 * value) / 10) - 0.1, 2)
if value < 0.1: if value < 0.1:
value = 0.1 value = 0.1
environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'volume', str(value)) self.env['runtime']['settingsManager'].setSetting('sound', 'volume', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent sound volume", soundIcon='SoundOff', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent sound volume", soundIcon='SoundOff', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'decreases the pitch of the speech' return 'decreases the pitch of the speech'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'pitch')
value = round((math.ceil(10 * value) / 10) - 0.1, 2) value = round((math.ceil(10 * value) / 10) - 0.1, 2)
if value < 0.0: if value < 0.0:
value = 0.0 value = 0.0
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'pitch', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'pitch', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech pitch", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech pitch", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'decreases the rate of the speech' return 'decreases the rate of the speech'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate')
value = round((math.ceil(10 * value) / 10) - 0.1, 2) value = round((math.ceil(10 * value) / 10) - 0.1, 2)
if value < 0.0: if value < 0.0:
value = 0.0 value = 0.0
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'rate', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'rate', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech rate", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech rate", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'decreases the volume of the speech' return 'decreases the volume of the speech'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'volume')
value = round((math.ceil(10 * value) / 10) - 0.1, 2) value = round((math.ceil(10 * value) / 10) - 0.1, 2)
if value < 0.1: if value < 0.1:
value = 0.1 value = 0.1
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'volume', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'volume', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech volume", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech volume", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,21 +10,21 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'exits review mode' return 'exits review mode'
def run(self, environment): def run(self):
if (environment['screenData']['oldCursorReview'] == None) and \ if not (self.env['screenData']['oldCursorReview']) and \
(environment['screenData']['newCursorReview'] == None): (self.env['screenData']['newCursorReview']):
environment['runtime']['outputManager'].presentText(environment, "Not in review mode", interrupt=True) self.env['runtime']['outputManager'].presentText("Not in review mode", interrupt=True)
return return
environment['screenData']['oldCursorReview'] = None self.env['screenData']['oldCursorReview'] = None
environment['screenData']['newCursorReview'] = None self.env['screenData']['newCursorReview'] = None
environment['runtime']['outputManager'].presentText(environment, "leve review mode", interrupt=True) self.env['runtime']['outputManager'].presentText("leve review mode", interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'selects the first clipboard' return 'selects the first clipboard'
def run(self, environment): def run(self):
if len(environment['commandBuffer']['clipboard']) == 0: if len(self.env['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
environment['commandBuffer']['currClipboard'] = 0 self.env['commandBuffer']['currClipboard'] = 0
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,15 +10,15 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'sends the following keypress to the terminal' return 'sends the following keypress to the terminal'
def run(self, environment): def run(self):
environment['input']['keyForeward'] = True self.env['input']['keyForeward'] = True
environment['runtime']['outputManager'].presentText(environment, 'Foreward next keypress', interrupt=True) self.env['runtime']['outputManager'].presentText('Foreward next keypress', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,22 +11,22 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'adjusts the volume for in coming sounds' return 'adjusts the volume for in coming sounds'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume') value = self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume')
value = round((math.ceil(10 * value) / 10) + 0.1, 2) value = round((math.ceil(10 * value) / 10) + 0.1, 2)
if value > 1.0: if value > 1.0:
value = 1.0 value = 1.0
environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'volume', str(value)) self.env['runtime']['settingsManager'].setSetting('sound', 'volume', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent sound volume", soundIcon='SoundOn', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent sound volume", soundIcon='SoundOn', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'increases the pitch of the speech' return 'increases the pitch of the speech'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'pitch')
value = round((math.ceil(10 * value) / 10) + 0.1, 2) value = round((math.ceil(10 * value) / 10) + 0.1, 2)
if value > 1.0: if value > 1.0:
value = 1.0 value = 1.0
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'pitch', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'pitch', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech pitch", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech pitch", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'increase the speech rat' return 'increase the speech rat'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate')
value = round((math.ceil(10 * value) / 10) + 0.1, 2) value = round((math.ceil(10 * value) / 10) + 0.1, 2)
if value > 1.0: if value > 1.0:
value = 1.0 value = 1.0
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'rate', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'rate', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech rate", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech rate", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'increase the speech volume' return 'increase the speech volume'
def run(self, environment): def run(self):
value = environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume') value = self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'volume')
value = round((math.ceil(10 * value) / 10) + 0.1, 2) value = round((math.ceil(10 * value) / 10) + 0.1, 2)
if value > 1.0: if value > 1.0:
value = 1.0 value = 1.0
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'volume', str(value)) self.env['runtime']['settingsManager'].setSetting('speech', 'volume', str(value))
environment['runtime']['outputManager'].presentText(environment, str(int(value * 100)) + " percent speech volume", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(str(int(value * 100)) + " percent speech volume", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,26 +11,26 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'shows the indention level for the current line' return 'shows the indention level for the current line'
def run(self, environment): def run(self):
# Prefer review cursor over text cursor # Prefer review cursor over text cursor
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
x, y, currLine = \ x, y, currLine = \
line_utils.getCurrentLine(cursorPos['x'], cursorPos['y'], environment['screenData']['newContentText']) line_utils.getCurrentLine(cursorPos['x'], cursorPos['y'], self.env['screenData']['newContentText'])
if currLine.strip(" \t\n") == '': if currLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, "indent "+ str(len(currLine) - len(currLine.lstrip())), interrupt=True) self.env['runtime']['outputManager'].presentText("indent "+ str(len(currLine) - len(currLine.lstrip())), interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'selects the last clipboard' return 'selects the last clipboard'
def run(self, environment): def run(self):
if len(environment['commandBuffer']['clipboard']) == 0: if len(self.env['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
environment['commandBuffer']['currClipboard'] = len(environment['commandBuffer']['clipboard']) -1 self.env['commandBuffer']['currClipboard'] = len(self.env['commandBuffer']['clipboard']) -1
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,14 +10,14 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'displays the last received text' return 'displays the last received text'
def run(self, environment): def run(self):
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -13,19 +13,19 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'pastes the text from the currently selected clipboard' return 'pastes the text from the currently selected clipboard'
def run(self, environment): def run(self):
currClipboard = environment['commandBuffer']['currClipboard'] currClipboard = self.env['commandBuffer']['currClipboard']
if currClipboard < 0: if currClipboard < 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
with open("/dev/tty" + environment['screenData']['newTTY'], 'w') as fd: with open("/dev/tty" + self.env['screenData']['newTTY'], 'w') as fd:
for c in environment['commandBuffer']['clipboard'][currClipboard]: for c in self.env['commandBuffer']['clipboard'][currClipboard]:
fcntl.ioctl(fd, termios.TIOCSTI, c) fcntl.ioctl(fd, termios.TIOCSTI, c)
time.sleep(0.02) time.sleep(0.02)

View File

@ -11,28 +11,28 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'speaks the currently selected text that will be copied to the clipboard' return 'speaks the currently selected text that will be copied to the clipboard'
def run(self, environment): def run(self):
if (environment['commandBuffer']['Marks']['1'] == None) or \ if not (self.env['commandBuffer']['Marks']['1'] and \
(environment['commandBuffer']['Marks']['2'] == None): self.env['commandBuffer']['Marks']['2']):
environment['runtime']['outputManager'].presentText(environment, "please set begin and endmark", interrupt=True) self.env['runtime']['outputManager'].presentText("please set begin and endmark", interrupt=True)
return return
# use the last first and the last setted mark as range # use the last first and the last setted mark as range
startMark = environment['commandBuffer']['Marks']['1'].copy() startMark = self.env['commandBuffer']['Marks']['1'].copy()
endMark = environment['commandBuffer']['Marks']['2'].copy() endMark = self.env['commandBuffer']['Marks']['2'].copy()
marked = mark_utils.getTextBetweenMarks(startMark, endMark, environment['screenData']['newContentText']) marked = mark_utils.getTextBetweenMarks(startMark, endMark, self.env['screenData']['newContentText'])
if marked.strip(" \t\n") == '': if marked.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, marked, interrupt=True) self.env['runtime']['outputManager'].presentText(marked, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,23 +10,23 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'selects the next clipboard' return 'selects the next clipboard'
def run(self, environment): def run(self):
if len(environment['commandBuffer']['clipboard']) == 0: if len(self.env['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
environment['commandBuffer']['currClipboard'] += 1 self.env['commandBuffer']['currClipboard'] += 1
if environment['commandBuffer']['currClipboard'] > len(environment['commandBuffer']['clipboard']) -1: if self.env['commandBuffer']['currClipboard'] > len(self.env['commandBuffer']['clipboard']) -1:
environment['commandBuffer']['currClipboard'] = 0 self.env['commandBuffer']['currClipboard'] = 0
environment['runtime']['outputManager'].presentText(environment, 'First clipboard ', interrupt=True) self.env['runtime']['outputManager'].presentText('First clipboard ', interrupt=True)
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=False) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=False)
else: else:
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review to the next word and presents it' return 'moves review to the next word and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if self.env['screenData']['newCursorReview'] == None:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currWord = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \
word_utils.getNextWord(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) word_utils.getNextWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currWord.strip(" \t\n") == '': if currWord.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True) self.env['runtime']['outputManager'].presentText(currWord, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'present first line' return 'present first line'
def run(self, environment): def run(self):
x, y, firstLine = \ x, y, firstLine = \
line_utils.getCurrentLine(0, 0, environment['screenData']['newContentText']) line_utils.getCurrentLine(0, 0, self.env['screenData']['newContentText'])
if firstLine.strip(" \t\n") == '': if firstLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, firstLine, interrupt=True) self.env['runtime']['outputManager'].presentText(firstLine, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'current line' return 'current line'
def run(self, environment): def run(self):
x, y, lastLine = \ x, y, lastLine = \
line_utils.getCurrentLine(0, environment['screenData']['lines'] -1, environment['screenData']['newContentText']) line_utils.getCurrentLine(0, self.env['screenData']['lines'] -1, self.env['screenData']['newContentText'])
if lastLine.strip(" \t\n") == '': if lastLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, lastLine, interrupt=True) self.env['runtime']['outputManager'].presentText(lastLine, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,23 +10,23 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'selects the previous clipboard' return 'selects the previous clipboard'
def run(self, environment): def run(self):
if len(environment['commandBuffer']['clipboard']) == 0: if len(self.env['commandBuffer']['clipboard']) == 0:
environment['runtime']['outputManager'].presentText(environment, 'clipboard empty', interrupt=True) self.env['runtime']['outputManager'].presentText('clipboard empty', interrupt=True)
return return
environment['commandBuffer']['currClipboard'] -= 1 self.env['commandBuffer']['currClipboard'] -= 1
if environment['commandBuffer']['currClipboard'] < 0: if self.env['commandBuffer']['currClipboard'] < 0:
environment['commandBuffer']['currClipboard'] = len(environment['commandBuffer']['clipboard']) -1 self.env['commandBuffer']['currClipboard'] = len(self.env['commandBuffer']['clipboard']) -1
environment['runtime']['outputManager'].presentText(environment, 'Last clipboard ', interrupt=True) self.env['runtime']['outputManager'].presentText('Last clipboard ', interrupt=True)
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=False) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=False)
else: else:
environment['runtime']['outputManager'].presentText(environment, environment['commandBuffer']['clipboard'][environment['commandBuffer']['currClipboard']], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['commandBuffer']['clipboard'][self.env['commandBuffer']['currClipboard']], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,14 +10,14 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'exits Fenrir' return 'exits Fenrir'
def run(self, environment): def run(self):
environment['generalInformation']['running'] = False self.env['generalInformation']['running'] = False
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,16 +10,16 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'removes marks from selected text' return 'removes marks from selected text'
def run(self, environment): def run(self):
environment['commandBuffer']['Marks']['1'] = None self.env['commandBuffer']['Marks']['1'] = None
environment['commandBuffer']['Marks']['2'] = None self.env['commandBuffer']['Marks']['2'] = None
environment['runtime']['outputManager'].presentText(environment, 'Remove marks', interrupt=True) self.env['runtime']['outputManager'].presentText('Remove marks', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -18,40 +18,41 @@ class command():
self.language = '' self.language = ''
self.spellChecker = None self.spellChecker = None
def initialize(self, environment): def initialize(self, environment):
self.updateSpellLanguage(environment) self.env = environment
def shutdown(self, environment): self.updateSpellLanguage()
def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'removes the current word from the exceptions dictionary' return 'removes the current word from the exceptions dictionary'
def updateSpellLanguage(self, environment): def updateSpellLanguage(self):
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
def run(self, environment): def run(self):
if not initialized: if not initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True) self.env['runtime']['outputManager'].presentText('pychant is not installed', interrupt=True)
return return
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language: if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try: try:
self.updateSpellLanguage(environment) self.updateSpellLanguage()
except: except:
return return
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
# get the word # get the word
newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']] newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
if currWord != '': if currWord != '':
if self.spellChecker.is_removed(currWord): if self.spellChecker.is_removed(currWord):
environment['runtime']['outputManager'].presentText(environment, currWord + ' is already removed from dict',soundIcon='Cancel', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' is already removed from dict',soundIcon='Cancel', interrupt=True)
else: else:
self.spellChecker.remove(currWord) self.spellChecker.remove(currWord)
environment['runtime']['outputManager'].presentText(environment, currWord + ' removed',soundIcon='Accept', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' removed',soundIcon='Accept', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,15 +10,15 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'move review to bottom of screen' return 'move review to bottom of screen'
def run(self, environment): def run(self):
environment['screenData']['newCursorReview'] = { 'x': 0, 'y':environment['screenData']['lines'] -1} self.env['screenData']['newCursorReview'] = { 'x': 0, 'y':self.env['screenData']['lines'] -1}
environment['runtime']['outputManager'].presentText(environment, "Bottom", interrupt=True) self.env['runtime']['outputManager'].presentText("Bottom", interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'presents the current character.' return 'presents the current character.'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currChar = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \
char_utils.getCurrentChar(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) char_utils.getCurrentChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currChar.strip(" \t\n") == '': if currChar.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank" ,interrupt=True) self.env['runtime']['outputManager'].presentText("blank" ,interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currChar ,interrupt=True) self.env['runtime']['outputManager'].presentText(currChar ,interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'current line' return 'current line'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currLine = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currLine = \
line_utils.getCurrentLine(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) line_utils.getCurrentLine(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currLine.strip(" \t\n") == '': if currLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currLine, interrupt=True) self.env['runtime']['outputManager'].presentText(currLine, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'current word.' return 'current word.'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currWord = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \
word_utils.getCurrentWord(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currWord.strip(" \t\n") == '': if currWord.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True) self.env['runtime']['outputManager'].presentText(currWord, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review to the next character and presents it' return 'moves review to the next character and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currChar = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \
char_utils.getNextChar(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) char_utils.getNextChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currChar.strip(" \t\n") == '': if currChar.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=True) self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review to the next line and presents it' return 'moves review to the next line and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currLine = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currLine = \
line_utils.getNextLine(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) line_utils.getNextLine(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currLine.strip(" \t\n") == '': if currLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currLine, interrupt=True) self.env['runtime']['outputManager'].presentText(currLine, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review to the previous character and presents it' return 'moves review to the previous character and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currChar = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currChar = \
char_utils.getPrevChar(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) char_utils.getPrevChar(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currChar.strip(" \t\n") == '': if currChar.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=True) self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review to the previous line and presents it' return 'moves review to the previous line and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currLine = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currLine = \
line_utils.getPrevLine(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) line_utils.getPrevLine(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currLine.strip(" \t\n") == '': if currLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currLine, interrupt=True) self.env['runtime']['outputManager'].presentText(currLine, interrupt=True)
return
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,24 +11,24 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'moves review focus to the previous word and presents it' return 'moves review focus to the previous word and presents it'
def run(self, environment): def run(self):
environment['screenData']['oldCursorReview'] = environment['screenData']['newCursorReview'] self.env['screenData']['oldCursorReview'] = self.env['screenData']['newCursorReview']
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['screenData']['newCursorReview'] = environment['screenData']['newCursor'].copy() self.env['screenData']['newCursorReview'] = self.env['screenData']['newCursor'].copy()
environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], currWord = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \
word_utils.getPrevWord(environment['screenData']['newCursorReview']['x'], environment['screenData']['newCursorReview']['y'], environment['screenData']['newContentText']) word_utils.getPrevWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currWord.strip(" \t\n") == '': if currWord.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", interrupt=True) self.env['runtime']['outputManager'].presentText("blank", interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True) self.env['runtime']['outputManager'].presentText(currWord, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,15 +11,15 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'move review to top of screen' return 'move review to top of screen'
def run(self, environment): def run(self):
environment['screenData']['newCursorReview'] = {'x':0,'y':0} self.env['screenData']['newCursorReview'] = {'x':0,'y':0}
environment['runtime']['outputManager'].presentText(environment, "Top", interrupt=True) self.env['runtime']['outputManager'].presentText("Top", interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,23 +10,23 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'places marks to select text to copy to the clipboard' return 'places marks to select text to copy to the clipboard'
def run(self, environment): def run(self):
if environment['screenData']['newCursorReview'] == None: if not self.env['screenData']['newCursorReview']:
environment['runtime']['outputManager'].presentText(environment, 'no review cursor', interrupt=True) self.env['runtime']['outputManager'].presentText('no review cursor', interrupt=True)
return return
if environment['commandBuffer']['Marks']['1'] == None: if not self.env['commandBuffer']['Marks']['1']:
environment['commandBuffer']['Marks']['1'] = environment['screenData']['newCursorReview'].copy() self.env['commandBuffer']['Marks']['1'] = self.env['screenData']['newCursorReview'].copy()
else: else:
environment['commandBuffer']['Marks']['2'] = environment['screenData']['newCursorReview'].copy() self.env['commandBuffer']['Marks']['2'] = self.env['screenData']['newCursorReview'].copy()
environment['runtime']['outputManager'].presentText(environment, 'set mark', interrupt=True) self.env['runtime']['outputManager'].presentText('set mark', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,12 +10,12 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'interrupts the current presentation' return 'interrupts the current presentation'
def run(self, environment): def run(self):
environment['runtime']['outputManager'].interruptOutput(environment) self.env['runtime']['outputManager'].interruptOutput()
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -18,37 +18,38 @@ class command():
self.language = '' self.language = ''
self.spellChecker = None self.spellChecker = None
def initialize(self, environment): def initialize(self, environment):
self.updateSpellLanguage(environment) self.env = environment
def shutdown(self, environment): self.updateSpellLanguage()
def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'checks the spelling of the current word' return 'checks the spelling of the current word'
def updateSpellLanguage(self, environment): def updateSpellLanguage(self):
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
def run(self, environment): def run(self):
if not initialized: if not initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True) self.env['runtime']['outputManager'].presentText('pychant is not installed', interrupt=True)
return return
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language: if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try: try:
self.updateSpellLanguage(environment) self.updateSpellLanguage()
except: except:
return return
if (environment['screenData']['newCursorReview'] != None): if self.env['screenData']['newCursorReview']:
cursorPos = environment['screenData']['newCursorReview'].copy() cursorPos = self.env['screenData']['newCursorReview'].copy()
else: else:
cursorPos = environment['screenData']['newCursor'].copy() cursorPos = self.env['screenData']['newCursor'].copy()
# get the word # get the word
newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']] newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
if currWord != '': if currWord != '':
if not self.spellChecker.check(currWord): if not self.spellChecker.check(currWord):
environment['runtime']['outputManager'].presentText(environment, 'misspelled',soundIcon='mispell', interrupt=True) self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,20 +11,20 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'presents the time' return 'presents the time'
def run(self, environment): def run(self):
timeFormat = environment['runtime']['settingsManager'].getSetting(environment,'general', 'timeFormat') timeFormat = self.env['runtime']['settingsManager'].getSetting('general', 'timeFormat')
# get the time formatted # get the time formatted
timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat) timeString = datetime.datetime.strftime(datetime.datetime.now(), timeFormat)
# present the time via speak and braile, there is no soundicon, interrupt the current speech # present the time via speak and braile, there is no soundicon, interrupt the current speech
environment['runtime']['outputManager'].presentText(environment, timeString , soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText(timeString , soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -9,18 +9,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'enables or disables automatic reading of new text as it appears' return 'enables or disables automatic reading of new text as it appears'
def run(self, environment): def run(self):
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'autoReadIncomming', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'))) self.env['runtime']['settingsManager'].setSetting('speech', 'autoReadIncomming', str(not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'autoReadIncomming')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'): if self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'autoReadIncomming'):
environment['runtime']['outputManager'].presentText(environment, "autoread enabled", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText("autoread enabled", soundIcon='', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, "autoread disabled", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText("autoread disabled", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'enables or disables automatic spell checking' return 'enables or disables automatic spell checking'
def run(self, environment): def run(self):
environment['runtime']['settingsManager'].setSetting(environment, 'general', 'autoSpellCheck', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'))) self.env['runtime']['settingsManager'].setSetting('general', 'autoSpellCheck', str(not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'): if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
environment['runtime']['outputManager'].presentText(environment, "auto spellcheck enabled", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText("auto spellcheck enabled", soundIcon='', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, "auto spellcheck disabled", soundIcon='', interrupt=True) self.env['runtime']['outputManager'].presentText("auto spellcheck disabled", soundIcon='', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'enables and disables output in braille' return 'enables and disables output in braille'
def run(self, environment): def run(self):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "braille disabled", soundIcon='BrailleOff', interrupt=True) self.env['runtime']['outputManager'].presentText("braille disabled", soundIcon='BrailleOff', interrupt=True)
environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'))) self.env['runtime']['settingsManager'].setSetting('braille', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "braille enabled", soundIcon='BrailleOn', interrupt=True) self.env['runtime']['outputManager'].presentText("braille enabled", soundIcon='BrailleOn', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,25 +10,25 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'toggles all output settings' return 'toggles all output settings'
def run(self, environment): def run(self):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \ if self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled') or \
environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \ self.env['runtime']['settingsManager'].getSettingAsBool('sound', 'enabled') or \
environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "fenrir muted", soundIcon='Accept', interrupt=True) self.env['runtime']['outputManager'].presentText("fenrir muted", soundIcon='Accept', interrupt=True)
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','False') self.env['runtime']['settingsManager'].setSetting('speech', 'enabled','False')
environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','False') self.env['runtime']['settingsManager'].setSetting('sound', 'enabled','False')
environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','False') self.env['runtime']['settingsManager'].setSetting('braille', 'enabled','False')
else: else:
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','True') self.env['runtime']['settingsManager'].setSetting('speech', 'enabled','True')
environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','True') self.env['runtime']['settingsManager'].setSetting('sound', 'enabled','True')
environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','True') self.env['runtime']['settingsManager'].setSetting('braille', 'enabled','True')
environment['runtime']['outputManager'].presentText(environment, "fenrir unmuted", soundIcon='Cancel', interrupt=True) self.env['runtime']['outputManager'].presentText("fenrir unmuted", soundIcon='Cancel', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'enables or disables sound' return 'enables or disables sound'
def run(self, environment): def run(self):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('sound', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "sound disabled", soundIcon='SoundOff', interrupt=True) self.env['runtime']['outputManager'].presentText("sound disabled", soundIcon='SoundOff', interrupt=True)
environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'))) self.env['runtime']['settingsManager'].setSetting('sound', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('sound', 'enabled')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('sound', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "sound enabled", soundIcon='SoundOn', interrupt=True) self.env['runtime']['outputManager'].presentText("sound enabled", soundIcon='SoundOn', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,18 +10,18 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
return 'enables or disables speech' return 'enables or disables speech'
def run(self, environment): def run(self):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "speech disabled", soundIcon='SpeechOff', interrupt=True) self.env['runtime']['outputManager'].presentText("speech disabled", soundIcon='SpeechOff', interrupt=True)
environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'))) self.env['runtime']['settingsManager'].setSetting('speech', 'enabled', str(not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled')))
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled'):
environment['runtime']['outputManager'].presentText(environment, "speech enabled", soundIcon='SpeechOn', interrupt=True) self.env['runtime']['outputManager'].presentText("speech enabled", soundIcon='SpeechOn', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def getDescription(self, environment): def getDescription(self):
environment['generalInformation']['tutorialMode'] = False self.env['generalInformation']['tutorialMode'] = False
return 'You are leving the tutorial mode. Press that shortcut again to enter the tutorial mode again.' return 'You are leving the tutorial mode. Press that shortcut again to enter the tutorial mode again.'
def run(self, environment): def run(self):
text = 'you entered the tutorial mode. In that mode the commands are not executed. but you get an description what the shortcut does. to leve the tutorial mode press that shortcut again.' text = 'you entered the tutorial mode. In that mode the commands are not executed. but you get an description what the shortcut does. to leve the tutorial mode press that shortcut again.'
environment['runtime']['outputManager'].presentText(environment, text, interrupt=True) self.env['runtime']['outputManager'].presentText(text, interrupt=True)
environment['generalInformation']['tutorialMode'] = True self.env['generalInformation']['tutorialMode'] = True
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,21 +10,21 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass
def getDescription(self, environment):
return '' return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'interruptOnKeyPress'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'interruptOnKeyPress'):
return return
if environment['runtime']['inputManager'].noKeyPressed(environment): if self.env['runtime']['inputManager'].noKeyPressed():
return return
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
environment['runtime']['outputManager'].interruptOutput(environment) self.env['runtime']['outputManager'].interruptOutput()
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,30 +10,30 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return ''
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
# TTY Change # TTY Change
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
if environment['runtime']['inputManager'].noKeyPressed(environment): if self.env['runtime']['inputManager'].noKeyPressed():
return return
# detect an change on the screen, we just want to cursor arround, so no change should appear # detect an change on the screen, we just want to cursor arround, so no change should appear
if environment['screenData']['newDelta'] != '': if self.env['screenData']['newDelta'] != '':
return return
if environment['screenData']['newNegativeDelta'] != '': if self.env['screenData']['newNegativeDelta'] != '':
return return
# is it a horizontal change? # is it a horizontal change?
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y'] or\ if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y'] or\
environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
return return
currChar = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']] currChar = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']][self.env['screenData']['newCursor']['x']]
if not currChar.strip(" \t\n") == '': if not currChar.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, currChar, interrupt=True) self.env['runtime']['outputManager'].presentText(currChar, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,26 +10,26 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return ''
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: if self.env['screenData']['newDelta'] != self.env['screenData']['oldDelta']:
return return
if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']: if self.env['screenData']['newCursor']['y'] == self.env['screenData']['oldCursor']['y']:
return return
if environment['runtime']['inputManager'].noKeyPressed(environment): if self.env['runtime']['inputManager'].noKeyPressed():
return return
currLine = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] currLine = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
if currLine.strip(" \t\n") == '': if currLine.strip(" \t\n") == '':
environment['runtime']['outputManager'].presentText(environment, "blank", soundIcon='EmptyLine', interrupt=True) self.env['runtime']['outputManager'].presentText("blank", soundIcon='EmptyLine', interrupt=True)
else: else:
environment['runtime']['outputManager'].presentText(environment, currLine, interrupt=True) self.env['runtime']['outputManager'].presentText(currLine, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,28 +10,28 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
return return
# detect deletion or chilling # detect deletion or chilling
if environment['screenData']['newCursor']['x'] <= environment['screenData']['oldCursor']['x']: if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']:
return return
# TTY Change # TTY Change
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
# is there any change? # is there any change?
if environment['screenData']['newDelta'] == '': if self.env['screenData']['newDelta'] == '':
return return
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now) # big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
if len(environment['screenData']['newDelta']) > 3: if len(self.env['screenData']['newDelta']) > 3:
return return
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,48 +11,48 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'wordEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
return return
# just when cursor move worddetection is needed # just when cursor move worddetection is needed
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: if self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
return return
# for now no new line # for now no new line
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']: if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y']:
return return
if len(environment['screenData']['newDelta']) > 1: if len(self.env['screenData']['newDelta']) > 1:
return return
# TTY Change is no new word # TTY Change is no new word
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
# first place could not be the end of a word # first place could not be the end of a word
if environment['screenData']['newCursor']['x'] == 0: if self.env['screenData']['newCursor']['x'] == 0:
return return
# get the word # get the word
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)
# was this a typed word? # was this a typed word?
if environment['screenData']['newDelta'] != '': if self.env['screenData']['newDelta'] != '':
if not(newContent[environment['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['oldCursor']['x']): if not(newContent[self.env['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['oldCursor']['x']):
return return
else: else:
# or just arrow arround? # or just arrow arround?
if not(newContent[environment['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['newCursor']['x']): if not(newContent[self.env['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['newCursor']['x']):
return return
if currWord != '': if currWord != '':
environment['runtime']['outputManager'].presentText(environment, currWord, interrupt=True) self.env['runtime']['outputManager'].presentText(currWord, interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -18,60 +18,62 @@ class command():
self.language = '' self.language = ''
self.spellChecker = '' self.spellChecker = ''
def initialize(self, environment): def initialize(self, environment):
self.updateSpellLanguage(environment) self.env = environment
def shutdown(self, environment): self.updateSpellLanguage()
pass def shutdown(self):
def getDescription(self, environment): pass
return 'No Description found' def getDescription(self):
def updateSpellLanguage(self, environment): return 'No Description found'
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')
def run(self, environment): def updateSpellLanguage(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'): self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
def run(self):
if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
return return
if not initialized: if not initialized:
return return
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language: if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try: try:
self.updateSpellLanguage(environment) self.updateSpellLanguage()
except: except:
return return
# just when cursor move worddetection is needed # just when cursor move worddetection is needed
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: if self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
return return
# for now no new line # for now no new line
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']: if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y']:
return return
if len(environment['screenData']['newDelta']) > 1: if len(self.env['screenData']['newDelta']) > 1:
return return
# TTY Change is no new word # TTY Change is no new word
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
# first place could not be the end of a word # first place could not be the end of a word
if environment['screenData']['newCursor']['x'] == 0: if self.env['screenData']['newCursor']['x'] == 0:
return return
# get the word # get the word
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)
# was this a typed word? # was this a typed word?
if environment['screenData']['newDelta'] != '': if self.env['screenData']['newDelta'] != '':
if not(newContent[environment['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['oldCursor']['x']): if not(newContent[self.env['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['oldCursor']['x']):
return return
else: else:
# or just arrow arround? # or just arrow arround?
if not(newContent[environment['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != environment['screenData']['newCursor']['x']): if not(newContent[self.env['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['newCursor']['x']):
return return
if currWord != '': if currWord != '':
if not self.spellChecker.check(currWord): if not self.spellChecker.check(currWord):
environment['runtime']['outputManager'].presentText(environment, 'misspelled',soundIcon='mispell', interrupt=True) self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,36 +10,36 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charDeleteEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
return return
# detect typing or chilling # detect typing or chilling
if environment['screenData']['newCursor']['x'] >= environment['screenData']['oldCursor']['x']: if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
return return
# TTY change # TTY change
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
# More than just a deletion happend # More than just a deletion happend
if environment['screenData']['newDelta'].strip() != '': if self.env['screenData']['newDelta'].strip() != '':
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: if self.env['screenData']['newDelta'] != self.env['screenData']['oldDelta']:
return return
# No deletion # No deletion
if environment['screenData']['newNegativeDelta'] == '': if self.env['screenData']['newNegativeDelta'] == '':
return return
# too much for a single backspace... # too much for a single backspace...
if len(environment['screenData']['newNegativeDelta']) >= 5: if len(self.env['screenData']['newNegativeDelta']) >= 5:
return return
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newNegativeDelta'], interrupt=True) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,27 +10,27 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'autoReadIncomming'): if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'autoReadIncomming'):
return return
# is there something to read? # is there something to read?
if environment['screenData']['newDelta'] == '': if self.env['screenData']['newDelta'] == '':
return return
# dont read TTY change # dont read TTY change
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
# its a cursor movement (experimental) - maybe also check current shortcut string? # its a cursor movement (experimental) - maybe also check current shortcut string?
if abs(environment['screenData']['newCursor']['x'] - environment['screenData']['oldCursor']['x']) >= 1: if abs(self.env['screenData']['newCursor']['x'] - self.env['screenData']['oldCursor']['x']) >= 1:
if len(environment['screenData']['newDelta']) <= 5: if len(self.env['screenData']['newDelta']) <= 5:
return return
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=False) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=False)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -11,29 +11,29 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'promote', 'enabled'): if not self.env['runtime']['settingsManager'].getSettingAsBool('promote', 'enabled'):
return return
if environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list').strip(" \t\n") == '': if self.env['runtime']['settingsManager'].getSetting('promote', 'list').strip(" \t\n") == '':
return return
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
if environment['screenData']['newDelta'] == '': if self.env['screenData']['newDelta'] == '':
return return
if int(time.time() - environment['input']['lastInputTime']) < environment['runtime']['settingsManager'].getSettingAsInt(environment, 'promote', 'inactiveTimeoutSec'): if int(time.time() - self.env['input']['lastInputTime']) < self.env['runtime']['settingsManager'].getSettingAsInt('promote', 'inactiveTimeoutSec'):
return return
if len(environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list')) == 0: if len(self.env['runtime']['settingsManager'].getSetting('promote', 'list')) == 0:
return return
for promote in environment['runtime']['settingsManager'].getSetting(environment, 'promote', 'list').split(','): for promote in self.env['runtime']['settingsManager'].getSetting('promote', 'list').split(','):
if promote in environment['screenData']['newDelta']: if promote in self.env['screenData']['newDelta']:
environment['runtime']['outputManager'].playSoundIcon(environment,'PromotedText') self.env['runtime']['outputManager'].playSoundIcon('PromotedText')
environment['input']['lastInputTime'] = time.time() self.env['input']['lastInputTime'] = time.time()
return return
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] == self.env['screenData']['oldTTY']:
return return
environment['runtime']['outputManager'].presentText(environment, "screen " + str(environment['screenData']['newTTY']),soundIcon='ChangeTTY', interrupt=True) self.env['runtime']['outputManager'].presentText("screen " + str(self.env['screenData']['newTTY']),soundIcon='ChangeTTY', interrupt=True)
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=False) self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=False)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] == self.env['screenData']['oldTTY']:
return return
environment['commandBuffer']['Marks']['1'] = None self.env['commandBuffer']['Marks']['1'] = None
environment['commandBuffer']['Marks']['2'] = None self.env['commandBuffer']['Marks']['2'] = None
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -10,17 +10,17 @@ class command():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def getDescription(self):
pass return 'No Description found'
def getDescription(self, environment):
return ''
def run(self, environment): def run(self):
if environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] == self.env['screenData']['oldTTY']:
return return
environment['screenData']['oldCursorReview'] = None self.env['screenData']['oldCursorReview'] = None
environment['screenData']['newCursorReview'] = None self.env['screenData']['newCursorReview'] = None
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -12,16 +12,17 @@ class commandManager():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
environment['runtime']['commandManager'].loadCommands(environment,'commands') self.env = environment
environment['runtime']['commandManager'].loadCommands(environment,'onInput') self.env['runtime']['commandManager'].loadCommands('commands')
environment['runtime']['commandManager'].loadCommands(environment,'onScreenChanged') environment['runtime']['commandManager'].loadCommands('onInput')
environment['runtime']['commandManager'].loadCommands('onScreenChanged')
def shutdown(self, environment): def shutdown(self):
environment['runtime']['commandManager'].shutdownCommands(environment,'commands') self.env['runtime']['commandManager'].shutdownCommands('commands')
environment['runtime']['commandManager'].shutdownCommands(environment,'onInput') self.env['runtime']['commandManager'].shutdownCommands('onInput')
environment['runtime']['commandManager'].shutdownCommands(environment,'onScreenChanged') self.env['runtime']['commandManager'].shutdownCommands('onScreenChanged')
def loadCommands(self, environment, section='commands'): def loadCommands(self, section='commands'):
commandFolder = "commands/" + section +"/" commandFolder = "commands/" + section +"/"
commandList = glob.glob(commandFolder+'*') commandList = glob.glob(commandFolder+'*')
for command in commandList: for command in commandList:
@ -34,63 +35,63 @@ class commandManager():
spec = importlib.util.spec_from_file_location(fileName, command) spec = importlib.util.spec_from_file_location(fileName, command)
command_mod = importlib.util.module_from_spec(spec) command_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(command_mod) spec.loader.exec_module(command_mod)
environment['commands'][section][fileName.upper()] = command_mod.command() self.env['commands'][section][fileName.upper()] = command_mod.command()
environment['commands'][section][fileName.upper()].initialize(environment) self.env['commands'][section][fileName.upper()].initialize(self.env)
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Loading command:" + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Loading command:" + command ,debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue continue
def shutdownCommands(self, environment, section): def shutdownCommands(self, section):
for command in sorted(environment['commands'][section]): for command in sorted(self.env['commands'][section]):
try: try:
environment['commands'][section][command].shutdown(environment) self.env['commands'][section][command].shutdown()
del environment['commands'][section][command] del self.env['commands'][section][command]
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Shutdown command:" + section + "." + cmd ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Shutdown command:" + section + "." + command ,debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
continue continue
def executeTriggerCommands(self, environment, trigger): def executeTriggerCommands(self, trigger):
if environment['runtime']['screenManager'].isSuspendingScreen(environment): if self.env['runtime']['screenManager'].isSuspendingScreen():
return return
for command in sorted(environment['commands'][trigger]): for command in sorted(self.env['commands'][trigger]):
if self.commandExists(environment, command, trigger): if self.commandExists(command, trigger):
try: try:
environment['commands'][trigger][command].run(environment) self.env['commands'][trigger][command].run()
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Executing trigger:" + trigger + "." + cmd ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing trigger:" + trigger + "." + cmd ,debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
def executeCommand(self, environment, command, section = 'commands'): def executeCommand(self, command, section = 'commands'):
if environment['runtime']['screenManager'].isSuspendingScreen(environment) : if self.env['runtime']['screenManager'].isSuspendingScreen():
return return
if self.commandExists(environment, command, section): if self.commandExists(command, section):
try: try:
if environment['generalInformation']['tutorialMode']: if self.env['generalInformation']['tutorialMode']:
description = environment['commands'][section][command].getDescription(environment) description = self.env['commands'][section][command].getDescription()
environment['runtime']['outputManager'].presentText(environment, description, interrupt=True) self.env['runtime']['outputManager'].presentText(description, interrupt=True)
else: else:
environment['commands'][section][command].run(environment) self.env['commands'][section][command].run()
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Executing command:" + section + "." + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.clearCommandQueued(environment) self.clearCommandQueued()
environment['commandInfo']['lastCommandExecutionTime'] = time.time() self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
def isCommandQueued(self, environment): def isCommandQueued(self):
return environment['commandInfo']['currCommand'] != '' return self.env['commandInfo']['currCommand'] != ''
def clearCommandQueued(self, environment): def clearCommandQueued(self):
environment['commandInfo']['currCommand'] = '' self.env['commandInfo']['currCommand'] = ''
def queueCommand(self, environment, command): def queueCommand(self, command):
environment['commandInfo']['currCommand'] = command self.env['commandInfo']['currCommand'] = command
def commandExists(self, environment, command, section = 'commands'): def commandExists(self, command, section = 'commands'):
return( command.upper() in environment['commands'][section]) return( command.upper() in self.env['commands'][section])

View File

@ -19,10 +19,13 @@ class debug():
self._fileName = fileName self._fileName = fileName
self._file = None self._file = None
self._fileOpened = False self._fileOpened = False
def initialize(self, environment):
self.env = environment
def shutdown(self):
self.closeDebugFile()
def __del__(self): def __del__(self):
try: try:
self.closeDebugFile() self.shutdown()
except: except:
pass pass
@ -34,8 +37,8 @@ class debug():
self._file = open(self._fileName,'a') self._file = open(self._fileName,'a')
self._fileOpened = True self._fileOpened = True
def writeDebugOut(self, environment, text, level = debugLevel.DEACTIVE): def writeDebugOut(self, text, level = debugLevel.DEACTIVE):
if environment['runtime']['settingsManager'].getSettingAsInt(environment, 'general','debugLevel') < int(level): if self.env['runtime']['settingsManager'].getSettingAsInt('general','debugLevel') < int(level):
if self._fileOpened: if self._fileOpened:
self.closeDebugFile() self.closeDebugFile()
return return

View File

@ -12,61 +12,60 @@ class inputManager():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
environment['runtime']['settingsManager'].loadDriver(environment,\ self.env = environment
environment['runtime']['settingsManager'].getSetting(environment,'keyboard', 'driver'), 'inputDriver') self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('keyboard', 'driver'), 'inputDriver')
# init LEDs with current state # init LEDs with current state
environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment) self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getNumlock()
environment['input']['oldNumLock'] = environment['input']['newNumLock'] self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment) self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getCapslock()
environment['input']['oldCapsLock'] = environment['input']['newCapsLock'] self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment) self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getScrollLock()
environment['input']['oldScrollLock'] = environment['input']['newScrollLock'] self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
self.grabDevices(environment) self.grabDevices()
def shutdown(self, environment): def shutdown(self):
environment['runtime']['inputManager'].releaseDevices(environment) self.env['runtime']['inputManager'].releaseDevices()
if environment['runtime']['inputDriver']: self.env['runtime']['settingsManager'].shutdownDriver('inputDriver')
environment['runtime']['inputDriver'].shutdown(environment)
del environment['runtime']['inputDriver']
def getInputEvent(self, environment): def getInputEvent(self):
eventReceived = False eventReceived = False
mEvent = environment['runtime']['inputDriver'].getInputEvent(environment) mEvent = self.env['runtime']['inputDriver'].getInputEvent()
if mEvent: if mEvent:
mEvent['EventName'] = self.convertEventName(environment, mEvent['EventName']) mEvent['EventName'] = self.convertEventName(mEvent['EventName'])
if mEvent['EventValue'] == 0: if mEvent['EventValue'] == 0:
return False return False
eventReceived = True eventReceived = True
if mEvent['EventState'] == 0: if mEvent['EventState'] == 0:
if mEvent['EventName'] in environment['input']['currInput']: if mEvent['EventName'] in self.env['input']['currInput']:
environment['input']['currInput'].remove(mEvent['EventName']) self.env['input']['currInput'].remove(mEvent['EventName'])
environment['input']['currInput'] = sorted(environment['input']['currInput']) self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
elif mEvent['EventState'] == 1: elif mEvent['EventState'] == 1:
if not mEvent['EventName'] in environment['input']['currInput']: if not mEvent['EventName'] in self.env['input']['currInput']:
environment['input']['currInput'].append(mEvent['EventName']) self.env['input']['currInput'].append(mEvent['EventName'])
environment['input']['currInput'] = sorted(environment['input']['currInput']) self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
elif mEvent['EventState'] == 2: elif mEvent['EventState'] == 2:
pass pass
else: else:
pass pass
environment['input']['oldNumLock'] = environment['input']['newNumLock'] self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
environment['input']['newNumLock'] = environment['runtime']['inputDriver'].getNumlock(environment) self.env['input']['newNumLock'] = self.env['runtime']['inputDriver'].getNumlock()
environment['input']['oldCapsLock'] = environment['input']['newCapsLock'] self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
environment['input']['newCapsLock'] = environment['runtime']['inputDriver'].getCapslock(environment) self.env['input']['newCapsLock'] = self.env['runtime']['inputDriver'].getCapslock()
environment['input']['oldScrollLock'] = environment['input']['newScrollLock'] self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
environment['input']['newScrollLock'] = environment['runtime']['inputDriver'].getScrollLock(environment) self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getScrollLock()
environment['input']['lastInputTime'] = time.time() self.env['input']['lastInputTime'] = time.time()
environment['input']['shortcutRepeat'] = 1 self.env['input']['shortcutRepeat'] = 1
return eventReceived return eventReceived
def grabDevices(self, environment): def grabDevices(self):
if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices'): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
environment['runtime']['inputDriver'].grabDevices(environment) self.env['runtime']['inputDriver'].grabDevices()
def releaseDevices(self, environment): def releaseDevices(self):
environment['runtime']['inputDriver'].releaseDevices(environment) self.env['runtime']['inputDriver'].releaseDevices()
def convertEventName(self, environment, eventName): def convertEventName(self, eventName):
if not eventName: if not eventName:
return '' return ''
if eventName == 'KEY_LEFTCTRL': if eventName == 'KEY_LEFTCTRL':
@ -81,58 +80,59 @@ class inputManager():
eventName = 'KEY_ALT' eventName = 'KEY_ALT'
elif eventName == 'KEY_RIGHTALT': elif eventName == 'KEY_RIGHTALT':
eventName = 'KEY_ALT' eventName = 'KEY_ALT'
if self.isFenrirKey(environment, eventName): if self.isFenrirKey(eventName):
eventName = 'KEY_FENRIR' eventName = 'KEY_FENRIR'
return eventName return eventName
def isConsumeInput(self, environment): def isConsumeInput(self):
return environment['runtime']['commandManager'].isCommandQueued(environment) and \ return self.env['runtime']['commandManager'].isCommandQueued() and \
not environment['input']['keyForeward'] not self.env['input']['keyForeward']
#and #and
# not (environment['input']['keyForeward'] or \ # not (self.env['input']['keyForeward'] or \
# environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'grabDevices')) # self.env['runtime']['settingsManager'].getSettingAsBool(, 'keyboard', 'grabDevices'))
def clearEventBuffer(self, environment): def clearEventBuffer(self):
environment['runtime']['inputDriver'].clearEventBuffer(environment) self.env['runtime']['inputDriver'].clearEventBuffer()
def writeEventBuffer(self, environment): def writeEventBuffer(self):
try: try:
environment['runtime']['inputDriver'].writeEventBuffer(environment) self.env['runtime']['inputDriver'].writeEventBuffer()
except Exception as e: except Exception as e:
print(e) print(e)
environment['runtime']['debug'].writeDebugOut(environment,"Error while writeUInput",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Error while writeUInput",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment, str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
def isFenrirKeyPressed(self, environment): def isFenrirKeyPressed(self):
return 'KEY_FENRIR' in environment['input']['currInput'] return 'KEY_FENRIR' in self.env['input']['currInput']
def noKeyPressed(self, environment): def noKeyPressed(self):
return environment['input']['currInput'] == [] return self.env['input']['currInput'] == []
def getPrevDeepestInput(self, environment):
def getPrevDeepestInput(self):
shortcut = [] shortcut = []
shortcut.append(environment['input']['shortcutRepeat']) shortcut.append(self.env['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['prevDeepestInput'])) shortcut.append(sorted(self.env['input']['prevDeepestInput']))
def getPrevShortcut(self, environment): def getPrevShortcut(self):
shortcut = [] shortcut = []
shortcut.append(environment['input']['shortcutRepeat']) shortcut.append(self.env['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['prevInput'])) shortcut.append(sorted(self.env['input']['prevInput']))
return str(shortcut) return str(shortcut)
def getCurrShortcut(self, environment): def getCurrShortcut(self):
shortcut = [] shortcut = []
shortcut.append(environment['input']['shortcutRepeat']) shortcut.append(self.env['input']['shortcutRepeat'])
shortcut.append(sorted(environment['input']['currInput'])) shortcut.append(sorted(self.env['input']['currInput']))
return str(shortcut) return str(shortcut)
def isFenrirKey(self,environment, eventName): def isFenrirKey(self, eventName):
return eventName in environment['input']['fenrirKey'] return eventName in self.env['input']['fenrirKey']
def getCommandForShortcut(self, environment, shortcut): def getCommandForShortcut(self, shortcut):
shortcut = shortcut.upper() shortcut = shortcut.upper()
if not self.shortcutExists(environment, shortcut): if not self.shortcutExists(shortcut):
return '' return ''
return environment['bindings'][shortcut].upper() return self.env['bindings'][shortcut].upper()
def shortcutExists(self, environment, shortcut): def shortcutExists(self, shortcut):
return( str(shortcut).upper() in environment['bindings']) return( str(shortcut).upper() in self.env['bindings'])

View File

@ -10,104 +10,102 @@ class outputManager():
def __init__(self): def __init__(self):
pass pass
def initialize(self, environment): def initialize(self, environment):
environment['runtime']['settingsManager'].loadDriver(environment,\ self.env = environment
environment['runtime']['settingsManager'].getSetting(environment,'speech', 'driver'), 'speechDriver') self.env['runtime']['settingsManager'].loadDriver(\
environment['runtime']['settingsManager'].loadDriver(environment,\ self.env['runtime']['settingsManager'].getSetting('speech', 'driver'), 'speechDriver')
environment['runtime']['settingsManager'].getSetting(environment,'sound', 'driver'), 'soundDriver') self.env['runtime']['settingsManager'].loadDriver(\
self.env['runtime']['settingsManager'].getSetting('sound', 'driver'), 'soundDriver')
def shutdown(self, environment): def shutdown(self):
if environment['runtime']['soundDriver']: self.env['runtime']['settingsManager'].shutdownDriver('soundDriver')
environment['runtime']['soundDriver'].shutdown(environment) self.env['runtime']['settingsManager'].shutdownDriver('speechDriver')
del environment['runtime']['soundDriver']
if environment['runtime']['speechDriver']:
environment['runtime']['speechDriver'].shutdown(environment)
del environment['runtime']['speechDriver']
def presentText(self, environment, text, interrupt=True, soundIcon = ''): def presentText(self, text, interrupt=True, soundIcon = ''):
environment['runtime']['debug'].writeDebugOut(environment,"presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("presentText:\nsoundIcon:'"+soundIcon+"'\nText:\n" + text ,debug.debugLevel.INFO)
if self.playSoundIcon(environment, soundIcon, interrupt): if self.playSoundIcon(soundIcon, interrupt):
environment['runtime']['debug'].writeDebugOut(environment,"soundIcon found" ,debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("soundIcon found" ,debug.debugLevel.INFO)
return return
self.speakText(environment, text, interrupt) self.speakText(text, interrupt)
self.brailleText(environment, text, interrupt) self.brailleText(text, interrupt)
def speakText(self, environment, text, interrupt=True): def speakText(self, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): if not self.env['runtime']['settingsManager'].getSettingAsBool('speech', 'enabled'):
environment['runtime']['debug'].writeDebugOut(environment,"Speech disabled in outputManager.speakText",debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Speech disabled in outputManager.speakText",debug.debugLevel.INFO)
return return
if environment['runtime']['speechDriver'] == None: if self.env['runtime']['speechDriver'] == None:
environment['runtime']['debug'].writeDebugOut(environment,"No speechDriver in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("No speechDriver in outputManager.speakText",debug.debugLevel.ERROR)
return return
if interrupt: if interrupt:
self.interruptOutput(environment) self.interruptOutput()
try: try:
environment['runtime']['speechDriver'].setLanguage(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'language')) self.env['runtime']['speechDriver'].setLanguage(self.env['runtime']['settingsManager'].getSetting('speech', 'language'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"setting speech language in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("setting speech language in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].setVoice(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'voice')) self.env['runtime']['speechDriver'].setVoice(self.env['runtime']['settingsManager'].getSetting('speech', 'voice'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"Error while setting speech voice in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("Error while setting speech voice in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].setPitch(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'pitch')) self.env['runtime']['speechDriver'].setPitch(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'pitch'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"setting speech pitch in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("setting speech pitch in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].setRate(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'rate')) self.env['runtime']['speechDriver'].setRate(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'rate'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"setting speech rate in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("setting speech rate in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].setModule(environment['runtime']['settingsManager'].getSetting(environment, 'speech', 'module')) self.env['runtime']['speechDriver'].setModule(self.env['runtime']['settingsManager'].getSetting('speech', 'module'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"setting speech module in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("setting speech module in outputManager.speakText",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'speech', 'volume')) self.env['runtime']['speechDriver'].setVolume(self.env['runtime']['settingsManager'].getSettingAsFloat('speech', 'volume'))
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"setting speech volume in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("setting speech volume in outputManager.speakText ",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
try: try:
environment['runtime']['speechDriver'].speak(text) self.env['runtime']['speechDriver'].speak(text)
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("\"speak\" in outputManager.speakText ",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
def brailleText(self, environment, text, interrupt=True): def brailleText(self, text, interrupt=True):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): if not self.env['runtime']['settingsManager'].getSettingAsBool('braille', 'enabled'):
return return
if environment['runtime']['brailleDriver'] == None: if self.env['runtime']['brailleDriver'] == None:
return return
print('braille:'+text) print('braille:'+text)
def interruptOutput(self, environment):
environment['runtime']['speechDriver'].cancel()
environment['runtime']['soundDriver'].cancel()
def playSoundIcon(self, environment, soundIcon = '', interrupt=True): def interruptOutput(self):
self.env['runtime']['speechDriver'].cancel()
self.env['runtime']['soundDriver'].cancel()
def playSoundIcon(self, soundIcon = '', interrupt=True):
if soundIcon == '': if soundIcon == '':
return False return False
soundIcon = soundIcon.upper() soundIcon = soundIcon.upper()
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): if not self.env['runtime']['settingsManager'].getSettingAsBool('sound', 'enabled'):
environment['runtime']['debug'].writeDebugOut(environment,"Sound disabled in outputManager.speakText",debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut("Sound disabled in outputManager.speakText",debug.debugLevel.INFO)
return False return False
if environment['runtime']['soundDriver'] == None: if self.env['runtime']['soundDriver'] == None:
environment['runtime']['debug'].writeDebugOut(environment,"No speechDriver in outputManager.speakText",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("No speechDriver in outputManager.speakText",debug.debugLevel.ERROR)
return False return False
try: try:
environment['runtime']['soundDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'sound', 'volume')) self.env['runtime']['soundDriver'].setVolume(self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume'))
environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIcon], interrupt) self.env['runtime']['soundDriver'].playSoundFile(self.env['soundIcons'][soundIcon], interrupt)
return True return True
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,"\"playSoundIcon\" in outputManager.speakText ",debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut("\"playSoundIcon\" in outputManager.speakText ",debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return False return False

View File

@ -12,23 +12,22 @@ class screenManager():
self.autoIgnoreScreens = [] self.autoIgnoreScreens = []
def initialize(self, environment): def initialize(self, environment):
environment['runtime']['settingsManager'].loadDriver(environment,\ self.env = environment
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'driver'), 'screenDriver') self.env['runtime']['settingsManager'].loadDriver(\
if environment['runtime']['settingsManager'].getSettingAsBool(environment,'screen', 'autodetectSuspendingScreen'): self.env['runtime']['settingsManager'].getSetting('screen', 'driver'), 'screenDriver')
self.autoIgnoreScreens = environment['runtime']['screenDriver'].getIgnoreScreens() if self.env['runtime']['settingsManager'].getSettingAsBool('screen', 'autodetectSuspendingScreen'):
self.autoIgnoreScreens = self.env['runtime']['screenDriver'].getIgnoreScreens()
def shutdown(self, environment): def shutdown(self):
if environment['runtime']['screenDriver']: self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
environment['runtime']['screenDriver'].shutdown(environment)
del environment['runtime']['screenDriver']
def update(self, environment): def update(self):
if not self.isSuspendingScreen(environment): if not self.isSuspendingScreen():
environment['runtime']['screenDriver'].update(environment) self.env['runtime']['screenDriver'].update()
environment['screenData']['lastScreenUpdate'] = time.time() self.env['screenData']['lastScreenUpdate'] = time.time()
def isSuspendingScreen(self, environment): def isSuspendingScreen(self):
currScreen = environment['runtime']['screenDriver'].getCurrScreen() currScreen = self.env['runtime']['screenDriver'].getCurrScreen()
return ((currScreen in \ return ((currScreen in \
environment['runtime']['settingsManager'].getSetting(environment,'screen', 'suspendingScreen').split(',')) or self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
(currScreen in self.autoIgnoreScreens)) (currScreen in self.autoIgnoreScreens))

View File

@ -19,10 +19,10 @@ class settingsManager():
def __init__(self): def __init__(self):
self.settings = settings self.settings = settings
def initialize(self, environment): def initialize(self, environment):
self.env = environment
def shutdown(self):
pass pass
def shutdown(self, environment): def loadShortcuts(self, kbConfigPath='../../config/keyboard/desktop.conf'):
pass
def loadShortcuts(self, environment, kbConfigPath='../../config/keyboard/desktop.conf'):
kbConfig = open(kbConfigPath,"r") kbConfig = open(kbConfigPath,"r")
while(True): while(True):
line = kbConfig.readline() line = kbConfig.readline()
@ -50,10 +50,10 @@ class settingsManager():
shortcut.append(shortcutRepeat) shortcut.append(shortcutRepeat)
shortcut.append(sorted(shortcutKeys)) shortcut.append(sorted(shortcutKeys))
print(str(shortcut), commandName) print(str(shortcut), commandName)
environment['bindings'][str(shortcut)] = commandName self.env['bindings'][str(shortcut)] = commandName
kbConfig.close() kbConfig.close()
def loadSoundIcons(self, environment, soundIconPath): def loadSoundIcons(self, soundIconPath):
siConfig = open(soundIconPath + '/soundicons.conf',"r") siConfig = open(soundIconPath + '/soundicons.conf',"r")
while(True): while(True):
line = siConfig.readline() line = siConfig.readline()
@ -76,67 +76,73 @@ class settingsManager():
soundIconPath += '/' soundIconPath += '/'
if os.path.exists(soundIconPath + Values[1]): if os.path.exists(soundIconPath + Values[1]):
soundIconFile = soundIconPath + Values[1] soundIconFile = soundIconPath + Values[1]
environment['soundIcons'][soundIcon] = soundIconFile self.env['soundIcons'][soundIcon] = soundIconFile
siConfig.close() siConfig.close()
def loadSettings(self, environment, settingConfigPath): def loadSettings(self, settingConfigPath):
if not os.path.exists(settingConfigPath): if not os.path.exists(settingConfigPath):
return False return False
environment['settings'] = ConfigParser() self.env['settings'] = ConfigParser()
environment['settings'].read(settingConfigPath) self.env['settings'].read(settingConfigPath)
return True return True
def setSetting(self, environment, section, setting, value): def setSetting(self, section, setting, value):
environment['settings'].set(section, setting, value) self.env['settings'].set(section, setting, value)
def getSetting(self, environment, section, setting): def getSetting(self, section, setting):
value = '' value = ''
try: try:
value = environment['settings'].get(section, setting) value = self.env['settings'].get(section, setting)
except: except:
value = str(self.settings[section][setting]) value = str(self.settings[section][setting])
return value return value
def getSettingAsInt(self, environment, section, setting): def getSettingAsInt(self, section, setting):
value = 0 value = 0
try: try:
value = environment['settings'].getint(section, setting) value = self.env['settings'].getint(section, setting)
except: except:
value = self.settings[section][setting] value = self.settings[section][setting]
return value return value
def getSettingAsFloat(self, environment, section, setting): def getSettingAsFloat(self, section, setting):
value = 0.0 value = 0.0
try: try:
value = environment['settings'].getfloat(section, setting) value = self.env['settings'].getfloat(section, setting)
except: except:
value = self.settings[section][setting] value = self.settings[section][setting]
return value return value
def getSettingAsBool(self, environment, section, setting): def getSettingAsBool(self, section, setting):
value = False value = False
try: try:
value = environment['settings'].getboolean(section, setting) value = self.env['settings'].getboolean(section, setting)
except: except:
value = self.settings[section][setting] value = self.settings[section][setting]
return value return value
def loadDriver(self, environment, driverName, driverType): def loadDriver(self, driverName, driverType):
if environment['runtime'][driverType] != None: if self.env['runtime'][driverType] != None:
print('shutdown %s',driverType) print('shutdown %s',driverType)
environment['runtime'][driverType].shutdown(environment) self.env['runtime'][driverType].shutdown(self.env)
spec = importlib.util.spec_from_file_location(driverName, driverType + '/' + driverName + '.py') spec = importlib.util.spec_from_file_location(driverName, driverType + '/' + driverName + '.py')
driver_mod = importlib.util.module_from_spec(spec) driver_mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(driver_mod) spec.loader.exec_module(driver_mod)
environment['runtime'][driverType] = driver_mod.driver() self.env['runtime'][driverType] = driver_mod.driver()
environment['runtime'][driverType].initialize(environment) self.env['runtime'][driverType].initialize(self.env)
def setFenrirKeys(self, environment, keys): def shutdownDriver(self, driverType):
if self.env['runtime'][driverType] == None:
return
self.env['runtime'][driverType].shutdown()
del self.env['runtime'][driverType]
def setFenrirKeys(self, keys):
keys = keys.upper() keys = keys.upper()
keyList = keys.split(',') keyList = keys.split(',')
for key in keyList: for key in keyList:
if not key in environment['input']['fenrirKey']: if not key in self.env['input']['fenrirKey']:
environment['input']['fenrirKey'].append(key) self.env['input']['fenrirKey'].append(key)
def keyIDasString(self, key): def keyIDasString(self, key):
try: try:
@ -147,34 +153,37 @@ class settingsManager():
def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf'): def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf'):
environment['runtime']['debug'] = debug.debug() environment['runtime']['debug'] = debug.debug()
environment['runtime']['debug'].initialize(environment)
if not os.path.exists(settingsRoot): if not os.path.exists(settingsRoot):
if os.path.exists('../../config/'): if os.path.exists('../../config/'):
settingsRoot = '../../config/' settingsRoot = '../../config/'
else: else:
return None return None
environment['runtime']['settingsManager'] = self environment['runtime']['settingsManager'] = self
validConfig = environment['runtime']['settingsManager'].loadSettings(environment, settingsRoot + '/settings/' + settingsFile) environment['runtime']['settingsManager'].initialize(environment)
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsRoot + '/settings/' + settingsFile)
if not validConfig: if not validConfig:
return None return None
self.setFenrirKeys(environment, self.getSetting(environment, 'general','fenrirKeys')) self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
if not os.path.exists(self.getSetting(environment, 'keyboard','keyboardLayout')): if not os.path.exists(self.getSetting('keyboard','keyboardLayout')):
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')):
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout')) self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout'))
environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting('keyboard','keyboardLayout')) environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf'): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf'):
self.setSetting(environment, 'keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting(environment, 'keyboard','keyboardLayout') + '.conf') self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf')
environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
else: else:
environment['runtime']['settingsManager'].loadShortcuts(environment, self.getSetting(environment, 'keyboard','keyboardLayout')) environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
if not os.path.exists(self.getSetting(environment, 'sound','theme') + '/soundicons.conf'): if not os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme')): if os.path.exists(settingsRoot + 'sound/'+ self.getSetting('sound','theme')):
self.setSetting(environment, 'sound', 'theme', settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme')) self.setSetting('sound', 'theme', settingsRoot + 'sound/'+ self.getSetting('sound','theme'))
if os.path.exists(settingsRoot + 'sound/'+ self.getSetting(environment, 'sound','theme') + '/soundicons.conf'): if os.path.exists(settingsRoot + 'sound/'+ self.getSetting('sound','theme') + '/soundicons.conf'):
environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))
else: else:
environment['runtime']['settingsManager'].loadSoundIcons(environment, self.getSetting(environment, 'sound','theme')) environment['runtime']['settingsManager'].loadSoundIcons(self.getSetting('sound','theme'))
environment['runtime']['inputManager'] = inputManager.inputManager() environment['runtime']['inputManager'] = inputManager.inputManager()
environment['runtime']['inputManager'].initialize(environment) environment['runtime']['inputManager'].initialize(environment)
@ -182,15 +191,15 @@ class settingsManager():
environment['runtime']['outputManager'].initialize(environment) environment['runtime']['outputManager'].initialize(environment)
environment['runtime']['commandManager'] = commandManager.commandManager() environment['runtime']['commandManager'] = commandManager.commandManager()
environment['runtime']['commandManager'].initialize(environment) environment['runtime']['commandManager'].initialize(environment)
if environment['runtime']['screenManager'] == None: if environment['runtime']['screenManager'] == None:
environment['runtime']['screenManager'] = screenManager.screenManager() environment['runtime']['screenManager'] = screenManager.screenManager()
environment['runtime']['screenManager'].initialize(environment) environment['runtime']['screenManager'].initialize(environment)
environment['runtime']['debug'].writeDebugOut(environment,'\/-------environment-------\/',debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut('\/-------environment-------\/',debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(environment),debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut(str(environment),debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,'\/-------settings.conf-------\/',debug.debugLevel.ERROR) environment['runtime']['debug'].writeDebugOut('\/-------settings.conf-------\/',debug.debugLevel.ERROR)
environment['runtime']['debug'].writeDebugOut(environment,str(environment['settings']._sections environment['runtime']['debug'].writeDebugOut(str(environment['settings']._sections
),debug.debugLevel.ERROR) ),debug.debugLevel.ERROR)
return environment return environment

View File

@ -20,7 +20,7 @@ class fenrir():
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable') raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
except RuntimeError: except RuntimeError:
raise raise
self.environment['runtime']['outputManager'].presentText(self.environment, "Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True) self.environment['runtime']['outputManager'].presentText("Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
signal.signal(signal.SIGINT, self.captureSignal) signal.signal(signal.SIGINT, self.captureSignal)
signal.signal(signal.SIGTERM, self.captureSignal) signal.signal(signal.SIGTERM, self.captureSignal)
@ -30,44 +30,44 @@ class fenrir():
self.handleProcess() self.handleProcess()
except Exception as e: except Exception as e:
print(e) print(e)
self.environment['runtime']['debug'].writeDebugOut(self.environment,str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.shutdown() self.shutdown()
def handleProcess(self): def handleProcess(self):
eventReceived = self.environment['runtime']['inputManager'].getInputEvent(self.environment) eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
if eventReceived: if eventReceived:
self.prepareCommand() self.prepareCommand()
if not (self.environment['runtime']['inputManager'].isConsumeInput(self.environment) or \ if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
self.environment['runtime']['inputManager'].isFenrirKeyPressed(self.environment)) and \ self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
not self.environment['runtime']['commandManager'].isCommandQueued(self.environment): not self.environment['runtime']['commandManager'].isCommandQueued():
self.environment['runtime']['inputManager'].writeEventBuffer(self.environment) self.environment['runtime']['inputManager'].writeEventBuffer()
elif self.environment['runtime']['inputManager'].noKeyPressed(self.environment): elif self.environment['runtime']['inputManager'].noKeyPressed():
self.environment['runtime']['inputManager'].clearEventBuffer(self.environment) self.environment['runtime']['inputManager'].clearEventBuffer()
try: try:
self.environment['runtime']['screenManager'].update(self.environment) self.environment['runtime']['screenManager'].update()
except Exception as e: except Exception as e:
print(e) print(e)
self.environment['runtime']['debug'].writeDebugOut(self.environment, str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput') self.environment['runtime']['commandManager'].executeTriggerCommands('onInput')
self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged') self.environment['runtime']['commandManager'].executeTriggerCommands('onScreenChanged')
self.handleCommands() self.handleCommands()
def prepareCommand(self): def prepareCommand(self):
if self.environment['input']['keyForeward']: if self.environment['input']['keyForeward']:
return return
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut(self.environment) shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
command = self.environment['runtime']['inputManager'].getCommandForShortcut(self.environment, shortcut) command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
self.environment['runtime']['commandManager'].queueCommand(self.environment, command) self.environment['runtime']['commandManager'].queueCommand(command)
def handleCommands(self): def handleCommands(self):
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2: if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
return return
if not self.environment['runtime']['commandManager'].isCommandQueued(self.environment): if not self.environment['runtime']['commandManager'].isCommandQueued():
return return
self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands') self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands')
def shutdownRequest(self): def shutdownRequest(self):
self.environment['generalInformation']['running'] = False self.environment['generalInformation']['running'] = False
@ -77,23 +77,23 @@ class fenrir():
def shutdown(self): def shutdown(self):
if self.environment['runtime']['inputManager']: if self.environment['runtime']['inputManager']:
self.environment['runtime']['inputManager'].shutdown(self.environment) self.environment['runtime']['inputManager'].shutdown()
del self.environment['runtime']['inputManager'] del self.environment['runtime']['inputManager']
self.environment['runtime']['outputManager'].presentText(self.environment, "Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True) self.environment['runtime']['outputManager'].presentText("Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
time.sleep(.8) # wait a little for sound time.sleep(.8) # wait a little for sound
if self.environment['runtime']['screenManager']: if self.environment['runtime']['screenManager']:
self.environment['runtime']['screenManager'].shutdown(self.environment) self.environment['runtime']['screenManager'].shutdown()
del self.environment['runtime']['screenManager'] del self.environment['runtime']['screenManager']
if self.environment['runtime']['commandManager']: if self.environment['runtime']['commandManager']:
self.environment['runtime']['commandManager'].shutdown(self.environment) self.environment['runtime']['commandManager'].shutdown()
del self.environment['runtime']['commandManager'] del self.environment['runtime']['commandManager']
if self.environment['runtime']['outputManager']: if self.environment['runtime']['outputManager']:
self.environment['runtime']['outputManager'].shutdown(self.environment) self.environment['runtime']['outputManager'].shutdown()
del self.environment['runtime']['outputManager'] del self.environment['runtime']['outputManager']
if self.environment['runtime']['debug']: if self.environment['runtime']['debug']:
self.environment['runtime']['debug'].closeDebugFile() self.environment['runtime']['debug'].shutdown()
del self.environment['runtime']['debug'] del self.environment['runtime']['debug']
time.sleep(0.5) # wait a little before splatter it :) time.sleep(0.5) # wait a little before splatter it :)
self.environment = None self.environment = None

View File

@ -19,32 +19,34 @@ class driver():
self.ledDevices = {} self.ledDevices = {}
def initialize(self, environment): def initialize(self, environment):
self.getInputDevices(environment) self.env = environment
def shutdown(self, environment): self.getInputDevices()
def shutdown(self):
pass pass
def getInputEvent(self, environment): def getInputEvent(self):
event = None event = None
r, w, x = select(self.iDevices, [], [], environment['runtime']['settingsManager'].getSettingAsFloat(environment, 'screen', 'screenUpdateDelay')) r, w, x = select(self.iDevices, [], [], self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay'))
if r != []: if r != []:
for fd in r: for fd in r:
event = self.iDevices[fd].read_one() event = self.iDevices[fd].read_one()
environment['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event]) self.env['input']['eventBuffer'].append( [self.iDevices[fd], self.uDevices[fd], event])
return environment['runtime']['inputDriver'].mapEvent(environment, event) return self.env['runtime']['inputDriver'].mapEvent(event)
return None return None
def writeEventBuffer(self, environment): def writeEventBuffer(self):
for iDevice, uDevice, event in environment['input']['eventBuffer']: for iDevice, uDevice, event in self.env['input']['eventBuffer']:
self.writeUInput(environment, uDevice, event) self.writeUInput(uDevice, event)
self.clearEventBuffer(environment) self.clearEventBuffer()
def clearEventBuffer(self, environment): def clearEventBuffer(self):
del environment['input']['eventBuffer'][:] del self.env['input']['eventBuffer'][:]
def writeUInput(self, environment, uDevice, event): def writeUInput(self, uDevice, event):
uDevice.write_event(event) uDevice.write_event(event)
uDevice.syn() uDevice.syn()
def getInputDevices(self, environment): def getInputDevices(self):
# 3 pos absolute # 3 pos absolute
# 2 pos relative # 2 pos relative
# 17 LEDs # 17 LEDs
@ -55,7 +57,7 @@ class driver():
self.ledDevices = map(evdev.InputDevice, (evdev.list_devices())) self.ledDevices = map(evdev.InputDevice, (evdev.list_devices()))
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()} 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()}
def mapEvent(self,environment, event): def mapEvent(self, event):
if not event: if not event:
return None return None
mEvent = inputEvent.inputEvent mEvent = inputEvent.inputEvent
@ -70,7 +72,7 @@ class driver():
print(e) print(e)
return None return None
def getNumlock(self,environment): def getNumlock(self):
if self.ledDevices == {}: if self.ledDevices == {}:
return True return True
if self.ledDevices == None: if self.ledDevices == None:
@ -79,7 +81,7 @@ class driver():
return 0 in dev.leds() return 0 in dev.leds()
return True return True
def getCapslock(self,environment): def getCapslock(self):
if self.ledDevices == {}: if self.ledDevices == {}:
return False return False
if self.ledDevices == None: if self.ledDevices == None:
@ -88,7 +90,7 @@ class driver():
return 1 in dev.leds() return 1 in dev.leds()
return False return False
def getScrollLock(self,environment): def getScrollLock(self):
if self.ledDevices == {}: if self.ledDevices == {}:
return False return False
if self.ledDevices == None: if self.ledDevices == None:
@ -97,7 +99,7 @@ class driver():
return 2 in dev.leds() return 2 in dev.leds()
return False return False
def grabDevices(self, environment): def grabDevices(self):
for fd in self.iDevices: for fd in self.iDevices:
dev = self.iDevices[fd] dev = self.iDevices[fd]
cap = dev.capabilities() cap = dev.capabilities()
@ -113,7 +115,7 @@ class driver():
) )
dev.grab() dev.grab()
def releaseDevices(self, environment): def releaseDevices(self):
for fd in self.iDevices: for fd in self.iDevices:
try: try:
self.iDevices[fd].ungrab() self.iDevices[fd].ungrab()

View File

@ -12,8 +12,8 @@ class driver():
def __init__(self): def __init__(self):
self.vcsaDevicePath = '/dev/vcsa' self.vcsaDevicePath = '/dev/vcsa'
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def insert_newlines(self, string, every=64): def insert_newlines(self, string, every=64):
return '\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))
@ -25,7 +25,7 @@ class driver():
currScreen = currScreenFile.read()[3:-1] currScreen = currScreenFile.read()[3:-1]
currScreenFile.close() currScreenFile.close()
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return currScreen return currScreen
def getCurrApplication(self, screen): def getCurrApplication(self, screen):
@ -64,7 +64,7 @@ class driver():
return xlist return xlist
def update(self, environment, trigger='updateScreen'): def update(self, trigger='updateScreen'):
newTTY = '' newTTY = ''
newContentBytes = b'' newContentBytes = b''
try: try:
@ -76,66 +76,66 @@ class driver():
if len(newContentBytes) < 5: if len(newContentBytes) < 5:
return return
except Exception as e: except Exception as e:
environment['runtime']['debug'].writeDebugOut(environment,str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return return
screenEncoding = environment['runtime']['settingsManager'].getSetting(environment,'screen', 'encoding') screenEncoding = self.env['runtime']['settingsManager'].getSetting('screen', 'encoding')
# set new "old" values # set new "old" values
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes'] self.env['screenData']['oldContentBytes'] = self.env['screenData']['newContentBytes']
environment['screenData']['oldContentText'] = environment['screenData']['newContentText'] self.env['screenData']['oldContentText'] = self.env['screenData']['newContentText']
environment['screenData']['oldContentTextAttrib'] = environment['screenData']['newContentAttrib'] self.env['screenData']['oldContentTextAttrib'] = self.env['screenData']['newContentAttrib']
environment['screenData']['oldCursor']['x'] = environment['screenData']['newCursor']['x'] self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x']
environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y'] self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y']
if environment['screenData']['oldTTY'] == '-1': if self.env['screenData']['oldTTY'] == '-1':
environment['screenData']['oldTTY'] = newTTY # dont recognice starting fenrir as change self.env['screenData']['oldTTY'] = newTTY # dont recognice starting fenrir as change
else: else:
environment['screenData']['oldTTY'] = environment['screenData']['newTTY'] self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY']
environment['screenData']['oldDelta'] = environment['screenData']['newDelta'] self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta']
environment['screenData']['oldNegativeDelta'] = environment['screenData']['newNegativeDelta'] self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta']
environment['screenData']['oldApplication'] = environment['screenData']['newApplication'] self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication']
environment['screenData']['newTTY'] = newTTY self.env['screenData']['newTTY'] = newTTY
environment['screenData']['newContentBytes'] = newContentBytes self.env['screenData']['newContentBytes'] = newContentBytes
# get metadata like cursor or screensize # get metadata like cursor or screensize
environment['screenData']['lines'] = int( environment['screenData']['newContentBytes'][0]) self.env['screenData']['lines'] = int( self.env['screenData']['newContentBytes'][0])
environment['screenData']['columns'] = int( environment['screenData']['newContentBytes'][1]) self.env['screenData']['columns'] = int( self.env['screenData']['newContentBytes'][1])
environment['screenData']['newCursor']['x'] = int( environment['screenData']['newContentBytes'][2]) self.env['screenData']['newCursor']['x'] = int( self.env['screenData']['newContentBytes'][2])
environment['screenData']['newCursor']['y'] = int( environment['screenData']['newContentBytes'][3]) self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3])
environment['screenData']['newApplication'] = self.getCurrApplication(newTTY) self.env['screenData']['newApplication'] = self.getCurrApplication(newTTY)
# analyze content # analyze content
environment['screenData']['newContentText'] = environment['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
environment['screenData']['newContentAttrib'] = environment['screenData']['newContentBytes'][5:][::2] self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2]
environment['screenData']['newContentText'] = self.insert_newlines(environment['screenData']['newContentText'], environment['screenData']['columns']) self.env['screenData']['newContentText'] = self.insert_newlines(self.env['screenData']['newContentText'], self.env['screenData']['columns'])
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
environment['screenData']['oldContentBytes'] = b'' self.env['screenData']['oldContentBytes'] = b''
environment['screenData']['oldContentAttrib'] = b'' self.env['screenData']['oldContentAttrib'] = b''
environment['screenData']['oldContentText'] = '' self.env['screenData']['oldContentText'] = ''
environment['screenData']['oldCursor']['x'] = 0 self.env['screenData']['oldCursor']['x'] = 0
environment['screenData']['oldCursor']['y'] = 0 self.env['screenData']['oldCursor']['y'] = 0
environment['screenData']['oldDelta'] = '' self.env['screenData']['oldDelta'] = ''
environment['screenData']['oldNegativeDelta'] = '' self.env['screenData']['oldNegativeDelta'] = ''
environment['screenData']['oldApplication'] = '' self.env['screenData']['oldApplication'] = ''
# always clear current deltas # always clear current deltas
environment['screenData']['newNegativeDelta'] = '' self.env['screenData']['newNegativeDelta'] = ''
environment['screenData']['newDelta'] = '' self.env['screenData']['newDelta'] = ''
# changes on the screen # changes on the screen
if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ if (self.env['screenData']['oldContentText'] != self.env['screenData']['newContentText']) and \
(environment['screenData']['newContentText'] != '' ): (self.env['screenData']['newContentText'] != '' ):
if environment['screenData']['oldContentText'] == '' and\ if self.env['screenData']['oldContentText'] == '' and\
environment['screenData']['newContentText'] != '': self.env['screenData']['newContentText'] != '':
environment['screenData']['newDelta'] = environment['screenData']['newContentText'] self.env['screenData']['newDelta'] = self.env['screenData']['newContentText']
else: else:
diffStart = 0 diffStart = 0
if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ if self.env['screenData']['oldCursor']['x'] != self.env['screenData']['newCursor']['x'] and \
environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ self.env['screenData']['oldCursor']['y'] == self.env['screenData']['newCursor']['y'] and \
environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: self.env['screenData']['newContentText'][:self.env['screenData']['newCursor']['y']] == self.env['screenData']['oldContentText'][:self.env['screenData']['newCursor']['y']]:
diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] diffStart = self.env['screenData']['newCursor']['y'] * self.env['screenData']['columns'] + self.env['screenData']['newCursor']['y']
diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ diff = difflib.ndiff(self.env['screenData']['oldContentText'][diffStart:diffStart + self.env['screenData']['columns']],\
environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) self.env['screenData']['newContentText'][diffStart:diffStart + self.env['screenData']['columns']])
else: else:
diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ diff = difflib.ndiff( self.env['screenData']['oldContentText'][diffStart:].split('\n'),\
environment['screenData']['newContentText'][diffStart:].split('\n')) self.env['screenData']['newContentText'][diffStart:].split('\n'))
diffList = list(diff) diffList = list(diff)
environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) self.env['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('- ')) self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- '))

View File

@ -15,14 +15,15 @@ class driver():
self.soundFileCommand = '' self.soundFileCommand = ''
self.frequenceCommand = '' self.frequenceCommand = ''
def initialize(self, environment): def initialize(self, environment):
self.soundFileCommand = environment['runtime']['settingsManager'].getSetting(environment,'sound', 'genericPlayFileCommand') self.env = environment
self.frequenceCommand = environment['runtime']['settingsManager'].getSetting(environment,'sound', 'genericFrequencyCommand') self.soundFileCommand = self.env['runtime']['settingsManager'].getSetting('sound', 'genericPlayFileCommand')
self.frequenceCommand = self.env['runtime']['settingsManager'].getSetting('sound', 'genericFrequencyCommand')
if self.soundFileCommand == '': if self.soundFileCommand == '':
self.soundFileCommand = 'play -q -v fenrirVolume fenrirSoundFile' self.soundFileCommand = 'play -q -v fenrirVolume fenrirSoundFile'
if self.frequenceCommand == '': 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 return
def shutdown(self, environment): def shutdown(self):
self.cancel() self.cancel()
return return
def playFrequence(self, frequence, duration, adjustVolume): def playFrequence(self, frequence, duration, adjustVolume):

View File

@ -30,7 +30,7 @@ class driver:
return return
if not _gstreamerAvailable: if not _gstreamerAvailable:
return return
self.env = environment
self._player = Gst.ElementFactory.make('playbin', 'player') self._player = Gst.ElementFactory.make('playbin', 'player')
bus = self._player.get_bus() bus = self._player.get_bus()
bus.add_signal_watch() bus.add_signal_watch()
@ -49,7 +49,7 @@ class driver:
self._initialized = True self._initialized = True
return return
def shutdown(self, environment): def shutdown(self):
global _gstreamerAvailable global _gstreamerAvailable
if not _gstreamerAvailable: if not _gstreamerAvailable:
return return

View File

@ -18,8 +18,8 @@ class driver():
except: except:
self._initialized = False self._initialized = False
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
pass pass
def speak(self,text, queueable=True): def speak(self,text, queueable=True):

View File

@ -11,8 +11,9 @@ class driver():
def __init__(self ): def __init__(self ):
pass pass
def initialize(self, environment): def initialize(self, environment):
self._isInitialized = False self._isInitialized = False
def shutdown(self, environment): self.env = environment
def shutdown(self):
pass pass
def speak(self,text, queueable=True): def speak(self,text, queueable=True):

View File

@ -19,8 +19,8 @@ class driver():
except: except:
self._initialized = False self._initialized = False
def initialize(self, environment): def initialize(self, environment):
pass self.env = environment
def shutdown(self, environment): def shutdown(self):
if not self._isInitialized: if not self._isInitialized:
return return
self._isInitialized = False self._isInitialized = False