From 66be5935cfe7bcaa2a776af5ff7ee014125dd756 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 12 Mar 2018 21:29:34 +0100 Subject: [PATCH] first transport of text using the eventloop --- src/fenrir/core/fenrirManager.py | 11 ++++---- src/fenrir/core/screenManager.py | 20 +++++++-------- src/fenrir/screenDriver/vcsaDriver.py | 37 +++++++++++++++------------ 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index 31c2439e..92afa4f2 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -80,7 +80,6 @@ class fenrirManager(): self.singleKeyCommand = False if self.environment['input']['keyForeward'] > 0: self.environment['input']['keyForeward'] -=1 - self.environment['runtime']['screenManager'].update('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') #print('handleInput:',time.time() - startTime) def handleExecuteCommand(self, event): @@ -93,8 +92,8 @@ class fenrirManager(): self.environment['runtime']['commandManager'].executeCommand( command, 'help') return self.environment['runtime']['commandManager'].executeCommand( command, 'commands') - def handleScreenChange(self, event): - self.environment['runtime']['screenManager'].update('onScreenChange') + def handleScreenChange(self, event): + self.environment['runtime']['screenManager'].hanldeScreenChange(event['Data']) ''' if self.environment['runtime']['applicationManager'].isApplicationChange(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') @@ -103,10 +102,10 @@ class fenrirManager(): self.environment['runtime']['applicationManager'].getCurrentApplication()) ''' self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged') - self.environment['runtime']['screenManager'].update('onScreenChange') + self.environment['runtime']['screenDriver'].getCurrScreen() def handleScreenUpdate(self, event): #startTime = time.time() - self.environment['runtime']['screenManager'].update('onUpdate') + self.environment['runtime']['screenManager'].handleScreenUpdate(event['Data']) ''' if self.environment['runtime']['applicationManager'].isApplicationChange(): self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') @@ -120,7 +119,7 @@ class fenrirManager(): # has cursor changed? if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \ 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']['inputManager'].clearLastDeepInput() #print('handleScreenUpdate:',time.time() - startTime) diff --git a/src/fenrir/core/screenManager.py b/src/fenrir/core/screenManager.py index 29e45d67..e337d039 100644 --- a/src/fenrir/core/screenManager.py +++ b/src/fenrir/core/screenManager.py @@ -19,18 +19,18 @@ class screenManager(): def shutdown(self): self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') - - def update(self, trigger='onUpdate'): - self.env['runtime']['screenDriver'].getCurrScreen() - - if trigger == 'onScreenChange': - self.env['runtime']['screenDriver'].getSessionInformation() - - self.env['screen']['oldApplication'] = self.env['screen']['newApplication'] + def hanldeScreenChange(self, eventData): + self.env['runtime']['screenDriver'].getCurrScreen() + self.env['runtime']['screenDriver'].getSessionInformation() if self.isScreenChange(): - self.changeBrailleScreen() + self.changeBrailleScreen() 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() \ # or len(self.env['screen']['newDelta']) > 6: # self.env['runtime']['screenDriver'].getCurrApplication() diff --git a/src/fenrir/screenDriver/vcsaDriver.py b/src/fenrir/screenDriver/vcsaDriver.py index 93cad131..bf541b45 100644 --- a/src/fenrir/screenDriver/vcsaDriver.py +++ b/src/fenrir/screenDriver/vcsaDriver.py @@ -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) 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: vcsa = {} vcsaDevices = glob.glob('/dev/vcsa*') @@ -148,12 +163,12 @@ class driver(screenDriver): except: pass oldScreen = currScreen - eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":''}) try: vcsa[currScreen].seek(0) lastScreenContent = vcsa[currScreen].read() except: - pass + pass + eventQueue.put({"Type":fenrirEventType.ScreenChanged,"Data":lastScreenContent}) else: self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO) vcsa[currScreen].seek(0) @@ -167,7 +182,7 @@ class driver(screenDriver): time.sleep(0.008) vcsa[currScreen].seek(0) dirtyContent = vcsa[currScreen].read() - eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None}) + eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":screenContent}) except Exception as e: self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR) @@ -272,20 +287,8 @@ class driver(screenDriver): return _('Default') def getFenrirFontSize(self, attribute): return _('Default') - def update(self, trigger='onUpdate'): - if trigger == 'onInput': # no need for an update on input for VCSA - 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 + def update(self, text, trigger='onUpdate'): + newContentBytes = text # set new "old" values self.env['screen']['oldContentBytes'] = self.env['screen']['newContentBytes'] self.env['screen']['oldContentText'] = self.env['screen']['newContentText']