From 7a460b0d83f228bdb9b8a4003d38cfd0e21d5574 Mon Sep 17 00:00:00 2001 From: chrys Date: Wed, 12 Jul 2017 23:28:23 +0200 Subject: [PATCH] announce shortct --- src/fenrir/commands/help/toggle_tutorial_mode.py | 1 - src/fenrir/core/commandManager.py | 11 ++++++++--- src/fenrir/core/helpManager.py | 9 ++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/fenrir/commands/help/toggle_tutorial_mode.py b/src/fenrir/commands/help/toggle_tutorial_mode.py index 806f521f..18d778a3 100644 --- a/src/fenrir/commands/help/toggle_tutorial_mode.py +++ b/src/fenrir/commands/help/toggle_tutorial_mode.py @@ -16,7 +16,6 @@ class command(): def getDescription(self): return _('Toggle the Tutorial mode') def run(self): - print('TM') text = '' if self.env['runtime']['helpManager'].isTutorialMode(): text = _('You are leaving the tutorial mode. Press that shortcut again to enter the tutorial mode again.') diff --git a/src/fenrir/core/commandManager.py b/src/fenrir/core/commandManager.py index d387b0eb..68a99e6c 100644 --- a/src/fenrir/core/commandManager.py +++ b/src/fenrir/core/commandManager.py @@ -126,7 +126,6 @@ class commandManager(): shortcut.append(sorted(shortcutKeys)) self.env['bindings'][str(shortcut)] = fileName.upper() except Exception as e: - print(e) self.env['runtime']['debug'].writeDebugOut("Loading script:" + command ,debug.debugLevel.ERROR) self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR) continue @@ -196,7 +195,6 @@ class commandManager(): if self.commandExists(command, section): try: self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO) - print(command, section) self.env['commands'][section][command].run() except Exception as e: self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR) @@ -222,4 +220,11 @@ class commandManager(): self.env['commandInfo']['currCommand'] = command def commandExists(self, command, section = 'commands'): - return( command in self.env['commands'][section]) + return( command in self.env['commands'][section]) + def getShortcutForCommand(self, command): + shortcut = '' + try: + shortcut = list(self.env['bindings'].keys())[list(self.env['bindings'].values()).index(command)] + except: + pass + return shortcut diff --git a/src/fenrir/core/helpManager.py b/src/fenrir/core/helpManager.py index bc6f3d92..ec8c2875 100755 --- a/src/fenrir/core/helpManager.py +++ b/src/fenrir/core/helpManager.py @@ -28,7 +28,14 @@ class helpManager(): commandName = commandName.split('__-__')[0] commandName = commandName.replace('_',' ') commandName = commandName.replace('_',' ') - helptext = commandName + ', Shortcut , Description' + self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands') + commandDescription = self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands') + if commandDescription == '': + commandDescription = 'no Description available' + commandShortcut = self.env['runtime']['commandManager'].getShortcutForCommand( command) + commandShortcut = commandShortcut.replace('KEY_',' ') + if commandShortcut == '': + commandShortcut = 'unbound' + helptext = commandName + ', Shortcut ' + commandShortcut + ', Description' + commandDescription return helptext def createHelpDict(self, section = 'commands'): self.helpDict = {}