add initial tutorial menu
This commit is contained in:
parent
11c97cf955
commit
6133f100f8
@ -10,6 +10,9 @@ from array import array
|
||||
import struct
|
||||
import errno
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
|
||||
ttyno = 4
|
||||
tty = open('/dev/tty%d' % ttyno, 'rb')
|
||||
@ -19,7 +22,7 @@ head = vcs.read(4)
|
||||
rows = int(head[0])
|
||||
cols = int(head[1])
|
||||
|
||||
|
||||
s = time.time()
|
||||
GIO_UNIMAP = 0x4B66
|
||||
VT_GETHIFONTMASK = 0x560D
|
||||
himask = array("H", (0,))
|
||||
@ -51,6 +54,7 @@ for u, b in zip(utable[::2], utable[1::2]):
|
||||
|
||||
allText = []
|
||||
allAttrib = []
|
||||
|
||||
for y in range(rows):
|
||||
lineText = ''
|
||||
lineAttrib = []
|
||||
@ -64,13 +68,14 @@ for y in range(rows):
|
||||
lineAttrib.append(attr)
|
||||
ink = attr & 0x0F
|
||||
paper = (attr>>4) & 0x0F
|
||||
if (ink != 7) or (paper != 0):
|
||||
print(ink,paper)
|
||||
#if (ink != 7) or (paper != 0):
|
||||
# print(ink,paper)
|
||||
if sh & hichar:
|
||||
ch |= 0x100
|
||||
lineText += chr(charmap.get(ch, u'?'))
|
||||
allText.append(lineText)
|
||||
allAttrib.append(lineAttrib)
|
||||
|
||||
print(allText)
|
||||
print(allAttrib)
|
||||
#print(allText)
|
||||
#print(allAttrib)
|
||||
print(time.time() -s)
|
||||
|
@ -1,26 +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):
|
||||
self.env['general']['tutorialMode'] = False
|
||||
return _('You are leaving the tutorial mode. Press that shortcut again to enter the tutorial mode again.')
|
||||
|
||||
def run(self):
|
||||
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']['outputManager'].presentText(text, interrupt=True)
|
||||
self.env['general']['tutorialMode'] = True
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
2
src/fenrir/commands/help/Readme.txt
Normal file
2
src/fenrir/commands/help/Readme.txt
Normal file
@ -0,0 +1,2 @@
|
||||
this folder contains help and tutorial related functions.
|
||||
those are not bindable but hard coded.
|
22
src/fenrir/commands/help/curr_help.py
Normal file
22
src/fenrir/commands/help/curr_help.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/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 _('get current help message')
|
||||
def run(self):
|
||||
text = self.env['runtime']['helpManager'].getHelpForCurrentIndex()
|
||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||
def setCallback(self, callback):
|
||||
pass
|
23
src/fenrir/commands/help/next_help.py
Normal file
23
src/fenrir/commands/help/next_help.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/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 _('get next help message')
|
||||
def run(self):
|
||||
self.env['runtime']['helpManager'].nextIndex()
|
||||
text = self.env['runtime']['helpManager'].getHelpForCurrentIndex()
|
||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||
def setCallback(self, callback):
|
||||
pass
|
23
src/fenrir/commands/help/prev_help.py
Normal file
23
src/fenrir/commands/help/prev_help.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/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 _('get prev help message')
|
||||
def run(self):
|
||||
self.env['runtime']['helpManager'].prevIndex()
|
||||
text = self.env['runtime']['helpManager'].getHelpForCurrentIndex()
|
||||
self.env['runtime']['outputManager'].presentText(text, interrupt=True)
|
||||
def setCallback(self, callback):
|
||||
pass
|
29
src/fenrir/commands/help/toggle_tutorial_mode.py
Normal file
29
src/fenrir/commands/help/toggle_tutorial_mode.py
Normal file
@ -0,0 +1,29 @@
|
||||
#!/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):
|
||||
print('TM')
|
||||
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
|
@ -182,19 +182,34 @@ class commandManager():
|
||||
return
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
if self.env['general']['tutorialMode']:
|
||||
if self.env['runtime']['helpManager'].isTutorialMode():
|
||||
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
description = self.env['commands'][section][command].getDescription()
|
||||
description = self.getCommandDescription(section, command)
|
||||
self.env['runtime']['outputManager'].presentText(description, interrupt=True)
|
||||
else:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
self.runCommand(command, section)
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def runCommand(self, command, section = 'commands'):
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
print(command, section)
|
||||
self.env['commands'][section][command].run()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.ERROR)
|
||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command +' ' + str(e),debug.debugLevel.ERROR)
|
||||
self.clearCommandQueued()
|
||||
self.env['commandInfo']['lastCommandExecutionTime'] = time.time()
|
||||
|
||||
def getCommandDescription(self, command, section = 'commands'):
|
||||
if self.commandExists(command, section):
|
||||
try:
|
||||
return self.env['commands'][section][command].getDescription()
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut('commandManager.getCommandDescription:' + str(e),debug.debugLevel.ERROR)
|
||||
|
||||
def isCommandQueued(self):
|
||||
return self.env['commandInfo']['currCommand'] != ''
|
||||
|
||||
|
@ -54,13 +54,16 @@ class fenrirManager():
|
||||
startTime = time.time()
|
||||
if eventReceived:
|
||||
self.prepareCommand()
|
||||
if not (self.wasCommand or self.environment['general']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
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():
|
||||
if self.wasCommand:
|
||||
self.wasCommand = False
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
if self.environment['general']['tutorialMode']:
|
||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
if self.environment['input']['keyForeward'] > 0:
|
||||
self.environment['input']['keyForeward'] -=1
|
||||
|
@ -12,7 +12,7 @@ generalData = {
|
||||
'currUser':'',
|
||||
'prevUser':'',
|
||||
'managerList':['eventManager','punctuationManager','cursorManager','applicationManager','commandManager'
|
||||
,'screenManager','inputManager','outputManager','debug'],
|
||||
,'screenManager','inputManager','outputManager','helpManager','debug'],
|
||||
'commandFolderList':['commands','onInput', 'onCursorChange', 'onScreenUpdate','onScreenChanged','onHeartBeat', 'onPlugInputDevice'
|
||||
,'onApplicationChange','onSwitchApplicationProfile',],
|
||||
,'onApplicationChange','onSwitchApplicationProfile','help',],
|
||||
}
|
||||
|
75
src/fenrir/core/helpManager.py
Executable file
75
src/fenrir/core/helpManager.py
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from core import debug
|
||||
|
||||
|
||||
class helpManager():
|
||||
def __init__(self):
|
||||
self.helpDict = None
|
||||
self.tutorialListIndex = None
|
||||
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
|
||||
def isTutorialMode(self):
|
||||
return self.env['general']['tutorialMode']
|
||||
def getCommandHelpText(self, command, section = 'commands'):
|
||||
commandName = command.lower()
|
||||
commandName = commandName.split('__-__')[0]
|
||||
commandName = commandName.replace('_',' ')
|
||||
commandName = commandName.replace('_',' ')
|
||||
helptext = commandName + ', Shortcut , Description' + self.env['runtime']['commandManager'].getCommandDescription( command, section = 'commands')
|
||||
return helptext
|
||||
def createHelpDict(self, section = 'commands'):
|
||||
self.helpDict = {}
|
||||
for command in sorted(self.env['commands'][section].keys()):
|
||||
self.helpDict[len(self.helpDict)] = self.getCommandHelpText(command, section)
|
||||
if len(self.helpDict) > 0:
|
||||
self.tutorialListIndex = 0
|
||||
def getHelpForCurrentIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return ''
|
||||
return self.helpDict[self.tutorialListIndex]
|
||||
def nextIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return
|
||||
self.tutorialListIndex += 1
|
||||
if self.tutorialListIndex >= len(self.helpDict):
|
||||
self.tutorialListIndex = 0
|
||||
def prevIndex(self):
|
||||
if self.tutorialListIndex == None:
|
||||
return
|
||||
self.tutorialListIndex -= 1
|
||||
if self.tutorialListIndex < 0:
|
||||
self.tutorialListIndex = len(self.helpDict) - 1
|
||||
def handleTutorialMode(self):
|
||||
if self.env['runtime']['inputManager'].noKeyPressed():
|
||||
return
|
||||
if self.env['input']['currInput'] in [['KEY_F1', 'KEY_FENRIR']]:
|
||||
self.env['runtime']['commandManager'].runCommand('TOGGLE_TUTORIAL_MODE', 'help')
|
||||
return True
|
||||
if not self.isTutorialMode():
|
||||
return
|
||||
if self.env['input']['currInput'] in [['KEY_ESC']]:
|
||||
self.env['runtime']['commandManager'].runCommand('TOGGLE_TUTORIAL_MODE', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_UP']]:
|
||||
self.env['runtime']['commandManager'].runCommand('PREV_HELP', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_DOWN']]:
|
||||
self.env['runtime']['commandManager'].runCommand('NEXT_HELP', 'help')
|
||||
return True
|
||||
if self.env['input']['currInput'] in [['KEY_SPACE']]:
|
||||
self.env['runtime']['commandManager'].runCommand('CURR_HELP', 'help')
|
||||
return True
|
||||
return False
|
@ -15,6 +15,7 @@ from core import screenManager
|
||||
from core import punctuationManager
|
||||
from core import cursorManager
|
||||
from core import applicationManager
|
||||
from core import helpManager
|
||||
from core import environment
|
||||
from core import inputData
|
||||
from core.settingsData import settingsData
|
||||
@ -328,7 +329,8 @@ class settingsManager():
|
||||
environment['runtime']['cursorManager'].initialize(environment)
|
||||
environment['runtime']['applicationManager'] = applicationManager.applicationManager()
|
||||
environment['runtime']['applicationManager'].initialize(environment)
|
||||
|
||||
environment['runtime']['helpManager'] = helpManager.helpManager()
|
||||
environment['runtime']['helpManager'].initialize(environment)
|
||||
if environment['runtime']['screenManager'] == None:
|
||||
environment['runtime']['screenManager'] = screenManager.screenManager()
|
||||
environment['runtime']['screenManager'].initialize(environment)
|
||||
|
Loading…
Reference in New Issue
Block a user