add nex/prev word phonetic

This commit is contained in:
chrys 2016-10-17 23:08:19 +02:00
parent e65f880dfb
commit 1eed2e3479
7 changed files with 27 additions and 27 deletions

View File

@ -11,18 +11,18 @@ KEY_FENRIR,KEY_KP1=review_line_first_char
KEY_FENRIR,KEY_KP3=review_line_last_char KEY_FENRIR,KEY_KP3=review_line_last_char
KEY_FENRIR,KEY_ALT,KEY_1=present_first_line KEY_FENRIR,KEY_ALT,KEY_1=present_first_line
KEY_FENRIR,KEY_ALT,KEY_2=present_last_line KEY_FENRIR,KEY_ALT,KEY_2=present_last_line
KEY_KP5=review_curr_word #KEY_KP5=review_curr_word
KEY_KP4=review_prev_word #KEY_KP4=review_prev_word
KEY_KP6=review_next_word #KEY_KP6=review_next_word
KEY_SHIFT,KEY_KP5=curr_word_phonetic KEY_KP5=review_curr_word_phonetic
KEY_SHIFT,KEY_KP4=review_prev_word_phonetic KEY_KP4=review_prev_word_phonetic
KEY_SHIFT,KEY_KP6=review_next_word_phonetic KEY_KP6=review_next_word_phonetic
#KEY_KP2=review_curr_char #KEY_KP2=review_curr_char
#KEY_KP1=review_prev_char #KEY_KP1=review_prev_char
#KEY_KP3=review_next_char #KEY_KP3=review_next_char
KEY_KP2=review_curr_char_phonetic #KEY_KP2=review_curr_char_phonetic
KEY_KP1=review_prev_char_phonetic #KEY_KP1=review_prev_char_phonetic
KEY_KP3=review_next_char_phonetic #KEY_KP3=review_next_char_phonetic
#=review_up #=review_up
#=review_down #=review_down
KEY_KPDOT=cursor_position KEY_KPDOT=cursor_position
@ -75,9 +75,8 @@ key_FENRIR,KEY_KPENTER=toggle_auto_read
KEY_FENRIR,KEY_Q=quit_fenrir KEY_FENRIR,KEY_Q=quit_fenrir
KEY_FENRIR,KEY_T=time KEY_FENRIR,KEY_T=time
2,KEY_FENRIR,KEY_T=date 2,KEY_FENRIR,KEY_T=date
KEY_FENRIR,KEY_S=spell_check KEY_KP1=add_word_to_spell_check
2,KEY_FENRIR,KEY_S=add_word_to_spell_check KEY_KP2=remove_word_from_spell_check
KEY_FENRIR,KEY_SHIFT,KEY_S=remove_word_from_spell_check
KEY_FENRIR,KEY_BACKSPACE=forward_keypress KEY_FENRIR,KEY_BACKSPACE=forward_keypress
KEY_FENRIR,KEY_UP=inc_speech_volume KEY_FENRIR,KEY_UP=inc_speech_volume
KEY_FENRIR,KEY_DOWN=dec_speech_volume KEY_FENRIR,KEY_DOWN=dec_speech_volume

View File

@ -57,14 +57,14 @@ module=espeak
voice= voice=
# Select the language you want fenrir to use. # Select the language you want fenrir to use.
language=de language=english-us
# Read new text as it happens? # Read new text as it happens?
autoReadIncoming=True autoReadIncoming=True
[braille] [braille]
#braille is not implemented yet #braille is not implemented yet
enabled=True enabled=False
driver=brlapi driver=brlapi
layout=en layout=en
@ -83,7 +83,7 @@ device=AUTO
grabDevices=True grabDevices=True
ignoreShortcuts=False ignoreShortcuts=False
# the current shortcut layout located in /etc/fenrir/keyboard # the current shortcut layout located in /etc/fenrir/keyboard
keyboardLayout=test keyboardLayout=desktop
# echo chars while typing. # echo chars while typing.
charEcho=False charEcho=False
# echo deleted chars # echo deleted chars
@ -96,9 +96,9 @@ interruptOnKeyPress=False
doubleTapTimeout=0.2 doubleTapTimeout=0.2
[general] [general]
debugLevel=1 debugLevel=0
punctuationProfile=default punctuationProfile=default
punctuationLevel=Some punctuationLevel=some
numberOfClipboards=10 numberOfClipboards=10
emoticons=True emoticons=True
# define the current fenrir key # define the current fenrir key

View File

@ -6,6 +6,7 @@
from core import debug from core import debug
from utils import word_utils from utils import word_utils
import string
initialized = False initialized = False
try: try:
import enchant import enchant
@ -35,14 +36,13 @@ class command():
if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try: try:
self.updateSpellLanguage() self.updateSpellLanguage()
except: except Exception as e:
return return
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
# get the word # get the word
newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']] newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~')
if currWord != '': if currWord != '':
if self.spellChecker.is_added(currWord): if self.spellChecker.is_added(currWord):

View File

@ -6,6 +6,7 @@
from core import debug from core import debug
from utils import word_utils from utils import word_utils
import string
initialized = False initialized = False
try: try:
import enchant import enchant
@ -43,13 +44,12 @@ class command():
# get the word # get the word
newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']] newContent = self.env['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~')
if not currWord.isspace(): if not currWord.isspace():
if self.spellChecker.is_removed(currWord): if self.spellChecker.is_removed(currWord):
self.env['runtime']['outputManager'].presentText(currWord + ' is already removed from dict',soundIcon='Cancel', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' is already removed from dict',soundIcon='Cancel', interrupt=True)
else: else:
self.spellChecker.remove(currWord) self.spellChecker.remove(currWord)
self.env['runtime']['outputManager'].presentText(currWord + ' removed',soundIcon='Accept', interrupt=True) self.env['runtime']['outputManager'].presentText(currWord + ' removed',soundIcon='Accept', interrupt=True)
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -16,11 +16,11 @@ class command():
def shutdown(self): def shutdown(self):
pass pass
def getDescription(self): def getDescription(self):
return 'phonetically spells the current word' return 'phonetically spells the current word and set review to it'
def run(self): def run(self):
self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor()
x, y, currWord = \ self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord = \
word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText']) word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['newContentText'])
if currWord.isspace(): if currWord.isspace():
@ -29,7 +29,7 @@ class command():
firstSequence = True firstSequence = True
for c in currWord: for c in currWord:
currChar = char_utils.getPhonetic(c) currChar = char_utils.getPhonetic(c)
self.env['runtime']['outputManager'].presentText(currChar, interrupt=firstSequence) self.env['runtime']['outputManager'].presentText(currChar, interrupt=firstSequence, announceCapital=True)
firstSequence = False firstSequence = False
def setCallback(self, callback): def setCallback(self, callback):

View File

@ -127,3 +127,4 @@ class command():
def setCallback(self, callback): def setCallback(self, callback):
pass pass

View File

@ -12,7 +12,7 @@ class punctuationManager():
pass pass
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
self.allPunctNone = dict.fromkeys(map(ord, string.punctuation), ' ') self.allPunctNone = dict.fromkeys(map(ord, string.punctuation +"§"), ' ')
# replace with space: # replace with space:
# dot, comma, grave, apostrophe # dot, comma, grave, apostrophe
for char in [ord('.'),ord(','),ord('`'),ord("'")]: for char in [ord('.'),ord(','),ord('`'),ord("'")]: