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

@ -6,6 +6,7 @@
from core import debug
from utils import word_utils
import string
initialized = False
try:
import enchant
@ -35,14 +36,13 @@ class command():
if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language:
try:
self.updateSpellLanguage()
except:
except Exception as e:
return
cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor()
# get the word
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 self.spellChecker.is_added(currWord):

View File

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

View File

@ -16,11 +16,11 @@ class command():
def shutdown(self):
pass
def getDescription(self):
return 'phonetically spells the current word'
return 'phonetically spells the current word and set review to it'
def run(self):
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'])
if currWord.isspace():
@ -29,7 +29,7 @@ class command():
firstSequence = True
for c in currWord:
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
def setCallback(self, callback):

View File

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

View File

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