do more work

This commit is contained in:
chrys 2019-01-23 00:33:11 +01:00
parent 8285ccaaed
commit 8f658171e2
22 changed files with 450 additions and 25 deletions

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,30 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import datetime
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
# get the time formatted
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
# present the time via speak and braile, there is no soundicon, interrupt the current speech
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,30 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import datetime
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
# get the time formatted
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
# present the time via speak and braile, there is no soundicon, interrupt the current speech
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,21 @@
#!/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):
return 'No description found'
def run(self):
pass
def setCallback(self, callback):
pass

View File

@ -0,0 +1,30 @@
#!/bin/python
# -*- coding: utf-8 -*-
# Fenrir TTY screen reader
# By Chrys, Storm Dragon, and contributers.
from fenrirscreenreader.core import debug
import datetime
class command():
def __init__(self):
pass
def initialize(self, environment):
self.env = environment
def shutdown(self):
pass
def getDescription(self):
return _('presents the date')
def run(self):
dateFormat = self.env['runtime']['settingsManager'].getSetting('general', 'dateFormat')
# get the time formatted
dateString = datetime.datetime.strftime(datetime.datetime.now(), dateFormat)
# present the time via speak and braile, there is no soundicon, interrupt the current speech
self.env['runtime']['outputManager'].presentText(dateString , soundIcon='', interrupt=True)
def setCallback(self, callback):
pass

View File

@ -11,9 +11,8 @@ import os
class vmenuManager():
def __init__(self):
self.menuDict = {}
self.currMenu = {}
self.currIndex = None
self.currLevel = None
self.currMenu = ''
self.active = False
def initialize(self, environment):
self.env = environment
@ -21,54 +20,102 @@ class vmenuManager():
pass
def getActive(self):
return self.active
def togglelMode(self):
self.setActive(not self.getActive())
def setActive(self, active):
def togglelMode(self, currMenu = ''):
self.setActive(not self.getActive(), currMenu)
def setActive(self, active, currMenu = ''):
self.active = active
self.currMenu = currMenu
if active:
self.createHelpDict()
self.createMenuTree()
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'
self.env['bindings'][str([1, ['KEY_LEFT']])] = 'NEXT_HELP'
self.env['bindings'][str([1, ['KEY_RIGHT']])] = 'CURR_HELP'
self.env['bindings'][str([1, ['KEY_ENTER']])] = 'CURR_HELP'
else:
try:
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']])])
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']])])
except:
pass
def createHelpDict(self, section = 'commands'):
self.menuDict = {}
#for command in sorted(self.env['commands'][section].keys()):
# self.menuDict[len(self.menuDict)] = self.getCommandHelpText(command, section)
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
else:
self.currIndex = None
def getHelpForCurrentIndex(self):
def executeMenu(self):
if self.currIndex == None:
return ''
return self.menuDict[self.currIndex]
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:
return
if not isinstance(r, dict):
return
if r == {}:
return
except:
return
self.currIndex.append(0)
def decLevel(self):
if self.currIndex == None:
return
if len(self.currIndex) == 1:
return
self.currIndex.remove(len(self.currIndex) - 1)
def nextIndex(self):
if self.currIndex == None:
return
self.currIndex += 1
if self.currIndex >= len(self.menuDict):
self.currIndex = 0
self.currIndex[len(self.currIndex) - 1] += 1
if self.currIndex[len(self.currIndex) - 1] >= len(self.getNestedByPath(self.menuDict, self.currIndex[:-1])):
self.currIndex[len(self.currIndex) - 1] = 0
def prevIndex(self):
if self.currIndex == None:
return
self.currIndex -= 1
if self.currIndex < 0:
self.currIndex = len(self.menuDict) - 1
if len(self.currIndex) - 1 < self.currLevel:
return
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 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})
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[]
d = complete
for i in path[:-1]:
d = d[list(d.keys())[i]]
return list(d.keys())
def getValueByPath(self, complete, path):
if not isinstance(complete, dict):
return None
d = complete.copy()
for i in path:
d = d[list(d.keys())[i]]
return d
''''
import os
level = [0]
@ -78,11 +125,41 @@ def fs_tree_to_dict( path_):
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})
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')
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)
''''