initial onApplicationChange trigger

This commit is contained in:
chrys 2016-09-21 23:46:03 +02:00
parent 2cd218f3e7
commit 52793528dd
6 changed files with 39 additions and 7 deletions

9
TODO
View File

@ -22,8 +22,7 @@ ToDos in Priority order:
- punctuation - punctuation
- New Triggers - New Triggers
onAppChange onAppChange
onScreenChange
rename current onScreenChange to onScreenUpdate
- add perApplicationTrigger trigger - add perApplicationTrigger trigger
per application commands per application commands
per application onScreenChange per application onScreenChange
@ -214,4 +213,8 @@ ps a -o tty,comm | grep -e Xorg | grep -v "grep -e Xorg"
- add screenManager - add screenManager
abstract screen driver abstract screen driver
- pass environment instance in init and remove it from function calls - pass environment instance in init and remove it from function calls
- New Triggers
onScreenChange
rename current onScreenChange to onScreenUpdate

View File

@ -0,0 +1,24 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from core import debug
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return 'No description found'
def run(self):
print('new %s', self.env['screenData']['newApplication'])
print('old %s', self.env['screenData']['oldApplication'])
print('-----------')
def setCallback(self, callback):
pass

View File

@ -16,13 +16,15 @@ class commandManager():
self.env['runtime']['commandManager'].loadCommands('commands') self.env['runtime']['commandManager'].loadCommands('commands')
self.env['runtime']['commandManager'].loadCommands('onInput') self.env['runtime']['commandManager'].loadCommands('onInput')
self.env['runtime']['commandManager'].loadCommands('onScreenUpdate') self.env['runtime']['commandManager'].loadCommands('onScreenUpdate')
self.env['runtime']['commandManager'].loadCommands('onScreenChanged') self.env['runtime']['commandManager'].loadCommands('onScreenChanged')
self.env['runtime']['commandManager'].loadCommands('onApplicationChange')
def shutdown(self): def shutdown(self):
self.env['runtime']['commandManager'].shutdownCommands('commands') self.env['runtime']['commandManager'].shutdownCommands('commands')
self.env['runtime']['commandManager'].shutdownCommands('onInput') self.env['runtime']['commandManager'].shutdownCommands('onInput')
self.env['runtime']['commandManager'].shutdownCommands('onScreenUpdate') self.env['runtime']['commandManager'].shutdownCommands('onScreenUpdate')
self.env['runtime']['commandManager'].shutdownCommands('onScreenChanged') self.env['runtime']['commandManager'].shutdownCommands('onScreenChanged')
self.env['runtime']['commandManager'].shutdownCommands('onApplicationChange')
def loadCommands(self, section='commands'): def loadCommands(self, section='commands'):
commandFolder = "commands/" + section +"/" commandFolder = "commands/" + section +"/"

View File

@ -33,7 +33,9 @@ commands = {
'onScreenChanged':{ 'onScreenChanged':{
}, },
'onScreenUpdate':{ 'onScreenUpdate':{
}, },
'onApplicationChange':{
},
'commands':{ 'commands':{
} },
} }

View File

@ -50,6 +50,8 @@ class fenrir():
print(e) print(e)
self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
if self.environment['screenData']['newApplication'] != self.environment['screenData']['oldApplication']:
self.environment['runtime']['commandManager'].executeTriggerCommands('onApplicationChange')
self.environment['runtime']['commandManager'].executeTriggerCommands('onInput') self.environment['runtime']['commandManager'].executeTriggerCommands('onInput')
if self.environment['screenData']['newTTY'] == self.environment['screenData']['oldTTY']: if self.environment['screenData']['newTTY'] == self.environment['screenData']['oldTTY']:
self.environment['runtime']['commandManager'].executeTriggerCommands('onScreenUpdate') self.environment['runtime']['commandManager'].executeTriggerCommands('onScreenUpdate')

View File

@ -113,7 +113,6 @@ class driver():
self.env['screenData']['oldCursor']['y'] = 0 self.env['screenData']['oldCursor']['y'] = 0
self.env['screenData']['oldDelta'] = '' self.env['screenData']['oldDelta'] = ''
self.env['screenData']['oldNegativeDelta'] = '' self.env['screenData']['oldNegativeDelta'] = ''
self.env['screenData']['oldApplication'] = ''
# always clear current deltas # always clear current deltas
self.env['screenData']['newNegativeDelta'] = '' self.env['screenData']['newNegativeDelta'] = ''
self.env['screenData']['newDelta'] = '' self.env['screenData']['newDelta'] = ''