fix some stuff
This commit is contained in:
parent
2aa5957f6d
commit
c21ed8fceb
@ -4,8 +4,11 @@ class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']:
|
||||
if environment['screenData']['newCursor'] == environment['screenData']['oldCursor'] and\
|
||||
environment['screenData']['newDelta'] == environment['screenData']['oldDelta']:
|
||||
return environment
|
||||
environment['runtime']['outputManager'].interruptOutput(environment)
|
||||
print('10000-shut_up.py')
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -1,18 +0,0 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
return environment
|
||||
if environment['screenData']['newCursor'] != environment['screenData']['oldCursor']:
|
||||
print(environment['screenData']['newCursor'] != environment['screenData']['oldCursor'])
|
||||
return environment
|
||||
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta'] or \
|
||||
environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], Interrupt=False)
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -1,18 +0,0 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x'] or\
|
||||
environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']:
|
||||
return environment
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']].replace(" ","").replace("\n","").replace("\t","") == '':
|
||||
environment['runtime']['outputManager'].speakText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']][environment['screenData']['newCursor']['x']])
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -1,17 +0,0 @@
|
||||
#!/bin/python
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']:
|
||||
return environment
|
||||
if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].replace(" ","").replace("\n","").replace("\t","") == '':
|
||||
environment['runtime']['outputManager'].speakText(environment, "blank")
|
||||
else:
|
||||
environment['runtime']['outputManager'].speakText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']])
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
def shutdown(self):
|
||||
pass
|
@ -4,9 +4,10 @@ class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
def run(self, environment):
|
||||
if environment['screenData']['newDelta'] != environment['screenData']['oldDelta'] or \
|
||||
environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'])
|
||||
if environment['screenData']['newDelta'] == environment['screenData']['oldDelta'] and \
|
||||
environment['screenData']['newTTY'] == environment['screenData']['oldTTY']:
|
||||
return environment
|
||||
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'],len(environment['screenData']['newDelta']) == 1)
|
||||
return environment
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -11,10 +11,12 @@ class inputManager():
|
||||
#for dev in self.devices.values(): print(dev)
|
||||
|
||||
def getKeyPressed(self, environment):
|
||||
timeout = True
|
||||
try:
|
||||
r, w, x = select(self.devices, [], [])
|
||||
r, w, x = select(self.devices, [], [],0.5)
|
||||
environment['runtime']['globalLock'].acquire(True)
|
||||
if r != []:
|
||||
timeout = False
|
||||
for fd in r:
|
||||
for event in self.devices[fd].read():
|
||||
if event.type == evdev.ecodes.EV_KEY:
|
||||
@ -28,7 +30,7 @@ class inputManager():
|
||||
except:
|
||||
pass
|
||||
environment['input']['currShortcutString'] = self.getShortcutString(environment)
|
||||
return environment
|
||||
return environment, timeout
|
||||
|
||||
def getShortcutString(self, environment):
|
||||
if environment['input']['currShortcut'] == {}:
|
||||
|
@ -15,24 +15,25 @@ from core import settingsManager
|
||||
|
||||
class fenrir():
|
||||
def __init__(self):
|
||||
self.threadHandleInput = None
|
||||
self.threadonInput = Thread(target=self.onInput, args=())
|
||||
|
||||
self.environment = settingsManager.settingsManager().initFenrirConfig()
|
||||
signal.signal(signal.SIGINT, self.captureSignal)
|
||||
|
||||
def proceed(self):
|
||||
self.threadHandleInput = Thread(target=self.handleInput, args=())
|
||||
self.threadHandleInput.start()
|
||||
self.threadonInput.start()
|
||||
while(self.environment['generalInformation']['running']):
|
||||
self.updateScreen()
|
||||
self.shutdown()
|
||||
|
||||
def handleInput(self):
|
||||
def onInput(self):
|
||||
while(self.environment['generalInformation']['running']):
|
||||
self.environment = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
||||
self.environment, timeout = self.environment['runtime']['inputManager'].getKeyPressed(self.environment)
|
||||
self.environment = self.environment['runtime']['commandManager'].getCommandForShortcut(self.environment)
|
||||
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment, 'onInput')
|
||||
if not timeout:
|
||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onInput')
|
||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||
if self.environment['commandInfo']['currCommand'] != '':
|
||||
self.environment['input']['currShortcut'] = {}
|
||||
self.environment['input']['currShortcutString'] = ''
|
||||
@ -40,6 +41,7 @@ class fenrir():
|
||||
self.environment['runtime']['globalLock'].release()
|
||||
|
||||
def updateScreen(self):
|
||||
return
|
||||
self.environment['runtime']['globalLock'].acquire(True)
|
||||
self.environment = self.environment['runtime']['screenDriver'].analyzeScreen(self.environment,'updateScreen')
|
||||
self.environment = self.environment['runtime']['commandManager'].executeTriggerCommands(self.environment, 'onScreenChanged')
|
||||
@ -48,7 +50,7 @@ class fenrir():
|
||||
|
||||
def handleCommands(self):
|
||||
if (self.environment['commandInfo']['currCommand'] != '') and \
|
||||
(time.time() - self.environment['commandInfo']['lastCommandTime'] >= 0.02):
|
||||
(time.time() - self.environment['commandInfo']['lastCommandTime'] >= 0.01):
|
||||
self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
|
||||
|
||||
def shutdown(self):
|
||||
|
@ -13,15 +13,6 @@ class screen():
|
||||
self.textWrapper = textwrap.TextWrapper()
|
||||
self.textWrapper.drop_whitespace = False
|
||||
def analyzeScreen(self, environment, trigger='updateScreen'):
|
||||
# set new "old" values
|
||||
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
|
||||
environment['screenData']['oldContentText'] = environment['screenData']['newContentText']
|
||||
environment['screenData']['oldContentTextAttrib'] = environment['screenData']['newContentAttrib']
|
||||
environment['screenData']['oldCursor']['x'] = environment['screenData']['newCursor']['x']
|
||||
environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y']
|
||||
environment['screenData']['oldTTY'] = environment['screenData']['newTTY']
|
||||
environment['screenData']['oldDelta'] = environment['screenData']['newDelta']
|
||||
newTTY = environment['screenData']['newTTY']
|
||||
# read screen
|
||||
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
|
||||
newTTY = currTTY.read()[3:-1]
|
||||
@ -35,11 +26,20 @@ class screen():
|
||||
return environment
|
||||
except:
|
||||
return environment
|
||||
if trigger != 'onInput': # so we already moved the cursor and is not input -> screenchanges was faster
|
||||
if trigger != 'onInput' and False: # so we already moved the cursor and is not input -> screenUpdate was faster
|
||||
if ((newContentBytes[2] != environment['screenData']['oldCursor']['x']) or\
|
||||
(newContentBytes[3] != environment['screenData']['oldCursor']['y'])) and\
|
||||
(newTTY == environment['screenData']['oldTTY']):
|
||||
return environment
|
||||
# set new "old" values
|
||||
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
|
||||
environment['screenData']['oldContentText'] = environment['screenData']['newContentText']
|
||||
environment['screenData']['oldContentTextAttrib'] = environment['screenData']['newContentAttrib']
|
||||
environment['screenData']['oldCursor']['x'] = environment['screenData']['newCursor']['x']
|
||||
environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y']
|
||||
environment['screenData']['oldTTY'] = environment['screenData']['newTTY']
|
||||
environment['screenData']['oldDelta'] = environment['screenData']['newDelta']
|
||||
|
||||
environment['screenData']['newTTY'] = newTTY
|
||||
environment['screenData']['newContentBytes'] = newContentBytes
|
||||
# get metadata like cursor or screensize
|
||||
@ -47,12 +47,9 @@ class screen():
|
||||
environment['screenData']['columns'] = int( environment['screenData']['newContentBytes'][1])
|
||||
environment['screenData']['newCursor']['x'] = int( environment['screenData']['newContentBytes'][2])
|
||||
environment['screenData']['newCursor']['y'] = int( environment['screenData']['newContentBytes'][3])
|
||||
|
||||
# analyze content
|
||||
environment['screenData']['newContentText'] = str(environment['screenData']['newContentBytes'][4:][::2].decode('WINDOWS-1250'))
|
||||
environment['screenData']['newContentText'] = str(environment['screenData']['newContentBytes'][4:][::2].decode("ascii", "replace"))
|
||||
environment['screenData']['newContentAttrib'] = environment['screenData']['newContentBytes'][5:][::2]
|
||||
if environment['screenData']['newContentText'].count('\n') != 0:
|
||||
environment['screenData']['newContentText'] = environment['screenData']['newContentText'].replace('\n',"")
|
||||
environment['screenData']['newContentText'] = '\n'.join(self.textWrapper.wrap(environment['screenData']['newContentText'], ))[:-2]
|
||||
|
||||
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
||||
|
Loading…
Reference in New Issue
Block a user