Merge branch 'master' into inputHandlingRework

This commit is contained in:
chrys 2016-09-06 23:28:37 +02:00
commit 6b570dcbcc
5 changed files with 56 additions and 7 deletions

View File

@ -29,6 +29,7 @@
1-FENRIR,1-KEY_T=time
1-FENRIR,1-KEY_D=date
#=spell_check
#=add_word_to_spell_check
#=foreward_keypress
#=inc_speech_volume
#=dec_speech_volume

View File

@ -29,6 +29,7 @@
#=time
#=date
#=spell_check
#=add_word_to_spell_check
#=foreward_keypress
#=inc_speech_volume
#=dec_speech_volume

View File

@ -22,13 +22,14 @@
1-FENRIR,1-KEY_F2=toggle_braille
#1-FENRIR,1-KEY_F3=toggle_sound
1-FENRIR,1-KEY_F4=toggle_speech
#=toggle_auto_spell_check
1-FENRIR,1-KEY_M=toggle_auto_spell_check
#=toggle_output
#=toggle_auto_read
#=quit_fenrir
1-FENRIR,1-KEY_T=time
1-FENRIR,1-KEY_R=date
#=spell_check
1-FENRIR,1-KEY_M=spell_check
1-FENRIR,1-KEY_G=add_word_to_spell_check
1-FENRIR,1-KEY_A=foreward_keypress
#1-FENRIR,1-KEY_F2=inc_speech_volume
#1-FENRIR,1-KEY_F3=dec_sound_volume
@ -44,7 +45,7 @@
1-FENRIR,1-KEY_S=last_clipboard
1-FENRIR,1-KEY_D=prev_clipboard
1-FENRIR,1-KEY_F=next_clipboard
1-FENRIR,1-KEY_G=curr_clipboard
#=curr_clipboard
1-FENRIR,1-KEY_Q=set_mark
#1-FENRIR,1-KEY_V=marked_text
1-FENRIR,1-KEY_V=copy_marked_to_clipboard

View File

@ -0,0 +1,49 @@
#!/bin/python
from utils import word_utils
initialized = False
try:
import enchant
initialized = True
except:
pass
class command():
def __init__(self):
self.language = ''
self.spellChecker = None
def run(self, environment):
if not initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
return environment
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language:
try:
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')
except:
return environment
if (environment['screenData']['newCursorReview'] != None):
cursorPos = environment['screenData']['newCursorReview'].copy()
else:
cursorPos = environment['screenData']['newCursor'].copy()
# get the word
newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
if currWord != '':
if self.spellChecker.check(currWord):
environment['runtime']['outputManager'].presentText(environment, 'not misspelled',soundIcon='mispell', interrupt=True)
else:
if self.spellChecker.is_added(currWord):
environment['runtime']['outputManager'].presentText(environment, 'not misspelled',soundIcon='Cancel', interrupt=True)
else:
self.spellChecker.add(currWord)
environment['runtime']['outputManager'].presentText(environment, currWord + ' added',soundIcon='Accept', interrupt=True)
return environment
def setCallback(self, callback):
pass
def shutdown(self):
pass

View File

@ -13,9 +13,6 @@ class command():
self.spellChecker = None
def run(self, environment):
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'):
return environment
if not initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
return environment
@ -32,7 +29,7 @@ class command():
cursorPos = environment['screenData']['newCursor'].copy()
# get the word
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]
newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']]
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent)
if currWord != '':