first transport of text using the eventloop

This commit is contained in:
chrys 2018-03-12 21:29:34 +01:00
parent 56ea61f5fb
commit 66be5935cf
3 changed files with 35 additions and 33 deletions

View File

@ -80,7 +80,6 @@ class fenrirManager():
self.singleKeyCommand = False self.singleKeyCommand = False
if self.environment['input']['keyForeward'] > 0: if self.environment['input']['keyForeward'] > 0:
self.environment['input']['keyForeward'] -=1 self.environment['input']['keyForeward'] -=1
self.environment['runtime']['screenManager'].update('onInput')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
#print('handleInput:',time.time() - startTime) #print('handleInput:',time.time() - startTime)
def handleExecuteCommand(self, event): def handleExecuteCommand(self, event):
@ -93,8 +92,8 @@ class fenrirManager():
self.environment['runtime']['commandManager'].executeCommand( command, 'help') self.environment['runtime']['commandManager'].executeCommand( command, 'help')
return return
self.environment['runtime']['commandManager'].executeCommand( command, 'commands') self.environment['runtime']['commandManager'].executeCommand( command, 'commands')
def handleScreenChange(self, event): def handleScreenChange(self, event):
self.environment['runtime']['screenManager'].update('onScreenChange') self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data'])
''' '''
if self.environment['runtime']['applicationManager'].isApplicationChange(): if self.environment['runtime']['applicationManager'].isApplicationChange():
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
@ -103,10 +102,10 @@ class fenrirManager():
self.environment['runtime']['applicationManager'].getCurrentApplication()) self.environment['runtime']['applicationManager'].getCurrentApplication())
''' '''
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged') self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
self.environment['runtime']['screenManager'].update('onScreenChange') self.environment['runtime']['screenDriver'].getCurrScreen()
def handleScreenUpdate(self, event): def handleScreenUpdate(self, event):
#startTime = time.time() #startTime = time.time()
self.environment['runtime']['screenManager'].update('onUpdate') self.environment['runtime']['screenManager'].handleScreenUpdate(event['Data'])
''' '''
if self.environment['runtime']['applicationManager'].isApplicationChange(): if self.environment['runtime']['applicationManager'].isApplicationChange():
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
@ -120,7 +119,7 @@ class fenrirManager():
# has cursor changed? # has cursor changed?
if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \ if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \
self.environment['runtime']['cursorManager'].isCursorHorizontalMove(): self.environment['runtime']['cursorManager'].isCursorHorizontalMove():
self.environment['runtime']['commandManager'].executeDefaultTrigger('onCursorChange') self.environment['runtime']['commandManager'].executeDefaultTrigger('onCursorChange')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate') self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
self.environment['runtime']['inputManager'].clearLastDeepInput() self.environment['runtime']['inputManager'].clearLastDeepInput()
#print('handleScreenUpdate:',time.time() - startTime) #print('handleScreenUpdate:',time.time() - startTime)

View File

@ -19,18 +19,18 @@ class screenManager():
def shutdown(self): def shutdown(self):
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
def hanldeScreenChange(self, eventData):
def update(self, trigger='onUpdate'): self.env['runtime']['screenDriver'].getCurrScreen()
self.env['runtime']['screenDriver'].getCurrScreen() self.env['runtime']['screenDriver'].getSessionInformation()
if trigger == 'onScreenChange':
self.env['runtime']['screenDriver'].getSessionInformation()
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
if self.isScreenChange(): if self.isScreenChange():
self.changeBrailleScreen() self.changeBrailleScreen()
if not self.isSuspendingScreen(self.env['screen']['newTTY']): if not self.isSuspendingScreen(self.env['screen']['newTTY']):
self.env['runtime']['screenDriver'].update(trigger) self.env['runtime']['screenDriver'].update(eventData, 'onScreenChange')
self.env['screen']['lastScreenUpdate'] = time.time()
def handleScreenUpdate(self, eventData):
self.env['screen']['oldApplication'] = self.env['screen']['newApplication']
if not self.isSuspendingScreen(self.env['screen']['newTTY']):
self.env['runtime']['screenDriver'].update(eventData, 'onScreenUpdate')
#if trigger == 'onUpdate' or self.isScreenChange() \ #if trigger == 'onUpdate' or self.isScreenChange() \
# or len(self.env['screen']['newDelta']) > 6: # or len(self.env['screen']['newDelta']) > 6:
# self.env['runtime']['screenDriver'].getCurrApplication() # self.env['runtime']['screenDriver'].getCurrApplication()

View File

@ -116,6 +116,21 @@ class driver(screenDriver):
#self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO) #self.env['runtime']['debug'].writeDebugOut('getSessionInformation:' + str(self.env['screen']['autoIgnoreScreens']) + ' ' + str(self.env['general']) ,debug.debugLevel.INFO)
def updateWatchdog(self,active , eventQueue): def updateWatchdog(self,active , eventQueue):
screenData = {
'columns': 0,
'lines': 0,
'delta': '',
'negativeDelta': '',
'attribDelta': '',
'cursorAttrib':None,
'cursor':{'x':0,'y':0},
'Bytes': b'',
'Text': '',
'Attributes': None,
'Scren':'0',
'Application': '',
'screenUpdateTime': time.time(),
}
try: try:
vcsa = {} vcsa = {}
vcsaDevices = glob.glob('/dev/vcsa*') vcsaDevices = glob.glob('/dev/vcsa*')
@ -148,12 +163,12 @@ class driver(screenDriver):
except: except:
pass pass
oldScreen = currScreen oldScreen = currScreen
eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''})
try: try:
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
lastScreenContent = vcsa[currScreen].read() lastScreenContent = vcsa[currScreen].read()
except: except:
pass pass
eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":lastScreenContent})
else: else:
self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO)
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
@ -167,7 +182,7 @@ class driver(screenDriver):
time.sleep(0.008) time.sleep(0.008)
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
dirtyContent = vcsa[currScreen].read() dirtyContent = vcsa[currScreen].read()
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None}) eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":screenContent})
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR)
@ -272,20 +287,8 @@ class driver(screenDriver):
return _('Default') return _('Default')
def getFenrirFontSize(self, attribute): def getFenrirFontSize(self, attribute):
return _('Default') return _('Default')
def update(self, trigger='onUpdate'): def update(self, text, trigger='onUpdate'):
if trigger == 'onInput': # no need for an update on input for VCSA newContentBytes = text
return
newContentBytes = b''
try:
# read screen
vcsa = open(self.vcsaDevicePath + self.env['screen']['newTTY'],'rb',0)
newContentBytes = vcsa.read()
vcsa.close()
if len(newContentBytes) < 5:
return
except Exception as e:
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return
# set new "old" values # set new "old" values
self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes'] self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes']
self.env['screen']['oldContentText'] = self.env['screen']['newContentText'] self.env['screen']['oldContentText'] = self.env['screen']['newContentText']