add remote bits

This commit is contained in:
chrys 2019-02-04 23:11:45 +01:00
parent f0da503a96
commit 5d168d232a
2 changed files with 26 additions and 56 deletions

View File

@ -35,6 +35,8 @@ class remoteManager():
# command controll # command controll
self.commandConst = 'COMMAND ' self.commandConst = 'COMMAND '
self.sayConst = 'SAY ' self.sayConst = 'SAY '
self.vmenuConst = 'VMENU '
self.resetVmenuConst = 'RESETVMENU'
self.interruptConst = 'INTERRUPT' self.interruptConst = 'INTERRUPT'
self.defineWindowConst = 'WINDOW ' self.defineWindowConst = 'WINDOW '
self.resetWindowConst = 'RESETWINDOW' self.resetWindowConst = 'RESETWINDOW'
@ -80,6 +82,13 @@ class remoteManager():
# interrupt # interrupt
if upperCommandText.startswith(self.interruptConst): if upperCommandText.startswith(self.interruptConst):
self.interruptSpeech() self.interruptSpeech()
# set vmenu
if upperCommandText.startswith(self.vmenuConst):
parameterText = commandText[len(self.vmenuConst):]
self.setVMenu(parameterText)
# reset vmenu
if upperCommandText.startswith(self.resetVmenuConst):
self.resetVMenu()
# define window # define window
if upperCommandText.startswith(self.defineWindowConst): if upperCommandText.startswith(self.defineWindowConst):
parameterText = commandText[len(self.defineWindowConst):] parameterText = commandText[len(self.defineWindowConst):]
@ -91,6 +100,10 @@ class remoteManager():
if upperCommandText.startswith(self.setClipboardConst): if upperCommandText.startswith(self.setClipboardConst):
parameterText = commandText[len(self.setClipboardConst):] parameterText = commandText[len(self.setClipboardConst):]
self.setClipboard(parameterText) self.setClipboard(parameterText)
def setVMenu(self, vmenu = ''):
self.env['runtime']['vmenuManager'].setCurrMenu(vmenu)
def resetVMenu(self):
self.env['runtime']['vmenuManager'].setCurrMenu()
def setClipboard(self, text = ''): def setClipboard(self, text = ''):
self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', text) self.env['runtime']['memoryManager'].addValueToFirstIndex('clipboardHistory', text)
def defineWindow(self, windowText): def defineWindow(self, windowText):

View File

@ -27,17 +27,22 @@ class vmenuManager():
def setCurrMenu(self, currMenu = ''): def setCurrMenu(self, currMenu = ''):
self.currIndex = None self.currIndex = None
self.currMenu = '' self.currMenu = ''
currIndex = None
if currMenu != '': if currMenu != '':
currMenu += ' ' + _('Menu')
try: try:
t = self.menuDict[currMenu] t = self.menuDict[currMenu]
l = list(menuDict.keys()) l = list(self.menuDict.keys())
currIndex = [l.index(currMenu)] self.currIndex = [l.index(currMenu)]
except: except Exception as e:
print(e)
self.currMenu = ''
self.currIndex = None
return return
if self.incLevel(): if self.incLevel():
self.currIndex = currIndex
self.currMenu = currMenu self.currMenu = currMenu
else:
self.currMenu = ''
self.currIndex = None
def getCurrMenu(self): def getCurrMenu(self):
return self.currMenu return self.currMenu
def getActive(self): def getActive(self):
@ -54,6 +59,9 @@ class vmenuManager():
try: try:
if self.currMenu != '': if self.currMenu != '':
self.setCurrMenu(self.currMenu) self.setCurrMenu(self.currMenu)
if self.currIndex == None:
if len(self.menuDict) > 0:
self.currIndex = [0]
except Exception as e: except Exception as e:
print(e) print(e)
try: try:
@ -83,8 +91,6 @@ class vmenuManager():
menu = self.fs_tree_to_dict( self.defaultVMenuPath) menu = self.fs_tree_to_dict( self.defaultVMenuPath)
if menu: if menu:
self.menuDict = menu self.menuDict = menu
if len(self.menuDict) > 0:
self.currIndex = [0]
def executeMenu(self): def executeMenu(self):
if self.currIndex == None: if self.currIndex == None:
return return
@ -105,7 +111,6 @@ class vmenuManager():
return False return False
try: try:
r = self.getValueByPath(self.menuDict, self.currIndex +[0]) r = self.getValueByPath(self.menuDict, self.currIndex +[0])
print(r)
if r == {}: if r == {}:
return False return False
except: except:
@ -141,7 +146,6 @@ class vmenuManager():
return True return True
def getCurrentEntry(self): def getCurrentEntry(self):
print( self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]])
return self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]] return self.getKeysByPath(self.menuDict, self.currIndex)[self.currIndex[-1]]
def fs_tree_to_dict(self, path_): def fs_tree_to_dict(self, path_):
for root, dirs, files in os.walk(path_): for root, dirs, files in os.walk(path_):
@ -182,50 +186,3 @@ class vmenuManager():
for i in path: for i in path:
d = d[list(d.keys())[i]] d = d[list(d.keys())[i]]
return d return d
'''
import os
level = [0]
def fs_tree_to_dict( path_):
file_token = ''
for root, dirs, files in os.walk(path_):
tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs}
print(files, root, dirs)
tree.update({f: root + '/' + f for f in files})
return tree # note we discontinue iteration trough os.walk
v = fs_tree_to_dict( '/home/chrys/Projekte/fenrir/src/fenrirscreenreader/commands/vmenu/KEY')
def getNestedByPath(complete, path):
path = path.copy()
if path != []:
index = list(complete.keys())[path[0]]
path.remove(0)
nested = getNestedByPath(complete[index], path)
return nested
else:
return complete
def getKeysByPath(complete, path):
d = complete
for i in path[:-1]:
d = d[list(d.keys())[i]]
return list(d.keys())
def getValueByPath(complete, path):
d = complete
for i in path:
d = d[list(d.keys())[i]]
return d
c = [0,0,0]
getKeysByPath(v,c)
getValueByPath(v,c)
'''