add keyecho to tutorial mode
This commit is contained in:
parent
49c9645b8a
commit
da8e28540e
23
src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py
Normal file
23
src/fenrirscreenreader/commands/onKeyInput/81000-key_echo.py
Normal file
@ -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):
|
||||
return 'No description found'
|
||||
def run(self):
|
||||
if self.env['runtime']['helpManager'].isTutorialMode():
|
||||
self.env['runtime']['inputManager'].keyEcho(event)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
@ -37,14 +37,11 @@ class commandManager():
|
||||
return None
|
||||
if not os.path.exists(filepath):
|
||||
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not exists:" + filepath ,debug.debugLevel.WARNING)
|
||||
print('1')
|
||||
return None
|
||||
if os.path.isdir(filepath):
|
||||
print('2')
|
||||
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath is a directory:" + filepath ,debug.debugLevel.ERROR)
|
||||
return None
|
||||
if not os.access(filepath, os.R_OK):
|
||||
print('3')
|
||||
self.env['runtime']['debug'].writeDebugOut("loadFile: filepath not readable:" + filepath ,debug.debugLevel.ERROR)
|
||||
return None
|
||||
|
||||
@ -218,7 +215,7 @@ class commandManager():
|
||||
if self.env['runtime']['helpManager'].isTutorialMode() and section != 'help':
|
||||
self.env['runtime']['debug'].writeDebugOut("Tutorial for command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
description = self.getCommandDescription(command, section)
|
||||
self.env['runtime']['outputManager'].presentText(description, interrupt=True)
|
||||
self.env['runtime']['outputManager'].presentText(description, interrupt=False)
|
||||
else:
|
||||
self.env['runtime']['debug'].writeDebugOut("Executing command:" + section + "." + command ,debug.debugLevel.INFO)
|
||||
self.runCommand(command, section)
|
||||
|
@ -68,6 +68,8 @@ class fenrirManager():
|
||||
else:
|
||||
if self.environment['runtime']['helpManager'].isTutorialMode():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
self.environment['runtime']['inputManager'].keyEcho(event['Data'])
|
||||
|
||||
if self.environment['runtime']['vmenuManager'].getActive():
|
||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||
|
||||
|
@ -33,6 +33,7 @@ class inputManager():
|
||||
self.env['input']['newScrollLock'] = self.env['runtime']['inputDriver'].getLedState(2)
|
||||
self.env['input']['oldScrollLock'] = self.env['input']['newScrollLock']
|
||||
self.lastDeepestInput = []
|
||||
self.lastEvent = None
|
||||
self.env['input']['shortcutRepeat'] = 1
|
||||
self.lastInputTime = time.time()
|
||||
def shutdown(self):
|
||||
@ -79,10 +80,12 @@ class inputManager():
|
||||
time.sleep(value)
|
||||
else:
|
||||
self.env['runtime']['inputDriver'].sendKey(key, value)
|
||||
def getLastEvent(self):
|
||||
return self.lastEvent
|
||||
def handleInputEvent(self, eventData):
|
||||
#print(eventData)
|
||||
if not eventData:
|
||||
return
|
||||
self.lastEvent = eventData
|
||||
# a hang apears.. try to fix
|
||||
if self.env['input']['eventBuffer'] == []:
|
||||
if self.env['input']['currInput'] != []:
|
||||
@ -265,6 +268,18 @@ class inputManager():
|
||||
if not self.shortcutExists(shortcut):
|
||||
return ''
|
||||
return self.env['bindings'][shortcut]
|
||||
def keyEcho(self, eventData = None):
|
||||
if not eventData:
|
||||
eventData = self.env['runtime']['inputManager'].getLastEvent()
|
||||
if not eventData:
|
||||
return
|
||||
keyName = ''
|
||||
if eventData['EventState'] == 1:
|
||||
keyName = eventData['EventName'].lower()
|
||||
if keyName.startswith('key_'):
|
||||
keyName = keyName[4:]
|
||||
self.env['runtime']['outputManager'].presentText(_(keyName), interrupt=True)
|
||||
|
||||
|
||||
def shortcutExists(self, shortcut):
|
||||
return(shortcut in self.env['bindings'])
|
||||
|
Loading…
Reference in New Issue
Block a user