interrupt on tty change

This commit is contained in:
chrys 2016-07-18 19:42:49 +02:00
parent 0788db5a8c
commit 79166454c1
4 changed files with 17 additions and 21 deletions

View File

@ -23,7 +23,7 @@ driver=linux
[keyboard] [keyboard]
keyboardLayout=desktop keyboardLayout=desktop
charEcho=False charEcho=True
wordEcho=True wordEcho=True
[general] [general]

View File

@ -5,13 +5,13 @@ class command():
pass pass
def run(self, environment): def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho') and\ if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'keyboard', 'charEcho') and\
#len(environment['screenData']['newDelta']) <= 2 and \ environment['screenData']['newCursor'] - environment['screenData']['oldCursor'] ==1:
environment['screenData']['newCursor'] != environment['screenData']['oldCursor']:
return environment return environment
ttyChanged = environment['screenData']['newTTY'] != environment['screenData']['oldTTY']
if environment['screenData']['newDelta'] == environment['screenData']['oldDelta'] and \ if environment['screenData']['newDelta'] == environment['screenData']['oldDelta'] and \
environment['screenData']['newTTY'] == environment['screenData']['oldTTY']: not ttyChanged:
return environment return environment
environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'],False) environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], ttyChanged)
return environment return environment
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -21,9 +21,9 @@ class fenrir():
signal.signal(signal.SIGINT, self.captureSignal) signal.signal(signal.SIGINT, self.captureSignal)
def proceed(self): def proceed(self):
self.threadonInput.start() #self.threadonInput.start()
while(self.environment['generalInformation']['running']): #while(self.environment['generalInformation']['running']):
self.updateScreen() self.onInput()
self.shutdown() self.shutdown()
def onInput(self): def onInput(self):
@ -49,8 +49,8 @@ class fenrir():
time.sleep(0.5) time.sleep(0.5)
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.01): # (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):

View File

@ -4,7 +4,6 @@
import difflib import difflib
import textwrap import textwrap
import time import time
import re
#import fenrir.utils.debug #import fenrir.utils.debug
class screen(): class screen():
@ -13,12 +12,13 @@ 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'):
# read screen newTTY = ''
currTTY = open('/sys/devices/virtual/tty/tty0/active','r') newContentBytes = b''
newTTY = currTTY.read()[3:-1]
currTTY.close()
newContentBytes = b''
try: try:
# read screen
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
newTTY = currTTY.read()[3:-1]
currTTY.close()
vcsa = open(self.vcsaDevicePath + newTTY,'rb',0) vcsa = open(self.vcsaDevicePath + newTTY,'rb',0)
newContentBytes = vcsa.read() newContentBytes = vcsa.read()
vcsa.close() vcsa.close()
@ -26,11 +26,7 @@ class screen():
return environment return environment
except: except:
return environment return environment
if trigger != 'onInput' and False: # so we already moved the cursor and is not input -> screenUpdate was faster
if ((newContentBytes[2] != environment['screenData']['newCursor']['x']) or\
(newContentBytes[3] != environment['screenData']['newCursor']['y'])) and\
(newTTY == environment['screenData']['newTTY']):
return environment
# set new "old" values # set new "old" values
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes'] environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
environment['screenData']['oldContentText'] = environment['screenData']['newContentText'] environment['screenData']['oldContentText'] = environment['screenData']['newContentText']