initial single press integration

This commit is contained in:
chrys 2016-09-25 15:20:47 +02:00
parent e66d07bec7
commit 47033d9f40
8 changed files with 339 additions and 0 deletions

View File

@ -0,0 +1,35 @@
#!/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

View File

@ -0,0 +1,55 @@
#!/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

View File

@ -0,0 +1,75 @@
#!/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

View File

@ -0,0 +1,42 @@
#!/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

View File

@ -0,0 +1,33 @@
#!/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

View File

@ -0,0 +1,33 @@
#!/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

View File

@ -0,0 +1,33 @@
#!/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

View File

@ -0,0 +1,33 @@
#!/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