diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/curr_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu/navigation/curr_vmenu_entry.py index 4f0ebf31..e14f9f13 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/curr_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/curr_vmenu_entry.py @@ -14,9 +14,9 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get current help message') + return _('get current v menu entry') def run(self): - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + text = self.env['runtime']['vmenuManager'].getCurrentEntry() + self.env['runtime']['outputManager'].presentText(text, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/dec_level_vmenu.py b/src/fenrirscreenreader/commands/vmenu/navigation/dec_level_vmenu.py index 3060ecc2..67c41b97 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/dec_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/dec_level_vmenu.py @@ -14,10 +14,10 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get prev help message') + return _('leave v menu submenu') def run(self): - self.env['runtime']['helpManager'].prevIndex() - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + self.env['runtime']['vmenuManager'].decLevel() + text = self.env['runtime']['vmenuManager'].getCurrentEntry() + self.env['runtime']['outputManager'].presentText(text, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/exec_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu/navigation/exec_vmenu_entry.py index 3060ecc2..af32cb51 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/exec_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/exec_vmenu_entry.py @@ -14,10 +14,8 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get prev help message') + return _('execute v menu entry') def run(self): - self.env['runtime']['helpManager'].prevIndex() - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + self.env['runtime']['vmenuManager'].executeMenu() def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/inc_level_vmenu.py b/src/fenrirscreenreader/commands/vmenu/navigation/inc_level_vmenu.py index 3060ecc2..342a215f 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/inc_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/inc_level_vmenu.py @@ -14,10 +14,10 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get prev help message') + return _('enter v menu submenu') def run(self): - self.env['runtime']['helpManager'].prevIndex() - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + self.env['runtime']['vmenuManager'].incLevel() + text = self.env['runtime']['vmenuManager'].getCurrentEntry() + self.env['runtime']['outputManager'].presentText(text, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/next_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu/navigation/next_vmenu_entry.py index 7ef3993e..8eb1d409 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/next_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/next_vmenu_entry.py @@ -14,10 +14,10 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get next help message') + return _('get next v menu entry') def run(self): - self.env['runtime']['helpManager'].nextIndex() - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + self.env['runtime']['vmenuManager'].nextIndex() + text = self.env['runtime']['vmenuManager'].getCurrentEntry() + self.env['runtime']['outputManager'].presentText(text, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/prev_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu/navigation/prev_vmenu_entry.py index 3060ecc2..2a9ee977 100644 --- a/src/fenrirscreenreader/commands/vmenu/navigation/prev_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu/navigation/prev_vmenu_entry.py @@ -14,10 +14,10 @@ class command(): def shutdown(self): pass def getDescription(self): - return _('get prev help message') + return _('get prev v menu entry') def run(self): - self.env['runtime']['helpManager'].prevIndex() - text = self.env['runtime']['helpManager'].getHelpForCurrentIndex() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + self.env['runtime']['vmenuManager'].prevIndex() + text = self.env['runtime']['vmenuManager'].getCurrentEntry() + self.env['runtime']['outputManager'].presentText(text, interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu/navigation/toggle_vmenu_mode.py b/src/fenrirscreenreader/commands/vmenu/navigation/toggle_vmenu_mode.py new file mode 100644 index 00000000..d8b62d5f --- /dev/null +++ b/src/fenrirscreenreader/commands/vmenu/navigation/toggle_vmenu_mode.py @@ -0,0 +1,23 @@ +#!/bin/python +# -*- coding: utf-8 -*- + +# Fenrir TTY screen reader +# By Chrys, Storm Dragon, and contributers. + +from fenrirscreenreader.core import debug + +class command(): + def __init__(self): + pass + def initialize(self, environment): + self.env = environment + def shutdown(self): + pass + def getDescription(self): + self.env['runtime']['vmenuManager'].togglelVMenuMode() + return _('Exiting v menu mode.') + def run(self): + self.env['runtime']['vmenuManager'].togglelVMenuMode() + self.env['runtime']['outputManager'].presentText( _('Entering v menu.'), interrupt=True) + def setCallback(self, callback): + pass diff --git a/src/fenrirscreenreader/core/vmenuManager.py b/src/fenrirscreenreader/core/vmenuManager.py index 064bc516..d1ec2779 100755 --- a/src/fenrirscreenreader/core/vmenuManager.py +++ b/src/fenrirscreenreader/core/vmenuManager.py @@ -31,13 +31,12 @@ class vmenuManager(): return self.currMenu def getActive(self): return self.active - def togglelMode(self): + def togglelVMenuMode(self): self.setActive(not self.getActive()) def setActive(self, active): self.active = active - self.currMenu = currMenu if active: - self.createMenuTree() + self.createMenuTree() self.env['bindings'][str([1, ['KEY_ESC']])] = 'TOGGLE_VMENU_MODE' self.env['bindings'][str([1, ['KEY_UP']])] = 'PREV_VMENU_ENTRY' self.env['bindings'][str([1, ['KEY_DOWN']])] = 'NEXT_VMENU_ENTRY' @@ -50,7 +49,6 @@ class vmenuManager(): self.menuDict = {} self.currIndex = None self.currMenu = '' - self.currLevel = 0 self.active = False del(self.env['bindings'][str([1, ['KEY_ESC']])]) del(self.env['bindings'][str([1, ['KEY_UP']])]) @@ -67,15 +65,13 @@ class vmenuManager(): self.currIndex = None self.menuDict = fs_tree_to_dict( '/home/chrys/Projekte/fenrir/src/fenrirscreenreader/commands/vmenu/KEY') if len(self.menuDict) > 0: - self.currIndex = 0 + self.currIndex = [0] def executeMenu(self): if self.currIndex == None: return def incLevel(self): if self.currIndex == None: return - if len(self.currIndex) == 1: - return try: r = self.getValueByPath(self.menuDict, self.currIndex +[0]): if not r: @@ -107,11 +103,14 @@ class vmenuManager(): self.currIndex[len(self.currIndex) - 1] -= 1 if self.currIndex[len(self.currIndex) - 1] < 0: self.currIndex[len(self.currIndex) - 1] = len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])) - 1 + def getCurrentEntry(self): + return self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]] def fs_tree_to_dict(self, path_): for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: root + '/' + f for f in files}) return tree # note we discontinue iteration trough os.walk + def getKeysByPath(self, complete, path): if not isinstance(complete, dict): return[]