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