make byte shortcuts load from file
This commit is contained in:
parent
6f287f90a1
commit
ed2bb0f223
@ -88,6 +88,7 @@ Driver (screen, input):
|
||||
[W]set flag that it is used in emulation
|
||||
[W] handle byte shortcuts
|
||||
[W] detect shortcuts
|
||||
[] Load escape sequence shortcuts
|
||||
[] write/ consume them (controll it at all)
|
||||
[W] create keyboard layout
|
||||
[X] controll modes (vim like mode to not collide with application shortcuts)
|
||||
|
@ -100,7 +100,7 @@ class fenrirManager():
|
||||
self.detectByteCommand(event['Data'])
|
||||
|
||||
def handleControlMode(self, escapeSequence):
|
||||
convertedEscapeSequence = self.unifyEscapeSeq(escapeSequence)
|
||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||
if self.switchCtrlModeOnce > 0:
|
||||
self.switchCtrlModeOnce -= 1
|
||||
if convertedEscapeSequence == b'^[R':
|
||||
@ -162,15 +162,12 @@ class fenrirManager():
|
||||
def handleHeartBeat(self, event):
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onHeartBeat',force=True)
|
||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||
def unifyEscapeSeq(self, escapeSequence):
|
||||
convertedEscapeSequence = escapeSequence
|
||||
if convertedEscapeSequence[0] == 27:
|
||||
convertedEscapeSequence = b'^[' + convertedEscapeSequence[1:]
|
||||
return convertedEscapeSequence
|
||||
|
||||
def detectByteCommand(self, escapeSequence):
|
||||
convertedEscapeSequence = self.unifyEscapeSeq(escapeSequence)
|
||||
convertedEscapeSequence = self.environment['runtime']['byteManager'].unifyEscapeSeq(escapeSequence)
|
||||
command = ''
|
||||
try:
|
||||
'''
|
||||
commands = {
|
||||
b'^[h':'toggle_tutorial_mode',
|
||||
b'^[/': 'shut_up',
|
||||
@ -207,7 +204,9 @@ class fenrirManager():
|
||||
b'^[X': 'remove_marks',
|
||||
b'^[x': 'set_mark',
|
||||
}
|
||||
command = commands[convertedEscapeSequence].upper()
|
||||
'''
|
||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(convertedEscapeSequence)
|
||||
print(convertedEscapeSequence,command)
|
||||
self.environment['runtime']['eventManager'].putToEventQueue(fenrirEventType.ExecuteCommand, command)
|
||||
except:
|
||||
pass
|
||||
|
@ -23,6 +23,7 @@ from fenrirscreenreader.core import applicationManager
|
||||
from fenrirscreenreader.core import helpManager
|
||||
from fenrirscreenreader.core import headLineManager
|
||||
from fenrirscreenreader.core import tableManager
|
||||
from fenrirscreenreader.core import byteManager
|
||||
from fenrirscreenreader.core import environment
|
||||
from fenrirscreenreader.core import inputData
|
||||
from fenrirscreenreader.core.settingsData import settingsData
|
||||
@ -33,6 +34,7 @@ class settingsManager():
|
||||
def __init__(self):
|
||||
self.settings = settingsData
|
||||
self.settingArgDict = {}
|
||||
self.shortcutType = 'KEY'
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
@ -81,6 +83,25 @@ class settingsManager():
|
||||
kbConfig.close()
|
||||
# fix bindings
|
||||
self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE'
|
||||
def loadByteShortcuts(self, kbConfigPath=fenrirPath + '/../../config/keyboard/pty.conf'):
|
||||
kbConfig = open(kbConfigPath,"r")
|
||||
while(True):
|
||||
line = kbConfig.readline()
|
||||
if not line:
|
||||
break
|
||||
line = line.replace('\n','')
|
||||
if line.replace(" ","") == '':
|
||||
continue
|
||||
if line.replace(" ","").startswith("#"):
|
||||
continue
|
||||
if line.count("=") != 1:
|
||||
continue
|
||||
Values = line.split('=')
|
||||
shortcut = bytes(Values[0],'UTF-8')
|
||||
commandName = Values[1].upper()
|
||||
self.env['bindings'][shortcut] = commandName
|
||||
self.env['runtime']['debug'].writeDebugOut("Byte Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True)
|
||||
kbConfig.close()
|
||||
|
||||
def loadSoundIcons(self, soundIconPath):
|
||||
siConfig = open(soundIconPath + '/soundicons.conf',"r")
|
||||
@ -285,7 +306,6 @@ class settingsManager():
|
||||
validConfig = environment['runtime']['settingsManager'].loadSettings(settingsFile)
|
||||
if not validConfig:
|
||||
return None
|
||||
|
||||
if cliArgs.options != '':
|
||||
self.parseSettingArgs(cliArgs.options)
|
||||
if cliArgs.debug:
|
||||
@ -296,6 +316,10 @@ class settingsManager():
|
||||
if cliArgs.emulation:
|
||||
self.setOptionArgDict('screen', 'driver', 'ptyDriver')
|
||||
self.setOptionArgDict('keyboard', 'driver', 'ptyDriver')
|
||||
# TODO needs cleanup use dict
|
||||
#self.setOptionArgDict('keyboard', 'keyboardLayout', 'pty')
|
||||
self.setSetting('keyboard', 'keyboardLayout', 'pty')
|
||||
self.shortcutType = 'BYTE'
|
||||
self.setOptionArgDict('general', 'debugFile', '/tmp/fenrir-pty.log')
|
||||
self.setFenrirKeys(self.getSetting('general','fenrirKeys'))
|
||||
self.setScriptKeys(self.getSetting('general','scriptKeys'))
|
||||
@ -303,6 +327,7 @@ class settingsManager():
|
||||
environment['runtime']['debug'] = debugManager.debugManager(self.env['runtime']['settingsManager'].getSetting('general','debugFile'))
|
||||
environment['runtime']['debug'].initialize(environment)
|
||||
|
||||
if self.shortcutType == 'KEY':
|
||||
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'))
|
||||
@ -312,6 +337,16 @@ class settingsManager():
|
||||
environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
else:
|
||||
environment['runtime']['settingsManager'].loadShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
elif self.shortcutType == 'BYTE':
|
||||
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'))
|
||||
environment['runtime']['settingsManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
if os.path.exists(settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf'):
|
||||
self.setSetting('keyboard', 'keyboardLayout', settingsRoot + 'keyboard/' + self.getSetting('keyboard','keyboardLayout') + '.conf')
|
||||
environment['runtime']['settingsManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
else:
|
||||
environment['runtime']['settingsManager'].loadByteShortcuts(self.getSetting('keyboard','keyboardLayout'))
|
||||
|
||||
if not os.path.exists(self.getSetting('sound','theme') + '/soundicons.conf'):
|
||||
if os.path.exists(soundRoot + self.getSetting('sound','theme')):
|
||||
@ -331,8 +366,10 @@ class settingsManager():
|
||||
else:
|
||||
environment['runtime']['settingsManager'].loadDicts(self.getSetting('general','punctuationProfile'))
|
||||
|
||||
|
||||
if fenrirManager:
|
||||
environment['runtime']['fenrirManager'] = fenrirManager
|
||||
|
||||
environment['runtime']['memoryManager'] = memoryManager.memoryManager()
|
||||
environment['runtime']['memoryManager'].initialize(environment)
|
||||
environment['runtime']['eventManager'] = eventManager.eventManager()
|
||||
@ -343,6 +380,8 @@ class settingsManager():
|
||||
environment['runtime']['commandManager'].initialize(environment)
|
||||
environment['runtime']['inputManager'] = inputManager.inputManager()
|
||||
environment['runtime']['inputManager'].initialize(environment)
|
||||
environment['runtime']['byteManager'] = byteManager.byteManager()
|
||||
environment['runtime']['byteManager'].initialize(environment)
|
||||
environment['runtime']['outputManager'] = outputManager.outputManager()
|
||||
environment['runtime']['outputManager'].initialize(environment)
|
||||
environment['runtime']['punctuationManager'] = punctuationManager.punctuationManager()
|
||||
|
Loading…
Reference in New Issue
Block a user