Merge branch 'master' into inputHandlingRework
This commit is contained in:
commit
055d800023
BIN
config/sound/default/mispell.opus
Normal file
BIN
config/sound/default/mispell.opus
Normal file
Binary file not shown.
BIN
config/sound/default/mispell.wav
Normal file
BIN
config/sound/default/mispell.wav
Normal file
Binary file not shown.
@ -44,3 +44,5 @@ ErrorScreen='ErrorScreen.opus'
|
|||||||
HasAttributes='HasAttributes.opus'
|
HasAttributes='HasAttributes.opus'
|
||||||
# fenrir can promote strings if they appear on the screen.
|
# fenrir can promote strings if they appear on the screen.
|
||||||
PromotedText='PromotedText.opus'
|
PromotedText='PromotedText.opus'
|
||||||
|
# missspelled indicator
|
||||||
|
mispell='mispell.opus'
|
||||||
|
@ -44,3 +44,5 @@ ErrorScreen=''
|
|||||||
HasAttributes=''
|
HasAttributes=''
|
||||||
# fenrir can promote strings if they appear on the screen.
|
# fenrir can promote strings if they appear on the screen.
|
||||||
PromotedText=''
|
PromotedText=''
|
||||||
|
# misspelled indicator
|
||||||
|
mispell=''
|
||||||
|
@ -5,11 +5,12 @@ 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 = ''
|
||||||
|
self.spellChecker = None
|
||||||
|
|
||||||
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,42 +18,26 @@ 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
|
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
|
||||||
if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']:
|
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')
|
||||||
return environment
|
except:
|
||||||
|
return environment
|
||||||
# for now no new line
|
|
||||||
if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']:
|
if (environment['screenData']['newCursorReview'] != None):
|
||||||
return environment
|
cursorPos = environment['screenData']['newCursorReview'].copy()
|
||||||
if len(environment['screenData']['newDelta']) > 1:
|
else:
|
||||||
return environment
|
cursorPos = environment['screenData']['newCursor'].copy()
|
||||||
|
|
||||||
# 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'], 0, 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 self.spellChecker.check(currWord):
|
||||||
environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True)
|
environment['runtime']['outputManager'].presentText(environment, 'misspelled',soundIcon='mispell', interrupt=True)
|
||||||
|
|
||||||
return environment
|
return environment
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
|
@ -5,20 +5,26 @@ 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 = ''
|
||||||
|
self.spellChecker = ''
|
||||||
|
|
||||||
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'):
|
||||||
return environment
|
return environment
|
||||||
|
|
||||||
if not initialized:
|
if not initialized:
|
||||||
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:
|
||||||
|
self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage'))
|
||||||
|
self.language = environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')
|
||||||
|
except:
|
||||||
|
return environment
|
||||||
|
|
||||||
# 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
|
||||||
@ -50,8 +56,8 @@ class command():
|
|||||||
return environment
|
return environment
|
||||||
|
|
||||||
if currWord != '':
|
if currWord != '':
|
||||||
if not spellChecker.check(currWord):
|
if not self.spellChecker.check(currWord):
|
||||||
environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True)
|
environment['runtime']['outputManager'].presentText(environment, 'misspelled',soundIcon='mispell', interrupt=True)
|
||||||
|
|
||||||
return environment
|
return environment
|
||||||
def setCallback(self, callback):
|
def setCallback(self, callback):
|
||||||
|
Loading…
Reference in New Issue
Block a user