diff --git a/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py b/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py index d8b62d5f..1090323e 100644 --- a/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py +++ b/src/fenrirscreenreader/commands/commands/toggle_vmenu_mode.py @@ -18,6 +18,9 @@ class command(): return _('Exiting v menu mode.') def run(self): self.env['runtime']['vmenuManager'].togglelVMenuMode() - self.env['runtime']['outputManager'].presentText( _('Entering v menu.'), interrupt=True) + if self.env['runtime']['vmenuManager'].getActive(): + self.env['runtime']['outputManager'].presentText( _('Entering v menu.'), interrupt=True) + else: + self.env['runtime']['outputManager'].presentText( _('Leaving v menu.'), interrupt=True) def setCallback(self, callback): pass diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py index e14f9f13..bb98c8e9 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/curr_vmenu_entry.py @@ -16,7 +16,8 @@ class command(): def getDescription(self): return _('get current v menu entry') def run(self): + print('CURR MENU') text = self.env['runtime']['vmenuManager'].getCurrentEntry() - self.env['runtime']['outputManager'].presentText(text, interrupt=True) + 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 67c41b97..e461c864 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/dec_level_vmenu.py @@ -16,6 +16,7 @@ class command(): def getDescription(self): return _('leave v menu submenu') def run(self): + print('DEC LEVEL') self.env['runtime']['vmenuManager'].decLevel() text = self.env['runtime']['vmenuManager'].getCurrentEntry() self.env['runtime']['outputManager'].presentText(text, interrupt=True) diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py index af32cb51..3e031473 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/exec_vmenu_entry.py @@ -16,6 +16,8 @@ class command(): def getDescription(self): return _('execute v menu entry') def run(self): + print('EXEC ENTRY') + 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 342a215f..0c59dfcf 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/inc_level_vmenu.py @@ -16,6 +16,8 @@ class command(): def getDescription(self): return _('enter v menu submenu') def run(self): + print('INC LEVEL') + self.env['runtime']['vmenuManager'].incLevel() text = self.env['runtime']['vmenuManager'].getCurrentEntry() self.env['runtime']['outputManager'].presentText(text, interrupt=True) diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py index 8eb1d409..36d0022e 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/next_vmenu_entry.py @@ -16,6 +16,7 @@ class command(): def getDescription(self): return _('get next v menu entry') def run(self): + print('NEXT MENU') self.env['runtime']['vmenuManager'].nextIndex() text = self.env['runtime']['vmenuManager'].getCurrentEntry() self.env['runtime']['outputManager'].presentText(text, interrupt=True) diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py b/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py index 2a9ee977..9043aa0a 100644 --- a/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py +++ b/src/fenrirscreenreader/commands/vmenu-navigation/prev_vmenu_entry.py @@ -16,6 +16,8 @@ class command(): def getDescription(self): return _('get prev v menu entry') def run(self): + print('PREV MENU') + self.env['runtime']['vmenuManager'].prevIndex() text = self.env['runtime']['vmenuManager'].getCurrentEntry() self.env['runtime']['outputManager'].presentText(text, interrupt=True) diff --git a/src/fenrirscreenreader/commands/vmenu-navigation/toggle_vmenu_mode.py b/src/fenrirscreenreader/commands/vmenu-navigation/toggle_vmenu_mode.py deleted file mode 100644 index d8b62d5f..00000000 --- a/src/fenrirscreenreader/commands/vmenu-navigation/toggle_vmenu_mode.py +++ /dev/null @@ -1,23 +0,0 @@ -#!/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 985f7520..f99cf80e 100755 --- a/src/fenrirscreenreader/core/vmenuManager.py +++ b/src/fenrirscreenreader/core/vmenuManager.py @@ -35,43 +35,51 @@ class vmenuManager(): self.setActive(not self.getActive()) def setActive(self, active): self.active = active - if active: + print('drin') + if self.active: + #try: 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' - self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_VMENU_ENTRY' - self.env['bindings'][str([1, ['KEY_LEFT']])] = 'DEC_LEVEL_VMENU' - self.env['bindings'][str([1, ['KEY_RIGHT']])] = 'INC_LEVEL_VMENU' - self.env['bindings'][str([1, ['KEY_ENTER']])] = 'EXEC_VMENU_ENTRY' + #except Exception as e: + # print(e) + try: + 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' + self.env['bindings'][str([1, ['KEY_SPACE']])] = 'CURR_VMENU_ENTRY' + self.env['bindings'][str([1, ['KEY_LEFT']])] = 'DEC_LEVEL_VMENU' + self.env['bindings'][str([1, ['KEY_RIGHT']])] = 'INC_LEVEL_VMENU' + self.env['bindings'][str([1, ['KEY_ENTER']])] = 'EXEC_VMENU_ENTRY' + except Exception as e: + print(e) else: try: self.menuDict = {} self.currIndex = None self.currMenu = '' - self.active = False 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']])]) del(self.env['bindings'][str([1, ['KEY_LEFT']])]) - del(self.env['bindings'][str([1, ['KEY_RIGHT']])]) - del(self.env['bindings'][str([1, ['KEY_ENTER']])]) + del(self.env['bindings'][str([1, ['KEY_RIGHT']])]) + del(self.env['bindings'][str([1, ['KEY_ENTER']])]) except: - pass - + pass + print(self.env['bindings']) def createMenuTree(self): 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] + menu = self.fs_tree_to_dict( '/home/chrys/Projekte/fenrir/src/fenrirscreenreader/commands/vmenu-profiles/KEY') + if menu: + self.menuDict = menu + if len(self.menuDict) > 0: + self.currIndex = [0] def executeMenu(self): if self.currIndex == None: - return + return def incLevel(self): if self.currIndex == None: - return + return try: r = self.getValueByPath(self.menuDict, self.currIndex +[0]) if not r: @@ -107,7 +115,7 @@ class vmenuManager(): 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 = {d: self.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