speed up fenrir

This commit is contained in:
chrys 2016-09-27 23:17:46 +02:00
parent b2f31fde39
commit 58e2c6812a
9 changed files with 27 additions and 31 deletions

View File

@ -17,11 +17,13 @@ class command():
return '' return ''
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'interruptOnKeyPress'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'interruptOnKeyPress'):
return return
if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return
print(self.environment['input']['currInput'])
self.env['runtime']['outputManager'].interruptOutput() self.env['runtime']['outputManager'].interruptOutput()
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -17,7 +17,7 @@ class command():
return '' return ''
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed(): if not self.env['runtime']['inputManager'].noKeyPressed():
return return
if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']: if self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']:
return return

View File

@ -17,8 +17,6 @@ class command():
return 'No Description found' return 'No Description found'
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
return return
# detect deletion or chilling # detect deletion or chilling

View File

@ -18,8 +18,6 @@ class command():
return 'No Description found' return 'No Description found'
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
return return

View File

@ -30,8 +30,6 @@ class command():
self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'): if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
return return
@ -71,7 +69,7 @@ class command():
if currWord != '': if currWord != '':
if not self.spellChecker.check(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): def setCallback(self, callback):
pass pass

View File

@ -17,8 +17,6 @@ class command():
return 'No Description found' return 'No Description found'
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'): if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
return return

View File

@ -21,26 +21,29 @@ class screenManager():
def shutdown(self): def shutdown(self):
self.env['runtime']['settingsManager'].shutdownDriver('screenDriver') 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(): if not self.isSuspendingScreen():
self.env['runtime']['screenDriver'].update() self.env['runtime']['screenDriver'].update(trigger)
self.env['screenData']['lastScreenUpdate'] = time.time() self.env['screenData']['lastScreenUpdate'] = time.time()
def isSuspendingScreen(self): def isSuspendingScreen(self):
currScreen = self.env['runtime']['screenDriver'].getCurrScreen() return ((self.env['screenData']['newTTY'] in \
return ((currScreen in \
self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or self.env['runtime']['settingsManager'].getSetting('screen', 'suspendingScreen').split(',')) or
(currScreen in self.autoIgnoreScreens)) (self.env['screenData']['newTTY'] in self.autoIgnoreScreens))
def isScreenChange(self): def isScreenChange(self):
return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY'] return self.env['screenData']['newTTY'] != self.env['screenData']['oldTTY']
def getWindowAreaInText(self, text): def getWindowAreaInText(self, text):
if not self.env['runtime']['cursorManager'].isApplicationWindowSet(): if not self.env['runtime']['cursorManager'].isApplicationWindowSet():
return text return text
currApp = self.env['runtime']['applicationManager'].getCurrentApplication()
windowText = '' windowText = ''
windowList = text.split('\n') 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: 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 return windowText

View File

@ -51,11 +51,11 @@ class fenrir():
if self.environment['input']['keyForeward'] > 0: if self.environment['input']['keyForeward'] > 0:
self.environment['input']['keyForeward'] -=1 self.environment['input']['keyForeward'] -=1
else: else:
self.environment['runtime']['screenManager'].update() self.environment['runtime']['screenManager'].update('onInput')
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
else: else:
self.environment['runtime']['screenManager'].update() self.environment['runtime']['screenManager'].update('onUpdate')
if self.environment['runtime']['applicationManager'].isApplicationChange(): if self.environment['runtime']['applicationManager'].isApplicationChange():
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange') self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \ self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \

View File

@ -19,7 +19,7 @@ class driver():
return '\n'.join(string[i:i+every] for i in range(0, len(string), every)) return '\n'.join(string[i:i+every] for i in range(0, len(string), every))
def getCurrScreen(self): def getCurrScreen(self):
currScreen = -1 currScreen = ''
try: try:
currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r') currScreenFile = open('/sys/devices/virtual/tty/tty0/active','r')
currScreen = currScreenFile.read()[3:-1] currScreen = currScreenFile.read()[3:-1]
@ -28,10 +28,10 @@ class driver():
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
return currScreen return currScreen
def getCurrApplication(self, screen): def getCurrApplication(self):
apps = [] apps = []
try: 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') 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: except Exception as e:
print(e) print(e)
@ -49,7 +49,10 @@ class driver():
not "SH" == i[0] and \ not "SH" == i[0] and \
not "PS" == i[0]: not "PS" == i[0]:
if "TTY"+currScreen in i[1]: 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: except:
return '' return ''
return '' return ''
@ -74,7 +77,6 @@ class driver():
newContentBytes = b'' newContentBytes = b''
try: try:
# read screen # read screen
newTTY = self.getCurrScreen()
vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) vcsa = open(self.vcsaDevicePath + newTTY,'rb',0)
newContentBytes = vcsa.read() newContentBytes = vcsa.read()
vcsa.close() vcsa.close()
@ -91,20 +93,17 @@ class driver():
self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x'] self.env['screenData']['oldCursor']['x'] = self.env['screenData']['newCursor']['x']
self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y'] self.env['screenData']['oldCursor']['y'] = self.env['screenData']['newCursor']['y']
if self.env['screenData']['oldTTY'] == '-1': 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: else:
self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY'] self.env['screenData']['oldTTY'] = self.env['screenData']['newTTY']
self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta'] self.env['screenData']['oldDelta'] = self.env['screenData']['newDelta']
self.env['screenData']['oldNegativeDelta'] = self.env['screenData']['newNegativeDelta'] 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 self.env['screenData']['newContentBytes'] = newContentBytes
# get metadata like cursor or screensize # get metadata like cursor or screensize
self.env['screenData']['lines'] = int( self.env['screenData']['newContentBytes'][0]) self.env['screenData']['lines'] = int( self.env['screenData']['newContentBytes'][0])
self.env['screenData']['columns'] = int( self.env['screenData']['newContentBytes'][1]) 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']['x'] = int( self.env['screenData']['newContentBytes'][2])
self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3]) self.env['screenData']['newCursor']['y'] = int( self.env['screenData']['newContentBytes'][3])
self.env['screenData']['newApplication'] = self.getCurrApplication(newTTY)
# analyze content # analyze content
self.env['screenData']['newContentText'] = self.env['screenData']['newContentBytes'][4:][::2].decode(screenEncoding, "replace").encode('utf-8').decode('utf-8') 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] self.env['screenData']['newContentAttrib'] = self.env['screenData']['newContentBytes'][5:][::2]