From 5ba0e5a992368a31d34b363500893065167670ba Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 16:47:51 +0200 Subject: [PATCH 1/6] Update settings.conf --- config/settings/settings.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 2af9544f..fe6f56ba 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -82,6 +82,8 @@ numberOfClipboards=10 # define the current fenrir key fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P +autoSpellCheck=True +spellCheckLanguage=en_US [promote] enabled=True From d918a4849f725a1fb1ae3180c9e77ad26e7b59a4 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 16:48:15 +0200 Subject: [PATCH 2/6] Update settings.conf.chrys --- config/settings/settings.conf.chrys | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys index a8cdc7f1..b4c37a8d 100644 --- a/config/settings/settings.conf.chrys +++ b/config/settings/settings.conf.chrys @@ -43,6 +43,8 @@ numberOfClipboards=10 fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P dateFormat="%A, %B %d, %Y" +autoSpellCheck=True +spellCheckLanguage=en_US [promote] enabled=True From 79249e8613f0b62db3f1c7b774b8d7bd3cd83384 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 16:48:50 +0200 Subject: [PATCH 3/6] Update settings.conf.orig --- config/settings/settings.conf.orig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/settings/settings.conf.orig b/config/settings/settings.conf.orig index 9265f1f0..70a1e45f 100644 --- a/config/settings/settings.conf.orig +++ b/config/settings/settings.conf.orig @@ -83,6 +83,8 @@ numberOfClipboards=10 fenrirKeys=KEY_KP0 timeFormat=%H:%M%P dateFormat="%A, %B %d, %Y" +autoSpellCheck=True +spellCheckLanguage=en_US [promote] enabled=True From 76f307df1a7a6cd6754d9b115ddba0e19d925d4a Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 16:49:15 +0200 Subject: [PATCH 4/6] Update settings.conf.storm --- config/settings/settings.conf.storm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/settings/settings.conf.storm b/config/settings/settings.conf.storm index 6365297c..da479490 100644 --- a/config/settings/settings.conf.storm +++ b/config/settings/settings.conf.storm @@ -43,6 +43,8 @@ numberOfClipboards=10 fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P dateFormat="%A, %B %d, %Y" +autoSpellCheck=True +spellCheckLanguage=en_US [promote] enabled=True From e920d55b42fdf3d580db323f6876ea6fd4b46263 Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 16:58:06 +0200 Subject: [PATCH 5/6] Create 62000-spell_check.py --- .../onScreenChanged/62000-spell_check.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/fenrir-package/commands/onScreenChanged/62000-spell_check.py diff --git a/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py new file mode 100644 index 00000000..6c2094b3 --- /dev/null +++ b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py @@ -0,0 +1,58 @@ +#!/bin/python +from utils import word_utils + +class command(): + def __init__(self): + self.initialized = False + try: + import enchant + self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) + self.initialized = True + except: + pass + + 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'): + return environment + + # just when cursor move worddetection is needed + if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: + return environment + + # for now no new line + if environment['screenData']['newCursor']['y'] != environment['screenData']['oldCursor']['y']: + return environment + if len(environment['screenData']['newDelta']) > 1: + 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 + newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] + x, y, currWord = word_utils.getCurrentWord(environment['screenData']['newCursor']['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 not self.spellChecker.check(currWord): + environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass From f65332ad2d3caff460f01b4305197ab752a2648c Mon Sep 17 00:00:00 2001 From: chrys87 Date: Mon, 5 Sep 2016 17:00:38 +0200 Subject: [PATCH 6/6] Update 62000-spell_check.py --- .../commands/onScreenChanged/62000-spell_check.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py index 6c2094b3..ba597aaf 100644 --- a/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py +++ b/src/fenrir-package/commands/onScreenChanged/62000-spell_check.py @@ -6,16 +6,18 @@ class command(): self.initialized = False try: import enchant - self.spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) self.initialized = True except: pass 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'): 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 if environment['screenData']['newCursor']['x'] == environment['screenData']['oldCursor']['x']: @@ -48,7 +50,7 @@ class command(): return environment if currWord != '': - if not self.spellChecker.check(currWord): + if not spellChecker.check(currWord): environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True) return environment