initial single press integration
This commit is contained in:
parent
a880368f7e
commit
e66d07bec7
@ -69,7 +69,7 @@ layout=en
|
|||||||
driver=linux
|
driver=linux
|
||||||
encoding=cp850
|
encoding=cp850
|
||||||
screenUpdateDelay=0.4
|
screenUpdateDelay=0.4
|
||||||
suspendingScreen=1,2
|
suspendingScreen=
|
||||||
autodetectSuspendingScreen=False
|
autodetectSuspendingScreen=False
|
||||||
|
|
||||||
[keyboard]
|
[keyboard]
|
||||||
@ -79,13 +79,13 @@ device=all
|
|||||||
grabDevices=True
|
grabDevices=True
|
||||||
ignoreShortcuts=False
|
ignoreShortcuts=False
|
||||||
# the current shortcut layout located in /etc/fenrir/keyboard
|
# the current shortcut layout located in /etc/fenrir/keyboard
|
||||||
keyboardLayout=desktop
|
keyboardLayout=test
|
||||||
# echo chars while typing.
|
# echo chars while typing.
|
||||||
charEcho=False
|
charEcho=True
|
||||||
# echo deleted chars
|
# echo deleted chars
|
||||||
charDeleteEcho=True
|
charDeleteEcho=True
|
||||||
# echo word after pressing space
|
# echo word after pressing space
|
||||||
wordEcho=False
|
wordEcho=True
|
||||||
# interrupt speech on any keypress
|
# interrupt speech on any keypress
|
||||||
interruptOnKeyPress=False
|
interruptOnKeyPress=False
|
||||||
# timeout for double tap in sec
|
# timeout for double tap in sec
|
||||||
|
@ -1,35 +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):
|
|
||||||
return 'No Description found'
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charEcho'):
|
|
||||||
return
|
|
||||||
# detect deletion or chilling
|
|
||||||
if self.env['screenData']['newCursor']['x'] <= self.env['screenData']['oldCursor']['x']:
|
|
||||||
return
|
|
||||||
# is there any change?
|
|
||||||
if self.env['screenData']['newDelta'] == '':
|
|
||||||
return
|
|
||||||
# big changes are no char (but the value is bigger than one maybe the differ needs longer than you can type, so a little strange random buffer for now)
|
|
||||||
if len(self.env['screenData']['newDelta']) > 3:
|
|
||||||
return
|
|
||||||
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newDelta'], interrupt=True, ignorePunctuation=True)
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
||||||
|
|
@ -1,55 +0,0 @@
|
|||||||
#!/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Fenrir TTY screen reader
|
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
|
||||||
|
|
||||||
from core import debug
|
|
||||||
from utils import word_utils
|
|
||||||
|
|
||||||
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 not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
|
|
||||||
return
|
|
||||||
|
|
||||||
# just when cursor move worddetection is needed
|
|
||||||
if self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
|
|
||||||
return
|
|
||||||
|
|
||||||
# for now no new line
|
|
||||||
if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y']:
|
|
||||||
return
|
|
||||||
if len(self.env['screenData']['newDelta']) > 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
# first place could not be the end of a word
|
|
||||||
if self.env['screenData']['newCursor']['x'] == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
# get the word
|
|
||||||
newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
|
|
||||||
x, y, currWord = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)
|
|
||||||
# was this a typed word?
|
|
||||||
if self.env['screenData']['newDelta'] != '':
|
|
||||||
if not(newContent[self.env['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['oldCursor']['x']):
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
# or just arrow arround?
|
|
||||||
if not(newContent[self.env['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['newCursor']['x']):
|
|
||||||
return
|
|
||||||
|
|
||||||
if currWord != '':
|
|
||||||
self.env['runtime']['outputManager'].presentText(currWord, interrupt=True)
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
#!/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
# Fenrir TTY screen reader
|
|
||||||
# By Chrys, Storm Dragon, and contributers.
|
|
||||||
|
|
||||||
from core import debug
|
|
||||||
from utils import word_utils
|
|
||||||
initialized = False
|
|
||||||
try:
|
|
||||||
import enchant
|
|
||||||
initialized = True
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
class command():
|
|
||||||
def __init__(self):
|
|
||||||
self.language = ''
|
|
||||||
self.spellChecker = ''
|
|
||||||
def initialize(self, environment):
|
|
||||||
self.env = environment
|
|
||||||
self.updateSpellLanguage()
|
|
||||||
def shutdown(self):
|
|
||||||
pass
|
|
||||||
def getDescription(self):
|
|
||||||
return 'No Description found'
|
|
||||||
|
|
||||||
def updateSpellLanguage(self):
|
|
||||||
self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
|
|
||||||
self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
|
|
||||||
return
|
|
||||||
|
|
||||||
if not initialized:
|
|
||||||
return
|
|
||||||
if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
|
|
||||||
try:
|
|
||||||
self.updateSpellLanguage()
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
|
|
||||||
# just when cursor move worddetection is needed
|
|
||||||
if self.env['screenData']['newCursor']['x'] == self.env['screenData']['oldCursor']['x']:
|
|
||||||
return
|
|
||||||
|
|
||||||
# for now no new line
|
|
||||||
if self.env['screenData']['newCursor']['y'] != self.env['screenData']['oldCursor']['y']:
|
|
||||||
return
|
|
||||||
if len(self.env['screenData']['newDelta']) > 1:
|
|
||||||
return
|
|
||||||
|
|
||||||
# first place could not be the end of a word
|
|
||||||
if self.env['screenData']['newCursor']['x'] == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
# get the word
|
|
||||||
newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
|
|
||||||
x, y, currWord = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)
|
|
||||||
# was this a typed word?
|
|
||||||
if self.env['screenData']['newDelta'] != '':
|
|
||||||
if not(newContent[self.env['screenData']['oldCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['oldCursor']['x']):
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
# or just arrow arround?
|
|
||||||
if not(newContent[self.env['screenData']['newCursor']['x']].strip(" \t\n") == '' and x != self.env['screenData']['newCursor']['x']):
|
|
||||||
return
|
|
||||||
|
|
||||||
if currWord != '':
|
|
||||||
if not self.spellChecker.check(currWord):
|
|
||||||
self.env['runtime']['outputManager'].presentText('misspelled',soundIcon='mispell', interrupt=True)
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
@ -1,42 +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):
|
|
||||||
return 'No Description found'
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
|
|
||||||
return
|
|
||||||
|
|
||||||
# detect typing or chilling
|
|
||||||
if self.env['screenData']['newCursor']['x'] >= self.env['screenData']['oldCursor']['x']:
|
|
||||||
return
|
|
||||||
|
|
||||||
# More than just a deletion happend
|
|
||||||
if self.env['screenData']['newDelta'].strip() != '':
|
|
||||||
if self.env['screenData']['newDelta'] != self.env['screenData']['oldDelta']:
|
|
||||||
return
|
|
||||||
|
|
||||||
# No deletion
|
|
||||||
if self.env['screenData']['newNegativeDelta'] == '':
|
|
||||||
return
|
|
||||||
# too much for a single backspace...
|
|
||||||
if len(self.env['screenData']['newNegativeDelta']) >= 5:
|
|
||||||
return
|
|
||||||
self.env['runtime']['outputManager'].presentText(self.env['screenData']['newNegativeDelta'], interrupt=True, ignorePunctuation=True)
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
||||||
|
|
@ -1,33 +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):
|
|
||||||
return 'No description found'
|
|
||||||
def load(self):
|
|
||||||
print('--------------')
|
|
||||||
print('agetty')
|
|
||||||
print('load old',self.env['screenData']['oldApplication'])
|
|
||||||
print('load new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def unload(self):
|
|
||||||
print('--------------')
|
|
||||||
print('agetty')
|
|
||||||
print('unload old',self.env['screenData']['oldApplication'])
|
|
||||||
print('unload new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
@ -1,33 +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):
|
|
||||||
return 'No description found'
|
|
||||||
def load(self):
|
|
||||||
print('--------------')
|
|
||||||
print('bash')
|
|
||||||
print('load old',self.env['screenData']['oldApplication'])
|
|
||||||
print('load new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def unload(self):
|
|
||||||
print('--------------')
|
|
||||||
print('bash')
|
|
||||||
print('unload old',self.env['screenData']['oldApplication'])
|
|
||||||
print('unload new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
@ -1,33 +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):
|
|
||||||
return 'No description found'
|
|
||||||
def load(self):
|
|
||||||
print('--------------')
|
|
||||||
print('default')
|
|
||||||
print('load old',self.env['screenData']['oldApplication'])
|
|
||||||
print('load new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def unload(self):
|
|
||||||
print('--------------')
|
|
||||||
print('default')
|
|
||||||
print('unload old',self.env['screenData']['oldApplication'])
|
|
||||||
print('unload new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
@ -1,33 +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):
|
|
||||||
return 'No description found'
|
|
||||||
def load(self):
|
|
||||||
print('--------------')
|
|
||||||
print('vim')
|
|
||||||
print('load old',self.env['screenData']['oldApplication'])
|
|
||||||
print('load new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def unload(self):
|
|
||||||
print('--------------')
|
|
||||||
print('vim')
|
|
||||||
print('unload old',self.env['screenData']['oldApplication'])
|
|
||||||
print('unload new',self.env['screenData']['newApplication'])
|
|
||||||
print('--------------')
|
|
||||||
|
|
||||||
def setCallback(self, callback):
|
|
||||||
pass
|
|
@ -14,7 +14,6 @@ class applicationManager():
|
|||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
pass
|
pass
|
||||||
def getCurrentApplication(self):
|
def getCurrentApplication(self):
|
||||||
print(self.env['screenData']['newApplication'])
|
|
||||||
currApp = self.env['screenData']['newApplication'].upper()
|
currApp = self.env['screenData']['newApplication'].upper()
|
||||||
if not currApp:
|
if not currApp:
|
||||||
currApp == 'DEFAULT'
|
currApp == 'DEFAULT'
|
||||||
|
@ -23,7 +23,7 @@ class fenrir():
|
|||||||
self.environment['runtime']['outputManager'].presentText("Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
|
self.environment['runtime']['outputManager'].presentText("Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
|
||||||
signal.signal(signal.SIGINT, self.captureSignal)
|
signal.signal(signal.SIGINT, self.captureSignal)
|
||||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||||
|
self.wasCommand = False
|
||||||
def proceed(self):
|
def proceed(self):
|
||||||
while(self.environment['generalInformation']['running']):
|
while(self.environment['generalInformation']['running']):
|
||||||
try:
|
try:
|
||||||
@ -35,27 +35,30 @@ class fenrir():
|
|||||||
|
|
||||||
def handleProcess(self):
|
def handleProcess(self):
|
||||||
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
|
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
|
||||||
|
|
||||||
if eventReceived:
|
if eventReceived:
|
||||||
self.prepareCommand()
|
self.prepareCommand()
|
||||||
if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
#if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
||||||
self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
# self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
||||||
not self.environment['runtime']['commandManager'].isCommandQueued():
|
# not self.environment['runtime']['commandManager'].isCommandQueued():
|
||||||
|
if not self.wasCommand:
|
||||||
self.environment['runtime']['inputManager'].writeEventBuffer()
|
self.environment['runtime']['inputManager'].writeEventBuffer()
|
||||||
elif self.environment['runtime']['inputManager'].noKeyPressed():
|
if self.wasCommand:
|
||||||
|
if not self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
|
self.wasCommand = False
|
||||||
self.environment['runtime']['inputManager'].clearEventBuffer()
|
self.environment['runtime']['inputManager'].clearEventBuffer()
|
||||||
|
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||||
try:
|
self.environment['runtime']['screenManager'].update()
|
||||||
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||||
|
else:
|
||||||
self.environment['runtime']['screenManager'].update()
|
self.environment['runtime']['screenManager'].update()
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
self.environment['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
|
||||||
|
|
||||||
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
if self.environment['runtime']['applicationManager'].isApplicationChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||||
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
||||||
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
||||||
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
|
||||||
if self.environment['runtime']['screenManager'].isScreenChange():
|
if self.environment['runtime']['screenManager'].isScreenChange():
|
||||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
|
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
|
||||||
else:
|
else:
|
||||||
@ -69,6 +72,7 @@ class fenrir():
|
|||||||
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
||||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
||||||
self.environment['runtime']['commandManager'].queueCommand(command)
|
self.environment['runtime']['commandManager'].queueCommand(command)
|
||||||
|
self.wasCommand = command != ''
|
||||||
|
|
||||||
def handleCommands(self):
|
def handleCommands(self):
|
||||||
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
|
if time.time() - self.environment['commandInfo']['lastCommandExecutionTime'] < 0.2:
|
||||||
|
@ -145,4 +145,3 @@ class driver():
|
|||||||
|
|
||||||
self.env['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ '))
|
self.env['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ '))
|
||||||
self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- '))
|
self.env['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- '))
|
||||||
print(self.env['screenData']['newDelta'])
|
|
||||||
|
Loading…
Reference in New Issue
Block a user