merge with 1.5

This commit is contained in:
chrys 2017-08-25 21:50:29 +02:00
commit c59ce60a27
5 changed files with 59 additions and 31 deletions

View File

@ -17,17 +17,13 @@ class command():
return '' return ''
def run(self): def run(self):
if self.env['runtime']['inputManager'].noKeyPressed():
return
if self.env['screen']['newAttribDelta'] != '': if self.env['screen']['newAttribDelta'] != '':
return return
if self.env['runtime']['screenManager'].isScreenChange(): if self.env['runtime']['screenManager'].isScreenChange():
return return
if self.env['runtime']['cursorManager'].isCursorVerticalMove(): if self.env['runtime']['cursorManager'].isCursorVerticalMove():
return return
if len(self.env['input']['currInput']) != 1: if not (self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_UP'],['KEY_DOWN']]):
return
if not self.env['input']['currInput'][0] in ['KEY_UP','KEY_DOWN']:
return return
prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']] prevLine = self.env['screen']['oldContentText'].split('\n')[self.env['screen']['newCursor']['y']]
currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] currLine = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]

View File

@ -51,6 +51,8 @@ class fenrirManager():
def handleInput(self, event): def handleInput(self, event):
#startTime = time.time() #startTime = time.time()
eventReceived = self.environment['runtime']['inputManager'].getInputEvent() eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
if self.environment['runtime']['inputManager'].noKeyPressed():
self.environment['runtime']['inputManager'].clearLastDeepInput()
if eventReceived: if eventReceived:
if self.environment['runtime']['screenManager'].isSuspendingScreen(): if self.environment['runtime']['screenManager'].isSuspendingScreen():
@ -106,11 +108,15 @@ class fenrirManager():
self.environment['runtime']['applicationManager'].getPrevApplication(), \ self.environment['runtime']['applicationManager'].getPrevApplication(), \
self.environment['runtime']['applicationManager'].getCurrentApplication()) self.environment['runtime']['applicationManager'].getCurrentApplication())
''' '''
# timout for the last keypress
if time.time() - self.environment['runtime']['inputManager'].getLastInputTime() >= 0.3:
self.environment['runtime']['inputManager'].clearLastDeepInput()
# has cursor changed? # has cursor changed?
if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \ if self.environment['runtime']['cursorManager'].isCursorVerticalMove() or \
self.environment['runtime']['cursorManager'].isCursorHorizontalMove(): 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']['commandManager'].executeDefaultTrigger('onScreenUpdate')
self.environment['runtime']['inputManager'].clearLastDeepInput()
#print('handleScreenUpdate:',time.time() - startTime) #print('handleScreenUpdate:',time.time() - startTime)
def handlePlugInputDevice(self, event): def handlePlugInputDevice(self, event):
@ -128,7 +134,7 @@ class fenrirManager():
else: else:
if not self.environment['runtime']['inputManager'].noKeyPressed(): if not self.environment['runtime']['inputManager'].noKeyPressed():
if self.singleKeyCommand: if self.singleKeyCommand:
self.singleKeyCommand = len(self.environment['input']['prevDeepestInput']) == 1 self.singleKeyCommand = len( self.environment['runtime']['inputManager'].getLastDeepestInput() ) == 1
# key is already released. we need the old one # key is already released. we need the old one
if not( self.singleKeyCommand and self.environment['runtime']['inputManager'].noKeyPressed()): if not( self.singleKeyCommand and self.environment['runtime']['inputManager'].noKeyPressed()):
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut() shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()

View File

@ -22,7 +22,8 @@ class inputManager():
self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock'] self.env['input']['oldCapsLock'] = self.env['input']['newCapsLock']
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2) self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2)
self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock'] self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
self.lastDeepestInput = []
self.lastInputTime = time.time()
def shutdown(self): def shutdown(self):
self.removeAllDevices() self.removeAllDevices()
self.env['runtime']['settingsManager'].shutdownDriver('inputDriver') self.env['runtime']['settingsManager'].shutdownDriver('inputDriver')
@ -40,26 +41,25 @@ class inputManager():
if len(self.env['input']['currInput']) > 1: if len(self.env['input']['currInput']) > 1:
self.env['input']['currInput'] = sorted(self.env['input']['currInput']) self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
elif len(self.env['input']['currInput']) == 0: elif len(self.env['input']['currInput']) == 0:
self.env['input']['prevDeepestInput'] = []
self.env['input']['shortcutRepeat'] = 1 self.env['input']['shortcutRepeat'] = 1
self.setLedState = self.handleLedStates(mEvent) self.setLedState = self.handleLedStates(mEvent)
self.env['input']['lastInputTime'] = time.time() self.lastInputTime = time.time()
elif mEvent['EventState'] == 1: elif mEvent['EventState'] == 1:
if not mEvent['EventName'] in self.env['input']['currInput']: if not mEvent['EventName'] in self.env['input']['currInput']:
self.env['input']['currInput'].append(mEvent['EventName']) self.env['input']['currInput'].append(mEvent['EventName'])
if len(self.env['input']['currInput']) > 1: if len(self.env['input']['currInput']) > 1:
self.env['input']['currInput'] = sorted(self.env['input']['currInput']) self.env['input']['currInput'] = sorted(self.env['input']['currInput'])
if len(self.env['input']['prevDeepestInput']) < len(self.env['input']['currInput']): if len(self.lastDeepestInput) < len(self.env['input']['currInput']):
self.env['input']['prevDeepestInput'] = self.env['input']['currInput'].copy() self.setLastDeepestInput( self.env['input']['currInput'].copy())
elif self.env['input']['prevDeepestInput'] == self.env['input']['currInput']: elif self.lastDeepestInput == self.env['input']['currInput']:
if time.time() - self.env['input']['lastInputTime'] <= self.env['runtime']['settingsManager'].getSettingAsFloat('keyboard','doubleTapTimeout'): if time.time() - self.lastInputTime <= self.env['runtime']['settingsManager'].getSettingAsFloat('keyboard','doubleTapTimeout'):
self.env['input']['shortcutRepeat'] += 1 self.env['input']['shortcutRepeat'] += 1
else: else:
self.env['input']['shortcutRepeat'] = 1 self.env['input']['shortcutRepeat'] = 1
self.setLedState = self.handleLedStates(mEvent) self.setLedState = self.handleLedStates(mEvent)
self.env['input']['lastInputTime'] = time.time() self.lastInputTime = time.time()
elif mEvent['EventState'] == 2: elif mEvent['EventState'] == 2:
self.env['input']['lastInputTime'] = time.time() self.lastInputTime = time.time()
else: else:
pass pass
self.env['input']['oldNumLock'] = self.env['input']['newNumLock'] self.env['input']['oldNumLock'] = self.env['input']['newNumLock']
@ -143,7 +143,14 @@ class inputManager():
def clearEventBuffer(self): def clearEventBuffer(self):
self.env['runtime']['inputDriver'].clearEventBuffer() self.env['runtime']['inputDriver'].clearEventBuffer()
def setLastDeepestInput(self, currentDeepestInput):
self.lastDeepestInput = currentDeepestInput
def clearLastDeepInput(self):
self.lastDeepestInput = []
def getLastInputTime(self):
return self.lastInputTime
def getLastDeepestInput(self):
return self.lastDeepestInput
def writeEventBuffer(self): def writeEventBuffer(self):
try: try:
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'): if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'grabDevices'):
@ -157,10 +164,10 @@ class inputManager():
return self.env['input']['currInput'] == [] return self.env['input']['currInput'] == []
def isKeyPress(self): def isKeyPress(self):
return (self.env['input']['prevInput'] == []) and (self.env['input']['currInput'] != []) return (self.env['input']['prevInput'] == []) and (self.env['input']['currInput'] != [])
def getPrevDeepestInput(self): def getPrevDeepestShortcut(self):
shortcut = [] shortcut = []
shortcut.append(self.env['input']['shortcutRepeat']) shortcut.append(self.env['input']['shortcutRepeat'])
shortcut.append(self.env['input']['prevDeepestInput']) shortcut.append(self.getLastDeepestInput())
return str(shortcut) return str(shortcut)
def getPrevShortcut(self): def getPrevShortcut(self):
@ -186,7 +193,7 @@ class inputManager():
return str(shortcut) return str(shortcut)
def currKeyIsModifier(self): def currKeyIsModifier(self):
if len(self.env['input']['prevDeepestInput']) != 1: if len(self.getLastDeepestInput()) != 1:
return False return False
return (self.env['input']['currInput'][0] =='KEY_FENRIR') or (self.env['input']['currInput'][0] == 'KEY_SCRIPT') return (self.env['input']['currInput'][0] =='KEY_FENRIR') or (self.env['input']['currInput'][0] == 'KEY_SCRIPT')

View File

@ -128,9 +128,8 @@ class driver():
currScreen = str(tty.read()[3:-1]) currScreen = str(tty.read()[3:-1])
oldScreen = currScreen oldScreen = currScreen
watchdog = select.epoll() watchdog = select.epoll()
watchdog.register(vcsa[currScreen], select.EPOLLPRI) watchdog.register(vcsa[currScreen], select.POLLPRI | select.POLLERR)
watchdog.register(tty, select.EPOLLPRI) watchdog.register(tty, select.POLLPRI | select.POLLERR)
lastScreenContent = b''
while active.value == 1: while active.value == 1:
changes = watchdog.poll(2) changes = watchdog.poll(2)
for change in changes: for change in changes:
@ -146,7 +145,7 @@ class driver():
except: except:
pass pass
try: try:
watchdog.register(vcsa[ currScreen ], select.EPOLLPRI) watchdog.register(vcsa[ currScreen ], select.POLLPRI | select.POLLERR)
except: except:
pass pass
oldScreen = currScreen oldScreen = currScreen
@ -155,14 +154,21 @@ class driver():
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
lastScreenContent = vcsa[currScreen].read() lastScreenContent = vcsa[currScreen].read()
except: except:
lastScreenContent = b'' pass
else: else:
self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO) self.env['runtime']['debug'].writeDebugOut('ScreenUpdate',debug.debugLevel.INFO)
vcsa[currScreen].seek(0) vcsa[currScreen].seek(0)
screenContent = vcsa[currScreen].read() dirtyContent = vcsa[currScreen].read()
if screenContent != lastScreenContent: screenContent = b''
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None}) timeout = time.time()
lastScreenContent = screenContent while screenContent != dirtyContent:
screenContent = dirtyContent
if time.time() - timeout >= 0.4:
break
time.sleep(0.03)
vcsa[currScreen].seek(0)
dirtyContent = vcsa[currScreen].read()
eventQueue.put({"Type":fenrirEventType.ScreenUpdate,"Data":None})
except Exception as e: except Exception as e:
self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut('VCSA:updateWatchdog:' + str(e),debug.debugLevel.ERROR)

View File

@ -7,6 +7,9 @@
from core import debug from core import debug
from collections import Counter from collections import Counter
import string import string
from select import select
from select import epoll
import select
def removeNonprintable(text): def removeNonprintable(text):
# Get the difference of all ASCII characters from the set of printable characters # Get the difference of all ASCII characters from the set of printable characters
@ -20,6 +23,16 @@ def insertNewlines(string, every=64):
def splitEvery(toSplit, every=64): def splitEvery(toSplit, every=64):
return list(toSplit[i:i+every] for i in range(0, len(toSplit), every)) return list(toSplit[i:i+every] for i in range(0, len(toSplit), every))
def hasMoreRead(fd):
r, w, e = select([fd], [], [], 0)
return (fd in r)
def hasMorePollPri(fd):
p = epoll()
p.register(fd, select.POLLPRI | select.POLLERR)
r = p.poll(0)
return (fd in r)
def trackHighlights(oldAttr, newAttr, text, lenght): def trackHighlights(oldAttr, newAttr, text, lenght):
result = '' result = ''
currCursor = None currCursor = None