diff --git a/config/settings/settings.conf b/config/settings/settings.conf index c9565d06..1dcb5ae6 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -122,7 +122,7 @@ driver=vcsaDriver encoding=cp850 screenUpdateDelay=0.05 suspendingScreen= -autodetectSuspendingScreen=True +autodetectSuspendingScreen=False [keyboard] driver=evdevDriver diff --git a/src/fenrir/commands/help/toggle_tutorial_mode.py b/src/fenrir/commands/help/toggle_tutorial_mode.py deleted file mode 100644 index 18d778a3..00000000 --- a/src/fenrir/commands/help/toggle_tutorial_mode.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/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 _('Toggle the Tutorial mode') - def run(self): - text = '' - if self.env['runtime']['helpManager'].isTutorialMode(): - text = _('You are leaving the tutorial mode. Press that shortcut again to enter the tutorial mode again.') - else: - text = _('you entered the tutorial mode. In that mode the commands are not executed. but you get a description of what the shortcut does. To leave the tutorial mode, press that shortcut again.') - self.env['runtime']['helpManager'].toggleTutorialMode() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) - - def setCallback(self, callback): - pass diff --git a/src/fenrir/core/commandManager.py b/src/fenrir/core/commandManager.py index 3feadce9..683bea94 100644 --- a/src/fenrir/core/commandManager.py +++ b/src/fenrir/core/commandManager.py @@ -181,7 +181,7 @@ class commandManager(): return if self.commandExists(command, section): try: - if self.env['runtime']['helpManager'].isTutorialMode(): + if self.env['runtime']['helpManager'].isTutorialMode() and section != 'help': self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO) description = self.getCommandDescription(command, section) self.env['runtime']['outputManager'].presentText(description, interrupt=True) diff --git a/src/fenrir/core/fenrirManager.py b/src/fenrir/core/fenrirManager.py index deb99916..5ca2a377 100644 --- a/src/fenrir/core/fenrirManager.py +++ b/src/fenrir/core/fenrirManager.py @@ -54,9 +54,9 @@ class fenrirManager(): startTime = time.time() if eventReceived: self.prepareCommand() - if not self.environment['runtime']['screenManager'].isSuspendingScreen(): - if self.environment['runtime']['helpManager'].handleTutorialMode(): - self.wasCommand = True + #if not self.environment['runtime']['screenManager'].isSuspendingScreen(): + # if self.environment['runtime']['helpManager'].handleTutorialMode(): + # self.wasCommand = True if not (self.wasCommand or self.environment['runtime']['helpManager'].isTutorialMode()) or self.environment['runtime']['screenManager'].isSuspendingScreen(): self.environment['runtime']['inputManager'].writeEventBuffer() if self.environment['runtime']['inputManager'].noKeyPressed(): @@ -70,7 +70,7 @@ class fenrirManager(): self.environment['input']['keyForeward'] -=1 #self.environment['runtime']['screenManager'].update('onInput') self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput') - self.handleCommands() + self.handleCommands() def handleScreenChange(self): self.environment['runtime']['screenManager'].update('onScreenChange') ''' @@ -116,19 +116,21 @@ class fenrirManager(): if self.environment['input']['keyForeward'] > 0: return shortcut = self.environment['runtime']['inputManager'].getCurrShortcut() - command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut) - if len(self.environment['input']['prevDeepestInput']) <= len(self.environment['input']['currInput']): + command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut) + if len(self.environment['input']['prevDeepestInput']) >= len(self.environment['input']['currInput']): self.wasCommand = command != '' or self.environment['runtime']['inputManager'].isFenrirKeyPressed() or self.environment['runtime']['inputManager'].isScriptKeyPressed() if command == '': return - self.environment['runtime']['commandManager'].queueCommand(command) def handleCommands(self): if not self.environment['runtime']['commandManager'].isCommandQueued(): return + if len(self.environment['input']['prevDeepestInput']) > len(self.environment['input']['currInput']): + return + if self.environment['runtime']['helpManager'].isTutorialMode(): + self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'help') self.environment['runtime']['commandManager'].executeCommand( self.environment['commandInfo']['currCommand'], 'commands') - def shutdownRequest(self): self.environment['runtime']['eventManager'].stopMainEventLoop() diff --git a/src/fenrir/core/helpManager.py b/src/fenrir/core/helpManager.py index 24316dd4..57614d4c 100755 --- a/src/fenrir/core/helpManager.py +++ b/src/fenrir/core/helpManager.py @@ -14,13 +14,26 @@ class helpManager(): def initialize(self, environment): self.env = environment self.createHelpDict() - def shutdown(self): pass def toggleTutorialMode(self): self.setTutorialMode(not self.env['general']['tutorialMode']) def setTutorialMode(self, newTutorialMode): - self.env['general']['tutorialMode'] = newTutorialMode + self.env['general']['tutorialMode'] = newTutorialMode + if newTutorialMode: + self.createHelpDict() + self.env['bindings'][str([1, ['KEY_ESC']])] = 'TOGGLE_TUTORIAL_MODE' + self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_HELP' + self.env['bindings'][str([1, ['KEY_DOWN']])] = 'NEXT_HELP' + self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_HELP' + else: + try: + del(self.env['bindings'][str([1, ['KEY_ESC']])]) + del(self.env['bindings'][str([1, ['KEY_UP']])]) + del(self.env['bindings'][str([1, ['KEY_DOWN']])]) + del(self.env['bindings'][str([1, ['KEY_SPACE']])]) + except: + pass def isTutorialMode(self): return self.env['general']['tutorialMode'] def getCommandHelpText(self, command, section = 'commands'): @@ -28,11 +41,17 @@ class helpManager(): commandName = commandName.split('__-__')[0] commandName = commandName.replace('_',' ') commandName = commandName.replace('_',' ') - commandDescription = self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands') + if command == 'TOGGLE_TUTORIAL_MODE': + commandDescription = _('toggles the tutorial mode') + else: + 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_',' ') + commandShortcut = commandShortcut.replace('[','') + commandShortcut = commandShortcut.replace(']','') + commandShortcut = commandShortcut.replace("'",'') if commandShortcut == '': commandShortcut = 'unbound' helptext = commandName + ', Shortcut ' + commandShortcut + ', Description ' + commandDescription @@ -43,6 +62,8 @@ class helpManager(): self.helpDict[len(self.helpDict)] = self.getCommandHelpText(command, section) if len(self.helpDict) > 0: self.tutorialListIndex = 0 + else: + self.tutorialListIndex = None def getHelpForCurrentIndex(self): if self.tutorialListIndex == None: return '' @@ -60,6 +81,7 @@ class helpManager(): if self.tutorialListIndex < 0: self.tutorialListIndex = len(self.helpDict) - 1 def handleTutorialMode(self): + return if self.env['runtime']['inputManager'].noKeyPressed(): return if self.env['input']['currInput'] in [['KEY_F1', 'KEY_FENRIR']]: diff --git a/src/fenrir/core/settingsManager.py b/src/fenrir/core/settingsManager.py index 910fb356..e0bdca89 100644 --- a/src/fenrir/core/settingsManager.py +++ b/src/fenrir/core/settingsManager.py @@ -70,8 +70,10 @@ class settingsManager(): self.env['runtime']['debug'].writeDebugOut("invalid shortcut (missing KEY_FENRIR): "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.ERROR) continue self.env['runtime']['debug'].writeDebugOut("Shortcut: "+ str(shortcut) + ' command:' +commandName ,debug.debugLevel.INFO, onAnyLevel=True) - self.env['bindings'][str(shortcut)] = commandName + self.env['bindings'][str(shortcut)] = commandName kbConfig.close() + # fix bindings + self.env['bindings'][str([1, ['KEY_F1', 'KEY_FENRIR']])] = 'TOGGLE_TUTORIAL_MODE' def loadSoundIcons(self, soundIconPath): siConfig = open(soundIconPath + '/soundicons.conf',"r")