More pep8 fixes. A tiny bit of refactoring.
This commit is contained in:
@ -2,13 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -19,52 +19,65 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return _("Announces characters as they are typed")
|
||||
|
||||
def run(self):
|
||||
# enabled?
|
||||
active = self.env['runtime']['SettingsManager'].get_setting_as_int(
|
||||
'keyboard', 'charEchoMode')
|
||||
active = self.env["runtime"]["SettingsManager"].get_setting_as_int(
|
||||
"keyboard", "charEchoMode"
|
||||
)
|
||||
# 0 = off
|
||||
if active == 0:
|
||||
return
|
||||
# 2 = caps only
|
||||
if active == 2:
|
||||
if not self.env['input']['newCapsLock']:
|
||||
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)
|
||||
x_move = abs(
|
||||
self.env['screen']['new_cursor']['x'] -
|
||||
self.env['screen']['old_cursor']['x'])
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
- self.env["screen"]["old_cursor"]["x"]
|
||||
)
|
||||
if x_move > 3:
|
||||
return
|
||||
if self.env['runtime']['InputManager'].get_shortcut_type() in ['KEY']:
|
||||
if self.env['runtime']['InputManager'].get_last_deepest_input() in [
|
||||
['KEY_TAB']]:
|
||||
if self.env["runtime"]["InputManager"].get_shortcut_type() in ["KEY"]:
|
||||
if self.env["runtime"][
|
||||
"InputManager"
|
||||
].get_last_deepest_input() in [["KEY_TAB"]]:
|
||||
return
|
||||
elif self.env['runtime']['InputManager'].get_shortcut_type() in ['BYTE']:
|
||||
if self.env['runtime']['ByteManager'].get_last_byte_key() in [
|
||||
b' ', b'\t']:
|
||||
elif self.env["runtime"]["InputManager"].get_shortcut_type() in [
|
||||
"BYTE"
|
||||
]:
|
||||
if self.env["runtime"]["ByteManager"].get_last_byte_key() in [
|
||||
b" ",
|
||||
b"\t",
|
||||
]:
|
||||
return
|
||||
# detect deletion or chilling
|
||||
if self.env['screen']['new_cursor']['x'] <= self.env['screen']['old_cursor']['x']:
|
||||
if (
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
<= self.env["screen"]["old_cursor"]["x"]
|
||||
):
|
||||
return
|
||||
# is there any change?
|
||||
if not self.env['runtime']['ScreenManager'].is_delta():
|
||||
if not self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
# filter unneded space on word begin
|
||||
curr_delta = self.env['screen']['new_delta']
|
||||
if len(curr_delta.strip()) != len(curr_delta) and \
|
||||
curr_delta.strip() != '':
|
||||
curr_delta = self.env["screen"]["new_delta"]
|
||||
if (
|
||||
len(curr_delta.strip()) != len(curr_delta)
|
||||
and curr_delta.strip() != ""
|
||||
):
|
||||
curr_delta = curr_delta.strip()
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_delta,
|
||||
interrupt=True,
|
||||
ignore_punctuation=True,
|
||||
announce_capital=True,
|
||||
flush=False)
|
||||
flush=False,
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,15 +2,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import string
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
class command():
|
||||
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -21,48 +21,61 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return _("Announces completed words during typing")
|
||||
|
||||
def run(self):
|
||||
# is it enabled?
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'keyboard', 'wordEcho'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"keyboard", "wordEcho"
|
||||
):
|
||||
return
|
||||
# is naviation?
|
||||
if self.env['screen']['new_cursor']['x'] - \
|
||||
self.env['screen']['old_cursor']['x'] != 1:
|
||||
# is navigation?
|
||||
if (
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
- self.env["screen"]["old_cursor"]["x"]
|
||||
!= 1
|
||||
):
|
||||
return
|
||||
# just when cursor move worddetection is needed
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_horizontal_move():
|
||||
if not self.env["runtime"][
|
||||
"CursorManager"
|
||||
].is_cursor_horizontal_move():
|
||||
return
|
||||
# for now no new line
|
||||
if self.env['runtime']['CursorManager'].is_cursor_vertical_move():
|
||||
if self.env["runtime"]["CursorManager"].is_cursor_vertical_move():
|
||||
return
|
||||
# currently writing
|
||||
if self.env['runtime']['ScreenManager'].is_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
|
||||
# get the word
|
||||
new_content = self.env['screen']['new_content_text'].split(
|
||||
'\n')[self.env['screen']['new_cursor']['y']]
|
||||
x, y, curr_word, end_of_screen, line_break = word_utils.get_current_word(
|
||||
self.env['screen']['new_cursor']['x'], 0, new_content)
|
||||
new_content = self.env["screen"]["new_content_text"].split("\n")[
|
||||
self.env["screen"]["new_cursor"]["y"]
|
||||
]
|
||||
x, y, curr_word, end_of_screen, line_break = (
|
||||
word_utils.get_current_word(
|
||||
self.env["screen"]["new_cursor"]["x"], 0, new_content
|
||||
)
|
||||
)
|
||||
|
||||
# is there a word?
|
||||
if curr_word == '':
|
||||
if curr_word == "":
|
||||
return
|
||||
# at the end of a word
|
||||
if not new_content[self.env['screen']['new_cursor']['x']].isspace():
|
||||
if (
|
||||
self.env["screen"]["new_cursor"]["x"] >= len(new_content)
|
||||
or not new_content[self.env["screen"]["new_cursor"]["x"]].isspace()
|
||||
):
|
||||
return
|
||||
# at the end of a word
|
||||
if (x +
|
||||
len(curr_word) != self.env['screen']['new_cursor']['x']) and (x +
|
||||
len(curr_word) != self.env['screen']['new_cursor']['x'] -
|
||||
1):
|
||||
if (x + len(curr_word) != self.env["screen"]["new_cursor"]["x"]) and (
|
||||
x + len(curr_word) != self.env["screen"]["new_cursor"]["x"] - 1
|
||||
):
|
||||
return
|
||||
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
curr_word, interrupt=True, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_word, interrupt=True, flush=False
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,26 +2,27 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import os
|
||||
import string
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
initialized = False
|
||||
try:
|
||||
import enchant
|
||||
|
||||
initialized = True
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
self.language = ''
|
||||
self.spellChecker = ''
|
||||
self.language = ""
|
||||
self.spellChecker = ""
|
||||
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
@ -31,118 +32,144 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return "No Description found"
|
||||
|
||||
def update_spell_language(self):
|
||||
if not initialized:
|
||||
return
|
||||
self.spellChecker = enchant.Dict(
|
||||
self.env['runtime']['SettingsManager'].get_setting(
|
||||
'general', 'spellCheckLanguage'))
|
||||
self.language = self.env['runtime']['SettingsManager'].get_setting(
|
||||
'general', 'spellCheckLanguage')
|
||||
self.env["runtime"]["SettingsManager"].get_setting(
|
||||
"general", "spellCheckLanguage"
|
||||
)
|
||||
)
|
||||
self.language = self.env["runtime"]["SettingsManager"].get_setting(
|
||||
"general", "spellCheckLanguage"
|
||||
)
|
||||
|
||||
def run(self):
|
||||
if not initialized:
|
||||
return
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'general', 'autoSpellCheck'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"general", "autoSpellCheck"
|
||||
):
|
||||
return
|
||||
if self.env['runtime']['SettingsManager'].get_setting(
|
||||
'general', 'spellCheckLanguage') != self.language:
|
||||
if (
|
||||
self.env["runtime"]["SettingsManager"].get_setting(
|
||||
"general", "spellCheckLanguage"
|
||||
)
|
||||
!= self.language
|
||||
):
|
||||
try:
|
||||
self.update_spell_language()
|
||||
except Exception as e:
|
||||
return
|
||||
|
||||
# just when horizontal cursor move worddetection is needed
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_horizontal_move():
|
||||
if not self.env["runtime"][
|
||||
"CursorManager"
|
||||
].is_cursor_horizontal_move():
|
||||
return
|
||||
|
||||
# for now no new line
|
||||
if self.env['runtime']['CursorManager'].is_cursor_vertical_move():
|
||||
if self.env["runtime"]["CursorManager"].is_cursor_vertical_move():
|
||||
return
|
||||
# more than a keyecho?
|
||||
if len(self.env['screen']['new_delta']) > 1:
|
||||
if len(self.env["screen"]["new_delta"]) > 1:
|
||||
return
|
||||
# deletion
|
||||
if self.env['runtime']['ScreenManager'].is_negative_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_negative_delta():
|
||||
return
|
||||
# first place could not be the end of a word
|
||||
if self.env['screen']['new_cursor']['x'] == 0:
|
||||
if self.env["screen"]["new_cursor"]["x"] == 0:
|
||||
return
|
||||
|
||||
# get the word (just for speedup only look at current line
|
||||
new_content = self.env['screen']['new_content_text'].split(
|
||||
'\n')[self.env['screen']['new_cursor']['y']]
|
||||
x, y, curr_word, end_of_screen, line_break = word_utils.get_current_word(
|
||||
self.env['screen']['new_cursor']['x'], 0, new_content)
|
||||
new_content = self.env["screen"]["new_content_text"].split("\n")[
|
||||
self.env["screen"]["new_cursor"]["y"]
|
||||
]
|
||||
x, y, curr_word, end_of_screen, line_break = (
|
||||
word_utils.get_current_word(
|
||||
self.env["screen"]["new_cursor"]["x"], 0, new_content
|
||||
)
|
||||
)
|
||||
# was this a typed word?
|
||||
if self.env['runtime']['ScreenManager'].is_delta():
|
||||
if not (new_content[self.env['screen']['old_cursor']['x']] in string.whitespace +
|
||||
'!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['old_cursor']['x']):
|
||||
if self.env["runtime"]["ScreenManager"].is_delta():
|
||||
if not (
|
||||
new_content[self.env["screen"]["old_cursor"]["x"]]
|
||||
in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~'
|
||||
and x != self.env["screen"]["old_cursor"]["x"]
|
||||
):
|
||||
return
|
||||
else:
|
||||
curr_word = curr_word.strip(
|
||||
string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~')
|
||||
string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~'
|
||||
)
|
||||
else:
|
||||
# or just arrow arround?
|
||||
if not new_content[self.env['screen']['new_cursor']['x']].isspace():
|
||||
if not new_content[
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
].isspace():
|
||||
return
|
||||
if (x +
|
||||
len(curr_word) != self.env['screen']['new_cursor']['x']) and (x +
|
||||
len(curr_word) != self.env['screen']['new_cursor']['x'] -
|
||||
1):
|
||||
if (
|
||||
x + len(curr_word) != self.env["screen"]["new_cursor"]["x"]
|
||||
) and (
|
||||
x + len(curr_word) != self.env["screen"]["new_cursor"]["x"] - 1
|
||||
):
|
||||
return
|
||||
|
||||
# just on end of word
|
||||
if self.env['screen']['new_cursor']['x'] > 0:
|
||||
if not new_content[self.env['screen']['old_cursor']
|
||||
['x'] - 1].lower() in string.ascii_lowercase:
|
||||
if self.env["screen"]["new_cursor"]["x"] > 0:
|
||||
if (
|
||||
not new_content[
|
||||
self.env["screen"]["old_cursor"]["x"] - 1
|
||||
].lower()
|
||||
in string.ascii_lowercase
|
||||
):
|
||||
return
|
||||
|
||||
# ignore bash buildins
|
||||
if curr_word 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']:
|
||||
"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 curr_word.upper() == 'FENRIR':
|
||||
if curr_word.upper() == "FENRIR":
|
||||
return
|
||||
if curr_word[0] == '-':
|
||||
if curr_word[0] == "-":
|
||||
return
|
||||
if curr_word[0] == '/':
|
||||
if curr_word[0] == "/":
|
||||
return
|
||||
if curr_word[0] == '#':
|
||||
if curr_word[0] == "#":
|
||||
return
|
||||
if curr_word.startswith('./'):
|
||||
if curr_word.startswith("./"):
|
||||
return
|
||||
if '@' in curr_word and '.' in curr_word:
|
||||
if "@" in curr_word and "." in curr_word:
|
||||
return
|
||||
if curr_word[0] == '@':
|
||||
if curr_word[0] == "@":
|
||||
return
|
||||
if curr_word.isnumeric():
|
||||
return
|
||||
@ -168,8 +195,12 @@ class command():
|
||||
pass
|
||||
|
||||
if not self.spellChecker.check(curr_word):
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
_('misspelled'), sound_icon ='mispell', interrupt=False, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
_("misspelled"),
|
||||
sound_icon="mispell",
|
||||
interrupt=False,
|
||||
flush=False,
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,13 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -19,39 +19,46 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return "No Description found"
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'keyboard', 'charDeleteEcho'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"keyboard", "charDeleteEcho"
|
||||
):
|
||||
return
|
||||
# detect typing or chilling
|
||||
if self.env['screen']['new_cursor']['x'] >= self.env['screen']['old_cursor']['x']:
|
||||
if (
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
>= self.env["screen"]["old_cursor"]["x"]
|
||||
):
|
||||
return
|
||||
|
||||
# More than just a deletion happend
|
||||
if self.env['runtime']['ScreenManager'].is_delta(ignoreSpace=True):
|
||||
if self.env["runtime"]["ScreenManager"].is_delta(ignoreSpace=True):
|
||||
return
|
||||
|
||||
# no deletion
|
||||
if not self.env['runtime']['ScreenManager'].is_negative_delta():
|
||||
if not self.env["runtime"]["ScreenManager"].is_negative_delta():
|
||||
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:
|
||||
if len(self.env["screen"]["newNegativeDelta"]) > 2:
|
||||
return
|
||||
|
||||
curr_negative_delta = self.env['screen']['newNegativeDelta']
|
||||
if len(curr_negative_delta.strip()) != len(curr_negative_delta) and \
|
||||
curr_negative_delta.strip() != '':
|
||||
curr_negative_delta = self.env["screen"]["newNegativeDelta"]
|
||||
if (
|
||||
len(curr_negative_delta.strip()) != len(curr_negative_delta)
|
||||
and curr_negative_delta.strip() != ""
|
||||
):
|
||||
curr_negative_delta = curr_negative_delta.strip()
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_negative_delta,
|
||||
interrupt=True,
|
||||
ignore_punctuation=True,
|
||||
announce_capital=True,
|
||||
flush=False)
|
||||
flush=False,
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,15 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import char_utils
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -21,55 +20,85 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'focus', 'cursor'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"focus", "cursor"
|
||||
):
|
||||
return
|
||||
if self.env['runtime']['ScreenManager'].is_screen_change():
|
||||
if self.env["runtime"]["ScreenManager"].is_screen_change():
|
||||
return
|
||||
# detect an change on the screen, we just want to cursor arround, so no
|
||||
# change should appear
|
||||
if self.env['runtime']['ScreenManager'].is_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
if self.env['runtime']['ScreenManager'].is_negative_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_negative_delta():
|
||||
return
|
||||
# is a vertical change?
|
||||
if self.env['runtime']['CursorManager'].is_cursor_vertical_move():
|
||||
if self.env["runtime"]["CursorManager"].is_cursor_vertical_move():
|
||||
return
|
||||
# is it a horizontal change?
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_horizontal_move():
|
||||
if not self.env["runtime"][
|
||||
"CursorManager"
|
||||
].is_cursor_horizontal_move():
|
||||
return
|
||||
|
||||
# echo word insteed of char
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'keyboard', 'wordEcho'):
|
||||
if abs(self.env['screen']['old_cursor']['x'] -
|
||||
self.env['screen']['new_cursor']['x']) != 1:
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"keyboard", "wordEcho"
|
||||
):
|
||||
if (
|
||||
abs(
|
||||
self.env["screen"]["old_cursor"]["x"]
|
||||
- self.env["screen"]["new_cursor"]["x"]
|
||||
)
|
||||
!= 1
|
||||
):
|
||||
# get the word
|
||||
new_content = self.env['screen']['new_content_text'].split(
|
||||
'\n')[self.env['screen']['new_cursor']['y']]
|
||||
x, y, curr_word, end_of_screen, line_break = word_utils.get_current_word(
|
||||
self.env['screen']['new_cursor']['x'], 0, new_content)
|
||||
if self.env['screen']['new_cursor']['x'] == x:
|
||||
new_content = self.env["screen"]["new_content_text"].split(
|
||||
"\n"
|
||||
)[self.env["screen"]["new_cursor"]["y"]]
|
||||
x, y, curr_word, end_of_screen, line_break = (
|
||||
word_utils.get_current_word(
|
||||
self.env["screen"]["new_cursor"]["x"], 0, new_content
|
||||
)
|
||||
)
|
||||
if self.env["screen"]["new_cursor"]["x"] == x:
|
||||
return
|
||||
x, y, curr_char = char_utils.get_current_char(
|
||||
self.env['screen']['new_cursor']['x'], self.env['screen']['new_cursor']['y'], self.env['screen']['new_content_text'])
|
||||
self.env["screen"]["new_cursor"]["x"],
|
||||
self.env["screen"]["new_cursor"]["y"],
|
||||
self.env["screen"]["new_content_text"],
|
||||
)
|
||||
if curr_char.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'].get_shortcut_type() in ['KEY'] and self.env['runtime'][
|
||||
'InputManager'].get_last_deepest_input()[0] in ['KEY_LEFT', 'KEY_RIGHT', 'KEY_UP', 'KEY_DOWN']):
|
||||
if self.env["runtime"]["InputManager"].get_shortcut_type() in [
|
||||
"KEY"
|
||||
] and self.env["runtime"]["InputManager"].get_last_deepest_input()[
|
||||
0
|
||||
] in [
|
||||
"KEY_LEFT",
|
||||
"KEY_RIGHT",
|
||||
"KEY_UP",
|
||||
"KEY_DOWN",
|
||||
]:
|
||||
char_utils.present_char_for_review(
|
||||
self.env, curr_char, interrupt=True, announce_capital=True, flush=False)
|
||||
self.env,
|
||||
curr_char,
|
||||
interrupt=True,
|
||||
announce_capital=True,
|
||||
flush=False,
|
||||
)
|
||||
else:
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_char,
|
||||
interrupt=True,
|
||||
ignore_punctuation=True,
|
||||
announce_capital=True,
|
||||
flush=False)
|
||||
flush=False,
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,13 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -19,41 +19,50 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return "No Description found"
|
||||
|
||||
def run(self):
|
||||
# try to detect the tab completion by cursor change
|
||||
x_move = self.env['screen']['new_cursor']['x'] - \
|
||||
self.env['screen']['old_cursor']['x']
|
||||
x_move = (
|
||||
self.env["screen"]["new_cursor"]["x"]
|
||||
- self.env["screen"]["old_cursor"]["x"]
|
||||
)
|
||||
if x_move <= 0:
|
||||
return
|
||||
if self.env['runtime']['InputManager'].get_shortcut_type() in ['KEY']:
|
||||
if self.env["runtime"]["InputManager"].get_shortcut_type() in ["KEY"]:
|
||||
if not (
|
||||
self.env['runtime']['InputManager'].get_last_deepest_input() in [
|
||||
['KEY_TAB']]):
|
||||
self.env["runtime"]["InputManager"].get_last_deepest_input()
|
||||
in [["KEY_TAB"]]
|
||||
):
|
||||
if x_move < 5:
|
||||
return
|
||||
elif self.env['runtime']['InputManager'].get_shortcut_type() in ['BYTE']:
|
||||
elif self.env["runtime"]["InputManager"].get_shortcut_type() in [
|
||||
"BYTE"
|
||||
]:
|
||||
found = False
|
||||
for currByte in self.env['runtime']['ByteManager'].get_last_byte_key(
|
||||
):
|
||||
for currByte in self.env["runtime"][
|
||||
"ByteManager"
|
||||
].get_last_byte_key():
|
||||
if currByte == 9:
|
||||
found = True
|
||||
if not found:
|
||||
if x_move < 5:
|
||||
return
|
||||
# is there any change?
|
||||
if not self.env['runtime']['ScreenManager'].is_delta():
|
||||
if not self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
if not x_move == len(self.env['screen']['new_delta']):
|
||||
if not x_move == len(self.env["screen"]["new_delta"]):
|
||||
return
|
||||
# filter unneded space on word begin
|
||||
curr_delta = self.env['screen']['new_delta']
|
||||
if len(curr_delta.strip()) != len(curr_delta) and \
|
||||
curr_delta.strip() != '':
|
||||
curr_delta = self.env["screen"]["new_delta"]
|
||||
if (
|
||||
len(curr_delta.strip()) != len(curr_delta)
|
||||
and curr_delta.strip() != ""
|
||||
):
|
||||
curr_delta = curr_delta.strip()
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
curr_delta, interrupt=True, announce_capital=True, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_delta, interrupt=True, announce_capital=True, flush=False
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,15 +2,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
import string
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
class command():
|
||||
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -21,41 +21,54 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return 'No Description found'
|
||||
return "No Description found"
|
||||
|
||||
def run(self):
|
||||
# is navigation?
|
||||
if not abs(self.env['screen']['old_cursor']['x'] -
|
||||
self.env['screen']['new_cursor']['x']) > 1:
|
||||
if (
|
||||
not abs(
|
||||
self.env["screen"]["old_cursor"]["x"]
|
||||
- self.env["screen"]["new_cursor"]["x"]
|
||||
)
|
||||
> 1
|
||||
):
|
||||
return
|
||||
|
||||
# just when cursor move worddetection is needed
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_horizontal_move():
|
||||
if not self.env["runtime"][
|
||||
"CursorManager"
|
||||
].is_cursor_horizontal_move():
|
||||
return
|
||||
# for now no new line
|
||||
if self.env['runtime']['CursorManager'].is_cursor_vertical_move():
|
||||
if self.env["runtime"]["CursorManager"].is_cursor_vertical_move():
|
||||
return
|
||||
# currently writing
|
||||
if self.env['runtime']['ScreenManager'].is_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
|
||||
# get the word
|
||||
new_content = self.env['screen']['new_content_text'].split(
|
||||
'\n')[self.env['screen']['new_cursor']['y']]
|
||||
x, y, curr_word, end_of_screen, line_break = word_utils.get_current_word(
|
||||
self.env['screen']['new_cursor']['x'], 0, new_content)
|
||||
new_content = self.env["screen"]["new_content_text"].split("\n")[
|
||||
self.env["screen"]["new_cursor"]["y"]
|
||||
]
|
||||
x, y, curr_word, end_of_screen, line_break = (
|
||||
word_utils.get_current_word(
|
||||
self.env["screen"]["new_cursor"]["x"], 0, new_content
|
||||
)
|
||||
)
|
||||
|
||||
# is there a word?
|
||||
if curr_word == '':
|
||||
if curr_word == "":
|
||||
return
|
||||
|
||||
# at the start of a word
|
||||
if (x + len(curr_word) != self.env['screen']['new_cursor']['x']) and \
|
||||
(self.env['screen']['new_cursor']['x'] != x):
|
||||
if (x + len(curr_word) != self.env["screen"]["new_cursor"]["x"]) and (
|
||||
self.env["screen"]["new_cursor"]["x"] != x
|
||||
):
|
||||
return
|
||||
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
curr_word, interrupt=True, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
curr_word, interrupt=True, flush=False
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,15 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import line_utils
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
self.lastIdent = -1
|
||||
|
||||
@ -21,58 +20,77 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'focus', 'cursor'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"focus", "cursor"
|
||||
):
|
||||
return
|
||||
if self.env['runtime']['ScreenManager'].is_screen_change():
|
||||
if self.env["runtime"]["ScreenManager"].is_screen_change():
|
||||
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'].is_delta():
|
||||
if self.env["runtime"]["ScreenManager"].is_delta():
|
||||
return
|
||||
|
||||
# is a vertical change?
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_vertical_move():
|
||||
if not self.env["runtime"]["CursorManager"].is_cursor_vertical_move():
|
||||
return
|
||||
|
||||
x, y, curr_line = line_utils.get_current_line(
|
||||
self.env['screen']['new_cursor']['x'], self.env['screen']['new_cursor']['y'], self.env['screen']['new_content_text'])
|
||||
self.env["screen"]["new_cursor"]["x"],
|
||||
self.env["screen"]["new_cursor"]["y"],
|
||||
self.env["screen"]["new_content_text"],
|
||||
)
|
||||
if curr_line.isspace():
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
_("blank"), sound_icon ='EmptyLine', interrupt=True, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
_("blank"), sound_icon="EmptyLine", interrupt=True, flush=False
|
||||
)
|
||||
else:
|
||||
# ident
|
||||
curr_ident = len(curr_line) - len(curr_line.lstrip())
|
||||
if self.lastIdent == -1:
|
||||
self.lastIdent = curr_ident
|
||||
do_interrupt = True
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_int(
|
||||
'general', 'autoPresentIndentMode') in [0, 1]:
|
||||
self.env['runtime']['OutputManager'].play_frequence(
|
||||
curr_ident * 50, 0.1, interrupt=do_interrupt)
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_int(
|
||||
'general', 'autoPresentIndentMode') in [0, 2]:
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"general", "autoPresentIndent"
|
||||
):
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_int(
|
||||
"general", "autoPresentIndentMode"
|
||||
) in [0, 1]:
|
||||
self.env["runtime"]["OutputManager"].play_frequence(
|
||||
curr_ident * 50, 0.1, interrupt=do_interrupt
|
||||
)
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_int(
|
||||
"general", "autoPresentIndentMode"
|
||||
) in [0, 2]:
|
||||
if self.lastIdent != curr_ident:
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
_('indented ') + str(curr_ident) + ' ', interrupt=do_interrupt, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
_("indented ") + str(curr_ident) + " ",
|
||||
interrupt=do_interrupt,
|
||||
flush=False,
|
||||
)
|
||||
do_interrupt = False
|
||||
# barrier
|
||||
say_line = curr_line
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'barrier', 'enabled'):
|
||||
is_barrier, barrierLine = self.env['runtime']['BarrierManager'].handle_line_barrier(
|
||||
self.env['screen']['new_content_text'].split('\n'), self.env['screen']['new_cursor']['x'], self.env['screen']['new_cursor']['y'])
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"barrier", "enabled"
|
||||
):
|
||||
is_barrier, barrierLine = self.env["runtime"][
|
||||
"BarrierManager"
|
||||
].handle_line_barrier(
|
||||
self.env["screen"]["new_content_text"].split("\n"),
|
||||
self.env["screen"]["new_cursor"]["x"],
|
||||
self.env["screen"]["new_cursor"]["y"],
|
||||
)
|
||||
if is_barrier:
|
||||
say_line = barrierLine
|
||||
# output
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
say_line, interrupt=do_interrupt, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
say_line, interrupt=do_interrupt, flush=False
|
||||
)
|
||||
self.lastIdent = curr_ident
|
||||
|
||||
def set_callback(self, callback):
|
||||
|
@ -2,15 +2,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import line_utils
|
||||
from fenrirscreenreader.utils import word_utils
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
self.lastIdent = -1
|
||||
|
||||
@ -21,27 +20,36 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'focus', 'cursor'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"focus", "cursor"
|
||||
):
|
||||
return
|
||||
if self.env['runtime']['ScreenManager'].is_screen_change():
|
||||
if self.env["runtime"]["ScreenManager"].is_screen_change():
|
||||
self.lastIdent = 0
|
||||
return
|
||||
|
||||
# is a vertical change?
|
||||
if not self.env['runtime']['CursorManager'].is_cursor_horizontal_move():
|
||||
if not self.env["runtime"][
|
||||
"CursorManager"
|
||||
].is_cursor_horizontal_move():
|
||||
return
|
||||
x, y, curr_line = line_utils.get_current_line(
|
||||
self.env['screen']['new_cursor']['x'], self.env['screen']['new_cursor']['y'], self.env['screen']['new_content_text'])
|
||||
curr_ident = self.env['screen']['new_cursor']['x']
|
||||
self.env["screen"]["new_cursor"]["x"],
|
||||
self.env["screen"]["new_cursor"]["y"],
|
||||
self.env["screen"]["new_content_text"],
|
||||
)
|
||||
curr_ident = self.env["screen"]["new_cursor"]["x"]
|
||||
|
||||
if not curr_line.isspace():
|
||||
# ident
|
||||
lastIdent, lastY, last_line = line_utils.get_current_line(
|
||||
self.env['screen']['new_cursor']['x'], self.env['screen']['new_cursor']['y'], self.env['screen']['old_content_text'])
|
||||
self.env["screen"]["new_cursor"]["x"],
|
||||
self.env["screen"]["new_cursor"]["y"],
|
||||
self.env["screen"]["old_content_text"],
|
||||
)
|
||||
if curr_line.strip() != last_line.strip():
|
||||
return
|
||||
if len(curr_line.lstrip()) == len(last_line.lstrip()):
|
||||
@ -53,17 +61,24 @@ class command():
|
||||
self.lastIdent = curr_ident
|
||||
if curr_ident <= 0:
|
||||
return
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'general', 'autoPresentIndent'):
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_int(
|
||||
'general', 'autoPresentIndentMode') in [0, 1]:
|
||||
self.env['runtime']['OutputManager'].play_frequence(
|
||||
curr_ident * 50, 0.1, interrupt=False)
|
||||
if self.env['runtime']['SettingsManager'].get_setting_as_int(
|
||||
'general', 'autoPresentIndentMode') in [0, 2]:
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"general", "autoPresentIndent"
|
||||
):
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_int(
|
||||
"general", "autoPresentIndentMode"
|
||||
) in [0, 1]:
|
||||
self.env["runtime"]["OutputManager"].play_frequence(
|
||||
curr_ident * 50, 0.1, interrupt=False
|
||||
)
|
||||
if self.env["runtime"]["SettingsManager"].get_setting_as_int(
|
||||
"general", "autoPresentIndentMode"
|
||||
) in [0, 2]:
|
||||
if self.lastIdent != curr_ident:
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
_('indented ') + str(curr_ident) + ' ', interrupt=False, flush=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
_("indented ") + str(curr_ident) + " ",
|
||||
interrupt=False,
|
||||
flush=False,
|
||||
)
|
||||
self.lastIdent = curr_ident
|
||||
|
||||
def set_callback(self, callback):
|
||||
|
@ -2,14 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
from fenrirscreenreader.utils import screen_utils
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -20,25 +19,30 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(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'].get_setting_as_bool(
|
||||
'general', 'hasattributes'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"general", "hasattributes"
|
||||
):
|
||||
return
|
||||
# is a vertical change?
|
||||
if not (self.env['runtime']['CursorManager'].is_cursor_vertical_move() or
|
||||
self.env['runtime']['CursorManager'].is_cursor_horizontal_move()):
|
||||
if not (
|
||||
self.env["runtime"]["CursorManager"].is_cursor_vertical_move()
|
||||
or self.env["runtime"]["CursorManager"].is_cursor_horizontal_move()
|
||||
):
|
||||
return
|
||||
|
||||
cursor_pos = self.env['screen']['new_cursor']
|
||||
cursor_pos = self.env["screen"]["new_cursor"]
|
||||
|
||||
if not self.env['runtime']['AttributeManager'].has_attributes(
|
||||
cursor_pos):
|
||||
if not self.env["runtime"]["AttributeManager"].has_attributes(
|
||||
cursor_pos
|
||||
):
|
||||
return
|
||||
self.env['runtime']['OutputManager'].present_text(
|
||||
'has attribute', sound_icon ='HasAttributes', interrupt=False)
|
||||
self.env["runtime"]["OutputManager"].present_text(
|
||||
"has attribute", sound_icon="HasAttributes", interrupt=False
|
||||
)
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
@ -2,13 +2,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Fenrir TTY screen reader
|
||||
# By Chrys, Storm Dragon, and contributers.
|
||||
# By Chrys, Storm Dragon, and contributors.
|
||||
|
||||
|
||||
from fenrirscreenreader.core.i18n import _
|
||||
|
||||
|
||||
class command():
|
||||
class command:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@ -19,14 +19,15 @@ class command():
|
||||
pass
|
||||
|
||||
def get_description(self):
|
||||
return _('exits review mode')
|
||||
return _("exits review mode")
|
||||
|
||||
def run(self):
|
||||
if not self.env['runtime']['SettingsManager'].get_setting_as_bool(
|
||||
'review', 'leaveReviewOnCursorChange'):
|
||||
if not self.env["runtime"]["SettingsManager"].get_setting_as_bool(
|
||||
"review", "leaveReviewOnCursorChange"
|
||||
):
|
||||
return
|
||||
if self.env['runtime']['CursorManager'].is_review_mode():
|
||||
self.env['runtime']['CursorManager'].clear_review_cursor()
|
||||
if self.env["runtime"]["CursorManager"].is_review_mode():
|
||||
self.env["runtime"]["CursorManager"].clear_review_cursor()
|
||||
|
||||
def set_callback(self, callback):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user