Update 62000-spell_check.py

This commit is contained in:
chrys87 2016-09-05 17:00:38 +02:00 committed by GitHub
parent e920d55b42
commit f65332ad2d

View File

@ -6,17 +6,19 @@ class command():
self.initialized = False self.initialized = False
try: try:
import enchant import enchant
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
self.initialized = True self.initialized = True
except: except:
pass pass
def run(self, environment): def run(self, environment):
if not self.initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'):
return environment return environment
if not self.initialized:
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
# just when cursor move worddetection is needed # just when cursor move worddetection is needed
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
return environment return environment
@ -48,7 +50,7 @@ class command():
return environment return environment
if currWord != '': if currWord != '':
if not self.spellChecker.check(currWord): if not spellChecker.check(currWord):
environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True) environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True)
return environment return environment