more cleanup
This commit is contained in:
parent
fb7ea791f0
commit
b50e4fde73
@ -17,7 +17,7 @@ class command():
|
|||||||
return 'sends the following keypress to the terminal'
|
return 'sends the following keypress to the terminal'
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.env['input']['keyForeward'] = True
|
self.env['input']['keyForeward'] = 2
|
||||||
self.env['runtime']['outputManager'].presentText('Foreward next keypress', interrupt=True)
|
self.env['runtime']['outputManager'].presentText('Foreward next keypress', interrupt=True)
|
||||||
|
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
|
@ -9,13 +9,11 @@ import time
|
|||||||
|
|
||||||
input = {
|
input = {
|
||||||
'currInput': [],
|
'currInput': [],
|
||||||
'prevInput': [],
|
|
||||||
'prevDeepestInput': [],
|
'prevDeepestInput': [],
|
||||||
'currEvent': None,
|
|
||||||
'eventBuffer': [],
|
'eventBuffer': [],
|
||||||
'shortcutRepeat': 0,
|
'shortcutRepeat': 0,
|
||||||
'fenrirKey': ['KEY_FENRIR'],
|
'fenrirKey': ['KEY_KP0'],
|
||||||
'keyForeward': False,
|
'keyForeward': 0,
|
||||||
'lastInputTime':time.time(),
|
'lastInputTime':time.time(),
|
||||||
'oldNumLock': True,
|
'oldNumLock': True,
|
||||||
'newNumLock':True,
|
'newNumLock':True,
|
||||||
|
@ -24,7 +24,7 @@ class fenrir():
|
|||||||
signal.signal(signal.SIGINT, self.captureSignal)
|
signal.signal(signal.SIGINT, self.captureSignal)
|
||||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||||
self.wasCommand = False
|
self.wasCommand = False
|
||||||
self.currShortcutLenght = 0
|
|
||||||
def proceed(self):
|
def proceed(self):
|
||||||
while(self.environment['generalInformation']['running']):
|
while(self.environment['generalInformation']['running']):
|
||||||
try:
|
try:
|
||||||
@ -42,18 +42,17 @@ class fenrir():
|
|||||||
#if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
#if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
||||||
# self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
# self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
||||||
# not self.environment['runtime']['commandManager'].isCommandQueued():
|
# not self.environment['runtime']['commandManager'].isCommandQueued():
|
||||||
print('vor',self.wasCommand,self.currShortcutLenght)
|
|
||||||
if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed()):
|
if not (self.wasCommand or self.environment['runtime']['inputManager'].isFenrirKeyPressed()):
|
||||||
print('dri')
|
|
||||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
if self.wasCommand:
|
if self.wasCommand:
|
||||||
print('mache falsch')
|
print('mache falsch')
|
||||||
self.wasCommand = False
|
self.wasCommand = False
|
||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
self.currShortcutLenght = 0
|
self.environment['input']['prevDeepestInput'] = []
|
||||||
self.environment['runtime']['screenManager'].update()
|
self.environment['runtime']['screenManager'].update()
|
||||||
print('nach',self.wasCommand,self.currShortcutLenght)
|
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||||
else:
|
else:
|
||||||
self.environment['runtime']['screenManager'].update()
|
self.environment['runtime']['screenManager'].update()
|
||||||
@ -78,9 +77,10 @@ class fenrir():
|
|||||||
print(shortcut)
|
print(shortcut)
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
||||||
self.environment['runtime']['commandManager'].queueCommand(command)
|
self.environment['runtime']['commandManager'].queueCommand(command)
|
||||||
if self.currShortcutLenght < len(self.environment['input']['currInput']):
|
if len(self.environment['input']['prevDeepestInput']) < len(self.environment['input']['currInput']):
|
||||||
self.wasCommand = command != ''
|
self.wasCommand = command != ''
|
||||||
self.currShortcutLenght = len(self.environment['input']['currInput'])
|
self.environment['input']['prevDeepestInput'] = self.environment['input']['currInput'].copy()
|
||||||
|
|
||||||
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
|
||||||
@ -99,7 +99,7 @@ class fenrir():
|
|||||||
self.environment['runtime']['inputManager'].shutdown()
|
self.environment['runtime']['inputManager'].shutdown()
|
||||||
del self.environment['runtime']['inputManager']
|
del self.environment['runtime']['inputManager']
|
||||||
self.environment['runtime']['outputManager'].presentText("Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
|
self.environment['runtime']['outputManager'].presentText("Quit Fenrir", soundIcon='ScreenReaderOff', interrupt=True)
|
||||||
time.sleep(.3) # wait a little for sound
|
time.sleep(0.9) # wait a little for sound
|
||||||
|
|
||||||
if self.environment['runtime']['screenManager']:
|
if self.environment['runtime']['screenManager']:
|
||||||
self.environment['runtime']['screenManager'].shutdown()
|
self.environment['runtime']['screenManager'].shutdown()
|
||||||
@ -123,7 +123,7 @@ class fenrir():
|
|||||||
if self.environment['runtime']['debug']:
|
if self.environment['runtime']['debug']:
|
||||||
self.environment['runtime']['debug'].shutdown()
|
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.2) # wait a little before splatter it :)
|
||||||
self.environment = None
|
self.environment = None
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user