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]
keyboardLayout=desktop
charEcho=False
charEcho=True
wordEcho=True
[general]

View File

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

View File

@ -21,9 +21,9 @@ class fenrir():
signal.signal(signal.SIGINT, self.captureSignal)
def proceed(self):
self.threadonInput.start()
while(self.environment['generalInformation']['running']):
self.updateScreen()
#self.threadonInput.start()
#while(self.environment['generalInformation']['running']):
self.onInput()
self.shutdown()
def onInput(self):
@ -49,8 +49,8 @@ class fenrir():
time.sleep(0.5)
def handleCommands(self):
if (self.environment['commandInfo']['currCommand'] != '') and \
(time.time() - self.environment['commandInfo']['lastCommandTime'] >= 0.01):
if (self.environment['commandInfo']['currCommand'] != ''):# and \
# (time.time() - self.environment['commandInfo']['lastCommandTime'] >= 0.01):
self.environment = self.environment['runtime']['commandManager'].executeCommand(self.environment, self.environment['commandInfo']['currCommand'], 'commands')
def shutdown(self):

View File

@ -4,7 +4,6 @@
import difflib
import textwrap
import time
import re
#import fenrir.utils.debug
class screen():
@ -13,12 +12,13 @@ class screen():
self.textWrapper = textwrap.TextWrapper()
self.textWrapper.drop_whitespace = False
def analyzeScreen(self, environment, trigger='updateScreen'):
# read screen
currTTY = open('/sys/devices/virtual/tty/tty0/active','r')
newTTY = currTTY.read()[3:-1]
currTTY.close()
newTTY = ''
newContentBytes = b''
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)
newContentBytes = vcsa.read()
vcsa.close()
@ -26,11 +26,7 @@ class screen():
return environment
except:
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
environment['screenData']['oldContentBytes'] = environment['screenData']['newContentBytes']
environment['screenData']['oldContentText'] = environment['screenData']['newContentText']