To make Fenrir easier to approach for new developer, start code migration to be pep8 compliant.
This commit is contained in:
@ -5,19 +5,26 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
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):
|
||||
# enabled?
|
||||
active = self.env['runtime']['settingsManager'].getSettingAsInt('keyboard', 'charEchoMode')
|
||||
# enabled?
|
||||
active = self.env['runtime']['settingsManager'].getSettingAsInt(
|
||||
'keyboard', 'charEchoMode')
|
||||
# 0 = off
|
||||
if active == 0:
|
||||
return
|
||||
@ -25,17 +32,23 @@ class command():
|
||||
if active == 2:
|
||||
if not self.env['input']['newCapsLock']:
|
||||
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)
|
||||
xMove = abs(self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'])
|
||||
# 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)
|
||||
xMove = abs(
|
||||
self.env['screen']['newCursor']['x'] -
|
||||
self.env['screen']['oldCursor']['x'])
|
||||
if xMove > 3:
|
||||
return
|
||||
if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']:
|
||||
if self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_TAB']]:
|
||||
return
|
||||
if self.env['runtime']['inputManager'].getLastDeepestInput() in [
|
||||
['KEY_TAB']]:
|
||||
return
|
||||
elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']:
|
||||
if self.env['runtime']['byteManager'].getLastByteKey() in [b' ', b'\t']:
|
||||
return
|
||||
# detect deletion or chilling
|
||||
if self.env['runtime']['byteManager'].getLastByteKey() in [
|
||||
b' ', b'\t']:
|
||||
return
|
||||
# detect deletion or chilling
|
||||
if self.env['screen']['newCursor']['x'] <= self.env['screen']['oldCursor']['x']:
|
||||
return
|
||||
# is there any change?
|
||||
@ -44,10 +57,14 @@ class command():
|
||||
# filter unneded space on word begin
|
||||
currDelta = self.env['screen']['newDelta']
|
||||
if len(currDelta.strip()) != len(currDelta) and \
|
||||
currDelta.strip() != '':
|
||||
currDelta.strip() != '':
|
||||
currDelta = currDelta.strip()
|
||||
self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currDelta,
|
||||
interrupt=True,
|
||||
ignorePunctuation=True,
|
||||
announceCapital=True,
|
||||
flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,25 +4,33 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import string
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return 'No Description found'
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'keyboard', 'wordEcho'):
|
||||
return
|
||||
# is naviation?
|
||||
if self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] != 1:
|
||||
if self.env['screen']['newCursor']['x'] - \
|
||||
self.env['screen']['oldCursor']['x'] != 1:
|
||||
return
|
||||
# just when cursor move worddetection is needed
|
||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
||||
@ -32,26 +40,29 @@ class command():
|
||||
return
|
||||
# currently writing
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = \
|
||||
word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# is there a word?
|
||||
return
|
||||
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split(
|
||||
'\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(
|
||||
self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# is there a word?
|
||||
if currWord == '':
|
||||
return
|
||||
# at the end of a word
|
||||
# at the end of a word
|
||||
if not newContent[self.env['screen']['newCursor']['x']].isspace():
|
||||
return
|
||||
# at the end of a word
|
||||
if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \
|
||||
(x + len(currWord) != self.env['screen']['newCursor']['x']-1):
|
||||
return
|
||||
# at the end of a word
|
||||
if (x +
|
||||
len(currWord) != self.env['screen']['newCursor']['x']) and (x +
|
||||
len(currWord) != self.env['screen']['newCursor']['x'] -
|
||||
1):
|
||||
return
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currWord, interrupt=True, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,8 +4,11 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import os, string
|
||||
import os
|
||||
import string
|
||||
|
||||
initialized = False
|
||||
try:
|
||||
@ -13,31 +16,40 @@ try:
|
||||
initialized = True
|
||||
except Exception as e:
|
||||
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):
|
||||
|
||||
def updateSpellLanguage(self):
|
||||
if not initialized:
|
||||
return
|
||||
self.spellChecker = enchant.Dict(self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage'))
|
||||
self.language = self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage')
|
||||
return
|
||||
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 initialized:
|
||||
return
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
|
||||
return
|
||||
if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'general', 'autoSpellCheck'):
|
||||
return
|
||||
if self.env['runtime']['settingsManager'].getSetting(
|
||||
'general', 'spellCheckLanguage') != self.language:
|
||||
try:
|
||||
self.updateSpellLanguage()
|
||||
except Exception as e:
|
||||
@ -46,87 +58,118 @@ class command():
|
||||
# just when horizontal cursor move worddetection is needed
|
||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
||||
return
|
||||
|
||||
|
||||
# for now no new line
|
||||
if self.env['runtime']['cursorManager'].isCursorVerticalMove():
|
||||
return
|
||||
# more than a keyecho?
|
||||
if len(self.env['screen']['newDelta']) > 1:
|
||||
return
|
||||
return
|
||||
# deletion
|
||||
if self.env['runtime']['screenManager'].isNegativeDelta():
|
||||
return
|
||||
return
|
||||
# first place could not be the end of a word
|
||||
if self.env['screen']['newCursor']['x'] == 0:
|
||||
return
|
||||
|
||||
|
||||
# get the word (just for speedup only look at current line
|
||||
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
newContent = self.env['screen']['newContentText'].split(
|
||||
'\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(
|
||||
self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
# was this a typed word?
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
if not(newContent[self.env['screen']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']):
|
||||
if not (newContent[self.env['screen']['oldCursor']['x']] in string.whitespace +
|
||||
'!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']):
|
||||
return
|
||||
else:
|
||||
currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~')
|
||||
currWord = currWord.strip(
|
||||
string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~')
|
||||
else:
|
||||
# or just arrow arround?
|
||||
# or just arrow arround?
|
||||
if not newContent[self.env['screen']['newCursor']['x']].isspace():
|
||||
return
|
||||
if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \
|
||||
(x + len(currWord) != self.env['screen']['newCursor']['x']-1):
|
||||
return
|
||||
if (x +
|
||||
len(currWord) != self.env['screen']['newCursor']['x']) and (x +
|
||||
len(currWord) != self.env['screen']['newCursor']['x'] -
|
||||
1):
|
||||
return
|
||||
|
||||
# just on end of word
|
||||
if self.env['screen']['newCursor']['x'] > 0:
|
||||
if not newContent[self.env['screen']['oldCursor']['x'] - 1].lower() in string.ascii_lowercase:
|
||||
if not newContent[self.env['screen']['oldCursor']
|
||||
['x'] - 1].lower() in string.ascii_lowercase:
|
||||
return
|
||||
|
||||
|
||||
# ignore bash buildins
|
||||
if currWord in ['cd','fg','bg','alias','bind','dir','caller','buildin','command','declare','echo','enable','help','let','local','logout',\
|
||||
'mapfile','printf','read','readarray','source','type','typeset','ulimit','unalias']:
|
||||
if currWord in [
|
||||
'cd',
|
||||
'fg',
|
||||
'bg',
|
||||
'alias',
|
||||
'bind',
|
||||
'dir',
|
||||
'caller',
|
||||
'buildin',
|
||||
'command',
|
||||
'declare',
|
||||
'echo',
|
||||
'enable',
|
||||
'help',
|
||||
'let',
|
||||
'local',
|
||||
'logout',
|
||||
'mapfile',
|
||||
'printf',
|
||||
'read',
|
||||
'readarray',
|
||||
'source',
|
||||
'type',
|
||||
'typeset',
|
||||
'ulimit',
|
||||
'unalias']:
|
||||
return
|
||||
# ignore the application name
|
||||
if currWord.upper() == 'FENRIR':
|
||||
return
|
||||
if currWord[0] =='-':
|
||||
return
|
||||
if currWord[0] == '-':
|
||||
return
|
||||
if currWord[0] == '/':
|
||||
return
|
||||
if currWord[0] == '#':
|
||||
return
|
||||
if currWord.startswith('./'):
|
||||
return
|
||||
return
|
||||
if '@' in currWord and '.' in currWord:
|
||||
return
|
||||
return
|
||||
if currWord[0] == '@':
|
||||
return
|
||||
return
|
||||
if currWord.isnumeric():
|
||||
return
|
||||
return
|
||||
if currWord.isdecimal():
|
||||
return
|
||||
if currWord.isspace():
|
||||
return
|
||||
|
||||
|
||||
try:
|
||||
if os.path.exists("/bin/"+currWord):
|
||||
if os.path.exists("/bin/" + currWord):
|
||||
return
|
||||
except Exception as e:
|
||||
pass
|
||||
try:
|
||||
if os.path.exists("/usr/bin/"+currWord):
|
||||
return
|
||||
if os.path.exists("/usr/bin/" + currWord):
|
||||
return
|
||||
except Exception as e:
|
||||
pass
|
||||
try:
|
||||
if os.path.exists("/sbin/"+currWord):
|
||||
return
|
||||
if os.path.exists("/sbin/" + currWord):
|
||||
return
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if not self.spellChecker.check(currWord):
|
||||
self.env['runtime']['outputManager'].presentText(_('misspelled'), soundIcon='mispell', interrupt=False, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
_('misspelled'), soundIcon='mispell', interrupt=False, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -5,22 +5,29 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return 'No Description found'
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'charDeleteEcho'):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'keyboard', 'charDeleteEcho'):
|
||||
return
|
||||
# detect typing or chilling
|
||||
if self.env['screen']['newCursor']['x'] >= self.env['screen']['oldCursor']['x']:
|
||||
return
|
||||
return
|
||||
|
||||
# More than just a deletion happend
|
||||
if self.env['runtime']['screenManager'].isDelta(ignoreSpace=True):
|
||||
@ -28,18 +35,23 @@ class command():
|
||||
|
||||
# no deletion
|
||||
if not self.env['runtime']['screenManager'].isNegativeDelta():
|
||||
return
|
||||
return
|
||||
|
||||
# too much for a single backspace...
|
||||
# word begin produce a diff wiht len == 2 |a | others with 1 |a|
|
||||
if len(self.env['screen']['newNegativeDelta']) > 2:
|
||||
return
|
||||
|
||||
|
||||
currNegativeDelta = self.env['screen']['newNegativeDelta']
|
||||
if len(currNegativeDelta.strip()) != len(currNegativeDelta) and \
|
||||
currNegativeDelta.strip() != '':
|
||||
currNegativeDelta.strip() != '':
|
||||
currNegativeDelta = currNegativeDelta.strip()
|
||||
self.env['runtime']['outputManager'].presentText(currNegativeDelta, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currNegativeDelta,
|
||||
interrupt=True,
|
||||
ignorePunctuation=True,
|
||||
announceCapital=True,
|
||||
flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,54 +4,72 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import char_utils
|
||||
from fenrirscreenreader.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 ''
|
||||
|
||||
return ''
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'):
|
||||
return
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'focus', 'cursor'):
|
||||
return
|
||||
if self.env['runtime']['screenManager'].isScreenChange():
|
||||
return
|
||||
# detect an change on the screen, we just want to cursor arround, so no change should appear
|
||||
return
|
||||
# detect an change on the screen, we just want to cursor arround, so no
|
||||
# change should appear
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
if self.env['runtime']['screenManager'].isNegativeDelta():
|
||||
return
|
||||
# is a vertical change?
|
||||
if self.env['runtime']['cursorManager'].isCursorVerticalMove():
|
||||
return
|
||||
return
|
||||
# is it a horizontal change?
|
||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
||||
return
|
||||
|
||||
# echo word insteed of char
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'):
|
||||
if abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) != 1:
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = \
|
||||
word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# echo word insteed of char
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'keyboard', 'wordEcho'):
|
||||
if abs(self.env['screen']['oldCursor']['x'] -
|
||||
self.env['screen']['newCursor']['x']) != 1:
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split(
|
||||
'\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(
|
||||
self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
if self.env['screen']['newCursor']['x'] == x:
|
||||
return
|
||||
x, y, currChar = char_utils.getCurrentChar(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
return
|
||||
x, y, currChar = char_utils.getCurrentChar(
|
||||
self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
if currChar.isspace():
|
||||
# Only announce spaces during pure navigation (arrow keys)
|
||||
# Check if this is really navigation by looking at input history
|
||||
if (self.env['runtime']['inputManager'].getShortcutType() in ['KEY'] and
|
||||
self.env['runtime']['inputManager'].getLastDeepestInput()[0] in ['KEY_LEFT', 'KEY_RIGHT', 'KEY_UP', 'KEY_DOWN']):
|
||||
char_utils.presentCharForReview(self.env, currChar, interrupt=True, announceCapital=True, flush=False)
|
||||
if (self.env['runtime']['inputManager'].getShortcutType() in ['KEY'] and self.env['runtime'][
|
||||
'inputManager'].getLastDeepestInput()[0] in ['KEY_LEFT', 'KEY_RIGHT', 'KEY_UP', 'KEY_DOWN']):
|
||||
char_utils.presentCharForReview(
|
||||
self.env, currChar, interrupt=True, announceCapital=True, flush=False)
|
||||
else:
|
||||
self.env['runtime']['outputManager'].presentText(currChar, interrupt=True, ignorePunctuation=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currChar,
|
||||
interrupt=True,
|
||||
ignorePunctuation=True,
|
||||
announceCapital=True,
|
||||
flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -5,32 +5,43 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
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):
|
||||
# try to detect the tab completion by cursor change
|
||||
xMove = self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x']
|
||||
xMove = self.env['screen']['newCursor']['x'] - \
|
||||
self.env['screen']['oldCursor']['x']
|
||||
if xMove <= 0:
|
||||
return
|
||||
if self.env['runtime']['inputManager'].getShortcutType() in ['KEY']:
|
||||
if not (self.env['runtime']['inputManager'].getLastDeepestInput() in [['KEY_TAB']]):
|
||||
if not (
|
||||
self.env['runtime']['inputManager'].getLastDeepestInput() in [
|
||||
['KEY_TAB']]):
|
||||
if xMove < 5:
|
||||
return
|
||||
return
|
||||
elif self.env['runtime']['inputManager'].getShortcutType() in ['BYTE']:
|
||||
found = False
|
||||
for currByte in self.env['runtime']['byteManager'].getLastByteKey():
|
||||
for currByte in self.env['runtime']['byteManager'].getLastByteKey(
|
||||
):
|
||||
if currByte == 9:
|
||||
found = True
|
||||
if not found:
|
||||
if xMove < 5:
|
||||
return
|
||||
return
|
||||
# is there any change?
|
||||
if not self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
@ -39,10 +50,10 @@ class command():
|
||||
# filter unneded space on word begin
|
||||
currDelta = self.env['screen']['newDelta']
|
||||
if len(currDelta.strip()) != len(currDelta) and \
|
||||
currDelta.strip() != '':
|
||||
currDelta.strip() != '':
|
||||
currDelta = currDelta.strip()
|
||||
self.env['runtime']['outputManager'].presentText(currDelta, interrupt=True, announceCapital=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currDelta, interrupt=True, announceCapital=True, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,22 +4,29 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import string
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return 'No Description found'
|
||||
return 'No Description found'
|
||||
|
||||
def run(self):
|
||||
# is navigation?
|
||||
if not abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) > 1:
|
||||
# is navigation?
|
||||
if not abs(self.env['screen']['oldCursor']['x'] -
|
||||
self.env['screen']['newCursor']['x']) > 1:
|
||||
return
|
||||
|
||||
# just when cursor move worddetection is needed
|
||||
@ -30,24 +37,25 @@ class command():
|
||||
return
|
||||
# currently writing
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = \
|
||||
word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# is there a word?
|
||||
return
|
||||
|
||||
# get the word
|
||||
newContent = self.env['screen']['newContentText'].split(
|
||||
'\n')[self.env['screen']['newCursor']['y']]
|
||||
x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(
|
||||
self.env['screen']['newCursor']['x'], 0, newContent)
|
||||
|
||||
# is there a word?
|
||||
if currWord == '':
|
||||
return
|
||||
|
||||
# at the start of a word
|
||||
if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \
|
||||
(self.env['screen']['newCursor']['x'] != x):
|
||||
return
|
||||
# at the start of a word
|
||||
if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \
|
||||
(self.env['screen']['newCursor']['x'] != x):
|
||||
return
|
||||
|
||||
self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
currWord, interrupt=True, flush=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,58 +4,76 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import line_utils
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
self.lastIdent = -1
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return ''
|
||||
|
||||
return ''
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'):
|
||||
return
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'focus', 'cursor'):
|
||||
return
|
||||
if self.env['runtime']['screenManager'].isScreenChange():
|
||||
self.lastIdent = 0
|
||||
return
|
||||
# this leads to problems in vim -> status line change -> no announcement, so we do check the lengh as hack
|
||||
self.lastIdent = 0
|
||||
return
|
||||
# this leads to problems in vim -> status line change -> no
|
||||
# announcement, so we do check the lengh as hack
|
||||
if self.env['runtime']['screenManager'].isDelta():
|
||||
return
|
||||
|
||||
|
||||
# is a vertical change?
|
||||
if not self.env['runtime']['cursorManager'].isCursorVerticalMove():
|
||||
return
|
||||
|
||||
x, y, currLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
return
|
||||
|
||||
x, y, currLine = line_utils.getCurrentLine(
|
||||
self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
if currLine.isspace():
|
||||
self.env['runtime']['outputManager'].presentText(_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
_("blank"), soundIcon='EmptyLine', interrupt=True, flush=False)
|
||||
else:
|
||||
# ident
|
||||
currIdent = len(currLine) - len(currLine.lstrip())
|
||||
if self.lastIdent == -1:
|
||||
self.lastIdent = currIdent
|
||||
doInterrupt = True
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt('general', 'autoPresentIndentMode') in [0,1]:
|
||||
self.env['runtime']['outputManager'].playFrequence(currIdent * 50, 0.1, interrupt=doInterrupt)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt('general', 'autoPresentIndentMode') in [0,2]:
|
||||
if self.lastIdent != currIdent:
|
||||
self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt(
|
||||
'general', 'autoPresentIndentMode') in [0, 1]:
|
||||
self.env['runtime']['outputManager'].playFrequence(
|
||||
currIdent * 50, 0.1, interrupt=doInterrupt)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt(
|
||||
'general', 'autoPresentIndentMode') in [0, 2]:
|
||||
if self.lastIdent != currIdent:
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
_('indented ') + str(currIdent) + ' ', interrupt=doInterrupt, flush=False)
|
||||
doInterrupt = False
|
||||
# barrier
|
||||
sayLine = currLine
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('barrier','enabled'):
|
||||
isBarrier, barrierLine = self.env['runtime']['barrierManager'].handleLineBarrier(self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'],self.env['screen']['newCursor']['y'])
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'barrier', 'enabled'):
|
||||
isBarrier, barrierLine = self.env['runtime']['barrierManager'].handleLineBarrier(
|
||||
self.env['screen']['newContentText'].split('\n'), self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'])
|
||||
if isBarrier:
|
||||
sayLine = barrierLine
|
||||
# output
|
||||
self.env['runtime']['outputManager'].presentText(sayLine, interrupt=doInterrupt, flush=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
sayLine, interrupt=doInterrupt, flush=False)
|
||||
self.lastIdent = currIdent
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,21 +4,28 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import line_utils
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
self.lastIdent = -1
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return ''
|
||||
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('focus', 'cursor'):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'focus', 'cursor'):
|
||||
return
|
||||
if self.env['runtime']['screenManager'].isScreenChange():
|
||||
self.lastIdent = 0
|
||||
@ -27,12 +34,14 @@ class command():
|
||||
# is a vertical change?
|
||||
if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
|
||||
return
|
||||
x, y, currLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
x, y, currLine = line_utils.getCurrentLine(
|
||||
self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['newContentText'])
|
||||
currIdent = self.env['screen']['newCursor']['x']
|
||||
|
||||
if not currLine.isspace():
|
||||
# ident
|
||||
lastIdent, lastY, lastLine = line_utils.getCurrentLine(self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['oldContentText'])
|
||||
lastIdent, lastY, lastLine = line_utils.getCurrentLine(
|
||||
self.env['screen']['newCursor']['x'], self.env['screen']['newCursor']['y'], self.env['screen']['oldContentText'])
|
||||
if currLine.strip() != lastLine.strip():
|
||||
return
|
||||
if len(currLine.lstrip()) == len(lastLine.lstrip()):
|
||||
@ -44,13 +53,18 @@ class command():
|
||||
self.lastIdent = currIdent
|
||||
if currIdent <= 0:
|
||||
return
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt('general', 'autoPresentIndentMode') in [0,1]:
|
||||
self.env['runtime']['outputManager'].playFrequence(currIdent * 50, 0.1, interrupt=False)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt('general', 'autoPresentIndentMode') in [0,2]:
|
||||
if self.lastIdent != currIdent:
|
||||
self.env['runtime']['outputManager'].presentText(_('indented ') + str(currIdent) + ' ', interrupt=False, flush=False)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt(
|
||||
'general', 'autoPresentIndentMode') in [0, 1]:
|
||||
self.env['runtime']['outputManager'].playFrequence(
|
||||
currIdent * 50, 0.1, interrupt=False)
|
||||
if self.env['runtime']['settingsManager'].getSettingAsInt(
|
||||
'general', 'autoPresentIndentMode') in [0, 2]:
|
||||
if self.lastIdent != currIdent:
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
_('indented ') + str(currIdent) + ' ', interrupt=False, flush=False)
|
||||
self.lastIdent = currIdent
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
||||
|
@ -4,30 +4,41 @@
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import screen_utils
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return _('Reads attributes of current cursor position')
|
||||
return _('Reads attributes of current cursor position')
|
||||
|
||||
def run(self):
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'hasAttributes'):
|
||||
return
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'general', 'hasAttributes'):
|
||||
return
|
||||
# is a vertical change?
|
||||
if not (self.env['runtime']['cursorManager'].isCursorVerticalMove() or\
|
||||
self.env['runtime']['cursorManager'].isCursorHorizontalMove()):
|
||||
return
|
||||
if not (self.env['runtime']['cursorManager'].isCursorVerticalMove() or
|
||||
self.env['runtime']['cursorManager'].isCursorHorizontalMove()):
|
||||
return
|
||||
|
||||
cursorPos = self.env['screen']['newCursor']
|
||||
|
||||
if not self.env['runtime']['attributeManager'].hasAttributes(cursorPos):
|
||||
|
||||
if not self.env['runtime']['attributeManager'].hasAttributes(
|
||||
cursorPos):
|
||||
return
|
||||
self.env['runtime']['outputManager'].presentText('has attribute', soundIcon='HasAttributes', interrupt=False)
|
||||
self.env['runtime']['outputManager'].presentText(
|
||||
'has attribute', soundIcon='HasAttributes', interrupt=False)
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
@ -5,21 +5,28 @@
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
def getDescription(self):
|
||||
return _('exits review mode')
|
||||
|
||||
return _('exits review mode')
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool('review', 'leaveReviewOnCursorChange'):
|
||||
return
|
||||
if not self.env['runtime']['settingsManager'].getSettingAsBool(
|
||||
'review', 'leaveReviewOnCursorChange'):
|
||||
return
|
||||
if self.env['runtime']['cursorManager'].isReviewMode():
|
||||
self.env['runtime']['cursorManager'].clearReviewCursor()
|
||||
|
||||
|
||||
def setCallback(self, callback):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user