From c5642c4118da8c847acdafa361df4a4ee7ee27f8 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 18 Oct 2016 17:58:37 +0200 Subject: [PATCH] add KEY_SCRIPT, and make fenrir load it from settings. Fenrir also understand its press currently --- config/settings/settings.conf | 1 + config/settings/settings.conf.storm | 1 + src/fenrir/core/inputEvent.py | 3 ++- src/fenrir/core/inputManager.py | 8 +++++++- src/fenrir/core/settings.py | 1 + src/fenrir/core/settingsManager.py | 15 +++++++-------- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 288e9932..989d701a 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -105,6 +105,7 @@ numberOfClipboards=10 emoticons=True # define the current fenrir key fenrirKeys=KEY_KP0,KEY_META +scriptKey=KEY_COMPOSE timeFormat=%H:%M:%P dateFormat=%A, %B %d, %Y autoSpellCheck=True diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 7fad3797..6ebb346b 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -55,6 +55,7 @@ newLinePause=True numberOfClipboards=10 emoticons=True fenrirKeys=KEY_KP0 +scriptKey=KEY_COMPOSE timeFormat=%H:%M:%P dateFormat="%A, %B %d, %Y" autoSpellCheck=True diff --git a/src/fenrir/core/inputEvent.py b/src/fenrir/core/inputEvent.py index 583aeab5..8226b741 100644 --- a/src/fenrir/core/inputEvent.py +++ b/src/fenrir/core/inputEvent.py @@ -12,7 +12,8 @@ input = { 'prevDeepestInput': [], 'eventBuffer': [], 'shortcutRepeat': 0, -'fenrirKey': ['KEY_KP0'], +'fenrirKey': [], +'scriptKey': [], 'keyForeward': 0, 'lastInputTime':time.time(), 'oldNumLock': True, diff --git a/src/fenrir/core/inputManager.py b/src/fenrir/core/inputManager.py index b2e96ddb..ef526cd5 100644 --- a/src/fenrir/core/inputManager.py +++ b/src/fenrir/core/inputManager.py @@ -105,6 +105,8 @@ class inputManager(): eventName = 'KEY_META' if self.isFenrirKey(eventName): eventName = 'KEY_FENRIR' + if self.isScriptKey(eventName): + eventName = 'KEY_SCRIPT' return eventName def isConsumeInput(self): @@ -132,6 +134,9 @@ class inputManager(): def isFenrirKeyPressed(self): return 'KEY_FENRIR' in self.env['input']['currInput'] + + def isScriptKeyPressed(self): + return 'KEY_SCRIPT' in self.env['input']['currInput'] def noKeyPressed(self): return self.env['input']['currInput'] == [] @@ -162,7 +167,8 @@ class inputManager(): def isFenrirKey(self, eventName): return eventName in self.env['input']['fenrirKey'] - + def isScriptKey(self, eventName): + return eventName in self.env['input']['scriptKey'] def getCommandForShortcut(self, shortcut): if not self.shortcutExists(shortcut): return '' diff --git a/src/fenrir/core/settings.py b/src/fenrir/core/settings.py index 146f9a5e..4370a78a 100644 --- a/src/fenrir/core/settings.py +++ b/src/fenrir/core/settings.py @@ -48,6 +48,7 @@ settings = { 'numberOfClipboards': 10, 'emoticons': True, 'fenrirKeys': ['KEY_KP0','KEY_META'], + 'scriptKeys': ['KEY_COMPOSE'], 'timeFormat': '%I:%M%P', 'dateFormat': '%A, %B %d, %Y', 'autoSpellCheck': False, diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index bc7aaac3..d8601576 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -186,14 +186,12 @@ class settingsManager(): for key in keyList: if not key in self.env['input']['fenrirKey']: self.env['input']['fenrirKey'].append(key) - - def keyIDasString(self, key): - try: - KeyID = self.getCodeForKeyID(key) - return str(KeyID) - except: - return '' - + def setScriptKeys(self, keys): + keys = keys.upper() + keyList = keys.split(',') + for key in keyList: + if not key in self.env['input']['scriptKey']: + self.env['input']['scriptKey'].append(key) def initFenrirConfig(self, environment = environment.environment, settingsRoot = '/etc/fenrir/', settingsFile='settings.conf'): environment['runtime']['debug'] = debug.debug() environment['runtime']['debug'].initialize(environment) @@ -210,6 +208,7 @@ class settingsManager(): if not validConfig: return None self.setFenrirKeys(self.getSetting('general','fenrirKeys')) + self.setScriptKeys(self.getSetting('general','scriptKeys')) if not os.path.exists(self.getSetting('keyboard','keyboardLayout')): if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout')): self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout'))