initial single press integration
This commit is contained in:
parent
a880368f7e
commit
e66d07bec7
@ -69,7 +69,7 @@ layout=en
|
||||
driver=linux
|
||||
encoding=cp850
|
||||
screenUpdateDelay=0.4
|
||||
suspendingScreen=1,2
|
||||
suspendingScreen=
|
||||
autodetectSuspendingScreen=False
|
||||
|
||||
[keyboard]
|
||||
@ -79,13 +79,13 @@ device=all
|
||||
grabDevices=True
|
||||
ignoreShortcuts=False
|
||||
# the current shortcut layout located in /etc/fenrir/keyboard
|
||||
keyboardLayout=desktop
|
||||
keyboardLayout=test
|
||||
# echo chars while typing.
|
||||
charEcho=False
|
||||
charEcho=True
|
||||
# echo deleted chars
|
||||
charDeleteEcho=True
|
||||
# echo word after pressing space
|
||||
wordEcho=False
|
||||
wordEcho=True
|
||||
# interrupt speech on any keypress
|
||||
interruptOnKeyPress=False
|
||||
# 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):
|
||||
pass
|
||||
def getCurrentApplication(self):
|
||||
print(self.env['screenData']['newApplication'])
|
||||
currApp = self.env['screenData']['newApplication'].upper()
|
||||
if not currApp:
|
||||
currApp == 'DEFAULT'
|
||||
|
@ -23,7 +23,7 @@ class fenrir():
|
||||
self.environment['runtime']['outputManager'].presentText("Start Fenrir", soundIcon='ScreenReaderOn', interrupt=True)
|
||||
signal.signal(signal.SIGINT, self.captureSignal)
|
||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||
|
||||
self.wasCommand = False
|
||||
def proceed(self):
|
||||
while(self.environment['generalInformation']['running']):
|
||||
try:
|
||||
@ -35,27 +35,30 @@ class fenrir():
|
||||
|
||||
def handleProcess(self):
|
||||
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
|
||||
|
||||
if eventReceived:
|
||||
self.prepareCommand()
|
||||
if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
||||
self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
||||
not self.environment['runtime']['commandManager'].isCommandQueued():
|
||||
#if not (self.environment['runtime']['inputManager'].isConsumeInput() or \
|
||||
# self.environment['runtime']['inputManager'].isFenrirKeyPressed()) and \
|
||||
# not self.environment['runtime']['commandManager'].isCommandQueued():
|
||||
if not self.wasCommand:
|
||||
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()
|
||||
|
||||
try:
|
||||
if self.environment['runtime']['inputManager'].noKeyPressed():
|
||||
self.environment['runtime']['screenManager'].update()
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||
else:
|
||||
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():
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onApplicationChange')
|
||||
self.environment['runtime']['commandManager'].executeSwitchTrigger('onSwitchApplicationProfile', \
|
||||
self.environment['runtime']['applicationManager'].getPrevApplication(), \
|
||||
self.environment['runtime']['applicationManager'].getCurrentApplication())
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onInput')
|
||||
|
||||
if self.environment['runtime']['screenManager'].isScreenChange():
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenChanged')
|
||||
else:
|
||||
@ -69,6 +72,7 @@ class fenrir():
|
||||
shortcut = self.environment['runtime']['inputManager'].getCurrShortcut()
|
||||
command = self.environment['runtime']['inputManager'].getCommandForShortcut(shortcut)
|
||||
self.environment['runtime']['commandManager'].queueCommand(command)
|
||||
self.wasCommand = command != ''
|
||||
|
||||
def handleCommands(self):
|
||||
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']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- '))
|
||||
print(self.env['screenData']['newDelta'])
|
||||
|
Loading…
Reference in New Issue
Block a user