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'):
|
||||||
@ -17,38 +17,24 @@ 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:
|
||||||
# just when cursor move worddetection is needed
|
spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
|
||||||
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
except:
|
||||||
return environment
|
return environment
|
||||||
|
|
||||||
# for now no new line
|
if not newContent[environment['screenData']['newCursor']['x']].strip() == '':
|
||||||
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']:
|
return environment
|
||||||
return environment
|
|
||||||
if len(environment['screenData']['newDelta']) > 1:
|
if (environment['screenData']['newCursorReview'] != None):
|
||||||
return environment
|
cursorPos = environment['screenData']['newCursorReview'].copy()
|
||||||
|
else:
|
||||||
# TTY Change is no new word
|
cursorPos = environment['screenData']['newCursor'].copy()
|
||||||
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