speed up fenrir
This commit is contained in:
		@@ -17,11 +17,13 @@ class command():
 | 
			
		||||
        return ''               
 | 
			
		||||
    
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return        
 | 
			
		||||
        if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'interruptOnKeyPress'):
 | 
			
		||||
            return 
 | 
			
		||||
        if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
 | 
			
		||||
            return               
 | 
			
		||||
 | 
			
		||||
        print(self.environment['input']['currInput'])
 | 
			
		||||
        self.env['runtime']['outputManager'].interruptOutput()
 | 
			
		||||
 | 
			
		||||
    def setCallback(self, callback):
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ class command():
 | 
			
		||||
        return ''           
 | 
			
		||||
    
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
        if not self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return   
 | 
			
		||||
        if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
 | 
			
		||||
            return            
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,6 @@ class command():
 | 
			
		||||
        return 'No Description found'
 | 
			
		||||
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return        
 | 
			
		||||
        if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
 | 
			
		||||
            return
 | 
			
		||||
        # detect deletion or chilling 
 | 
			
		||||
@@ -18,8 +18,6 @@ class command():
 | 
			
		||||
        return 'No Description found'     
 | 
			
		||||
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return     
 | 
			
		||||
        if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
@@ -30,8 +30,6 @@ class command():
 | 
			
		||||
        self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')      
 | 
			
		||||
      
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return     
 | 
			
		||||
        if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +69,7 @@ class command():
 | 
			
		||||
 | 
			
		||||
        if currWord != '':
 | 
			
		||||
            if not self.spellChecker.check(currWord):
 | 
			
		||||
                self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=True)
 | 
			
		||||
                self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=False)
 | 
			
		||||
 | 
			
		||||
    def setCallback(self, callback):
 | 
			
		||||
        pass
 | 
			
		||||
@@ -17,8 +17,6 @@ class command():
 | 
			
		||||
        return 'No Description found'        
 | 
			
		||||
 | 
			
		||||
    def run(self):
 | 
			
		||||
        if self.env['runtime']['inputManager'].noKeyPressed():
 | 
			
		||||
            return     
 | 
			
		||||
        if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
 | 
			
		||||
            return
 | 
			
		||||
   
 | 
			
		||||
@@ -21,26 +21,29 @@ class screenManager():
 | 
			
		||||
    def shutdown(self):
 | 
			
		||||
        self.env['runtime']['settingsManager'].shutdownDriver('screenDriver')
 | 
			
		||||
 | 
			
		||||
    def update(self):
 | 
			
		||||
    def update(self, trigger = 'onUpdate'):
 | 
			
		||||
        self.env['screenData']['newTTY'] = self.env['runtime']['screenDriver'].getCurrScreen()    
 | 
			
		||||
        if trigger == 'onUpdate':
 | 
			
		||||
            self.env['runtime']['applicationManager'].getCurrentApplication()
 | 
			
		||||
        if not self.isSuspendingScreen():
 | 
			
		||||
            self.env['runtime']['screenDriver'].update()
 | 
			
		||||
            self.env['runtime']['screenDriver'].update(trigger)
 | 
			
		||||
            self.env['screenData']['lastScreenUpdate'] = time.time()
 | 
			
		||||
 | 
			
		||||
    def isSuspendingScreen(self):
 | 
			
		||||
        currScreen = self.env['runtime']['screenDriver'].getCurrScreen()
 | 
			
		||||
        return ((currScreen in \
 | 
			
		||||
        return ((self.env['screenData']['newTTY'] in \
 | 
			
		||||
          self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
 | 
			
		||||
          (currScreen in self.autoIgnoreScreens))
 | 
			
		||||
          (self.env['screenData']['newTTY'] in self.autoIgnoreScreens))
 | 
			
		||||
    
 | 
			
		||||
    def isScreenChange(self):
 | 
			
		||||
        return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']
 | 
			
		||||
    
 | 
			
		||||
    def getWindowAreaInText(self, text):
 | 
			
		||||
        if not self.env['runtime']['cursorManager'].isApplicationWindowSet():
 | 
			
		||||
            return text
 | 
			
		||||
        currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
 | 
			
		||||
        windowText = ''
 | 
			
		||||
        windowList = text.split('\n')
 | 
			
		||||
        windowList = windowList[self.env['commandBuffer']['windowArea'][currApp]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1]
 | 
			
		||||
        windowList = windowList[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['y']:self.env['commandBuffer']['windowArea'][currApp]['2']['y'] + 1]
 | 
			
		||||
        for line in windowList:
 | 
			
		||||
            windowText += line[self.env['commandBuffer']['windowArea'][currApp]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n'
 | 
			
		||||
            windowText += line[self.env['commandBuffer']['windowArea'][self.env['screenData']['newApplication']]['1']['x']:self.env['commandBuffer']['windowArea'][currApp]['2']['x'] + 1] + '\n'
 | 
			
		||||
        return windowText
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -51,11 +51,11 @@ class fenrir():
 | 
			
		||||
                if self.environment['input']['keyForeward'] > 0:
 | 
			
		||||
                    self.environment['input']['keyForeward'] -=1
 | 
			
		||||
            else:
 | 
			
		||||
                self.environment['runtime']['screenManager'].update()                            
 | 
			
		||||
                self.environment['runtime']['screenManager'].update('onInput')                            
 | 
			
		||||
            self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')                
 | 
			
		||||
 | 
			
		||||
        else:
 | 
			
		||||
            self.environment['runtime']['screenManager'].update()
 | 
			
		||||
            self.environment['runtime']['screenManager'].update('onUpdate')
 | 
			
		||||
        if self.environment['runtime']['applicationManager'].isApplicationChange():
 | 
			
		||||
            self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
 | 
			
		||||
            self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ class driver():
 | 
			
		||||
        return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
 | 
			
		||||
    
 | 
			
		||||
    def getCurrScreen(self):
 | 
			
		||||
        currScreen = -1
 | 
			
		||||
        currScreen = ''
 | 
			
		||||
        try:    
 | 
			
		||||
            currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r')
 | 
			
		||||
            currScreen = currScreenFile.read()[3:-1]
 | 
			
		||||
@@ -28,10 +28,10 @@ class driver():
 | 
			
		||||
            self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)   
 | 
			
		||||
        return currScreen
 | 
			
		||||
 | 
			
		||||
    def getCurrApplication(self, screen):
 | 
			
		||||
    def getCurrApplication(self):
 | 
			
		||||
        apps = []
 | 
			
		||||
        try:
 | 
			
		||||
            currScreen = str(screen)
 | 
			
		||||
            currScreen = str(self.env['screenData']['newTTY'])
 | 
			
		||||
            apps = subprocess.Popen('ps -t tty' + currScreen + ' -o comm,tty,stat', shell=True, stdout=subprocess.PIPE).stdout.read().decode()[:-1].split('\n')
 | 
			
		||||
        except Exception as e:
 | 
			
		||||
            print(e)
 | 
			
		||||
@@ -49,7 +49,10 @@ class driver():
 | 
			
		||||
                          not "SH" == i[0] and \
 | 
			
		||||
                          not "PS" == i[0]:
 | 
			
		||||
                            if "TTY"+currScreen in i[1]:
 | 
			
		||||
                                return i[0]
 | 
			
		||||
                                if self.env['runtime']['applicationManager'].isApplicationChange():
 | 
			
		||||
                                    self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication']
 | 
			
		||||
                                    self.env['screenData']['newApplication'] = i[0]                                 
 | 
			
		||||
                                return
 | 
			
		||||
        except:
 | 
			
		||||
            return ''
 | 
			
		||||
        return ''
 | 
			
		||||
@@ -74,7 +77,6 @@ class driver():
 | 
			
		||||
        newContentBytes = b''       
 | 
			
		||||
        try:
 | 
			
		||||
            # read screen
 | 
			
		||||
            newTTY = self.getCurrScreen()
 | 
			
		||||
            vcsa = open(self.vcsaDevicePath + newTTY,'rb',0)
 | 
			
		||||
            newContentBytes = vcsa.read()
 | 
			
		||||
            vcsa.close()
 | 
			
		||||
@@ -91,20 +93,17 @@ class driver():
 | 
			
		||||
        self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x']
 | 
			
		||||
        self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y']
 | 
			
		||||
        if self.env['screenData']['oldTTY'] == '-1':
 | 
			
		||||
            self.env['screenData']['oldTTY'] = newTTY # dont recognice starting fenrir as change
 | 
			
		||||
            self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY']
 | 
			
		||||
        else:    
 | 
			
		||||
            self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY']
 | 
			
		||||
        self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta']
 | 
			
		||||
        self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta']
 | 
			
		||||
        self.env['screenData']['oldApplication'] = self.env['screenData']['newApplication'] 
 | 
			
		||||
        self.env['screenData']['newTTY'] = newTTY
 | 
			
		||||
        self.env['screenData']['newContentBytes'] = newContentBytes
 | 
			
		||||
        # get metadata like cursor or screensize
 | 
			
		||||
        self.env['screenData']['lines'] = int( self.env['screenData']['newContentBytes'][0])
 | 
			
		||||
        self.env['screenData']['columns'] = int( self.env['screenData']['newContentBytes'][1])
 | 
			
		||||
        self.env['screenData']['newCursor']['x'] = int( self.env['screenData']['newContentBytes'][2])
 | 
			
		||||
        self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3])
 | 
			
		||||
        self.env['screenData']['newApplication'] = self.getCurrApplication(newTTY)
 | 
			
		||||
        # analyze content
 | 
			
		||||
        self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8')
 | 
			
		||||
        self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user