Update spell_check.py
This commit is contained in:
parent
095ca33517
commit
68c216a845
@ -5,11 +5,11 @@ try:
|
|||||||
import enchant
|
import enchant
|
||||||
initialized = True
|
initialized = True
|
||||||
except:
|
except:
|
||||||
print('nööP')
|
pass
|
||||||
|
|
||||||
class command():
|
class command():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.language = ''
|
||||||
|
|
||||||
def run(self, environment):
|
def run(self, environment):
|
||||||
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'):
|
if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'):
|
||||||
@ -18,37 +18,23 @@ class command():
|
|||||||
if not initialized:
|
if not initialized:
|
||||||
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
|
environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)
|
||||||
return environment
|
return environment
|
||||||
spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
|
if environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage') != self.language:
|
||||||
|
try:
|
||||||
|
spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
|
||||||
|
except:
|
||||||
|
return environment
|
||||||
|
|
||||||
# just when cursor move worddetection is needed
|
if not newContent[environment['screenData']['newCursor']['x']].strip() == '':
|
||||||
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
|
||||||
return environment
|
return environment
|
||||||
|
|
||||||
# for now no new line
|
if (environment['screenData']['newCursorReview'] != None):
|
||||||
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']:
|
cursorPos = environment['screenData']['newCursorReview'].copy()
|
||||||
return environment
|
else:
|
||||||
if len(environment['screenData']['newDelta']) > 1:
|
cursorPos = environment['screenData']['newCursor'].copy()
|
||||||
return environment
|
|
||||||
|
|
||||||
# TTY Change is no new word
|
|
||||||
if environment['screenData']['newTTY'] != environment['screenData']['oldTTY']:
|
|
||||||
return environment
|
|
||||||
|
|
||||||
# first place could not be the end of a word
|
|
||||||
if environment['screenData']['newCursor']['x'] == 0:
|
|
||||||
return environment
|
|
||||||
|
|
||||||
# get the word
|
# get the word
|
||||||
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]
|
newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']]
|
||||||
x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['x'], 0, newContent)
|
x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], cursorPos['y'], newContent)
|
||||||
# was this a typed word?
|
|
||||||
if environment['screenData']['newDelta'] != '':
|
|
||||||
if not(newContent[environment['screenData']['oldCursor']['x']].strip() == '' and x != environment['screenData']['oldCursor']['x']):
|
|
||||||
return environment
|
|
||||||
else:
|
|
||||||
# or just arrow arround?
|
|
||||||
if not(newContent[environment['screenData']['newCursor']['x']].strip() == '' and x != environment['screenData']['newCursor']['x']):
|
|
||||||
return environment
|
|
||||||
|
|
||||||
if currWord != '':
|
if currWord != '':
|
||||||
if not spellChecker.check(currWord):
|
if not spellChecker.check(currWord):
|
||||||
|
Loading…
Reference in New Issue
Block a user