From e5306fb43b28a9c46fe3b2a2f07d919cdcfc69c2 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 6 Sep 2016 22:37:55 +0200 Subject: [PATCH 1/4] fix spell command --- config/keyboard/test.conf | 2 +- config/settings/settings.conf | 61 +++---------------- config/settings/settings.conf.chrys | 52 ---------------- .../commands/commands/spell_check.py | 5 +- 4 files changed, 12 insertions(+), 108 deletions(-) delete mode 100644 config/settings/settings.conf.chrys diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 6f34de67..4c04afdb 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -28,7 +28,7 @@ #=quit_fenrir 1-FENRIR,1-KEY_T=time 1-FENRIR,1-KEY_R=date -#=spell_check +1-FENRIR,1-KEY_M=spell_check 1-FENRIR,1-KEY_A=foreward_keypress #1-FENRIR,1-KEY_F2=inc_speech_volume #1-FENRIR,1-KEY_F3=dec_sound_volume diff --git a/config/settings/settings.conf b/config/settings/settings.conf index 93e83f44..b4c37a8d 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -1,54 +1,21 @@ [sound] -# Turn sound on or off: enabled=True - -# Select the driver used to play sounds, choices are sox and gstreamer. -# Sox is the default. driver=sox - -# Sound themes. This is the pack of sounds used for sound alerts. -# Sound packs may be located at /usr/share/sounds -# For system wide availability, or ~/.local/share/fenrir/sounds -# For the current user. theme=default - -# Sound volume controls how loud the sounds for your chosen soundpack are. -# 0 is quietest, 1.0 is loudest. volume=1.0 [speech] -# Turn speech on or off: enabled=True - -# Select speech driver, options are speechd (default) or espeak: driver=speechd - -# The rate selects how fast fenrir will speak. Options range from 0, slowest, to 1.0, fastest. -rate=0.45 - -# Pitch controls the pitch of the voice, select from 0, lowest, to 1.0, highest. +rate=0.75 pitch=0.5 - -# Volume controls the loudness of the voice, select from 0, quietest, to 1.0, loudest. -volume=1.0 - -# Module is used for speech-dispatcher, to select the speech module you want to use. -# Consult speech-dispatcher's configuration and help ti find out which modules are available. -# The default is espeak. module=espeak - -# Voice selects the varient you want to use, for example, f5 will use the female voice #5 in espeak, -# or if using the espeak module in speech-dispatcher. To find out which voices are available, consult the documentation provided with your chosen synthesizer. -voice= - -# Select the language you want fenrir to use. -language=english-us - -# Read new text as it happens? +voice=de +language=de +volume=0.8 autoReadIncomming=True [braille] -#braille is not implemented yet enabled=False layout=en @@ -61,33 +28,25 @@ autodetectSuspendingScreen=False [keyboard] device=all -# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. grabDevices=True ignoreShortcuts=False -# the current shortcut layout located in /etc/fenrir/keyboard -keyboardLayout=desktop -# echo chars while typing. -charEcho=False -# echo deleted chars +keyboardLayout=test +charEcho=True charDeleteEcho=True -# echo word after pressing space -wordEcho=False -# interrupt speech on any keypress +wordEcho=True interruptOnKeyPress=False [general] -debugLevel=0 +debugLevel=1 punctuationLevel=1 numberOfClipboards=10 -# define the current fenrir key fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P +dateFormat="%A, %B %d, %Y" autoSpellCheck=True spellCheckLanguage=en_US [promote] enabled=True inactiveTimeoutSec=120 -list= - - +list=chrys,test diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys deleted file mode 100644 index b4c37a8d..00000000 --- a/config/settings/settings.conf.chrys +++ /dev/null @@ -1,52 +0,0 @@ -[sound] -enabled=True -driver=sox -theme=default -volume=1.0 - -[speech] -enabled=True -driver=speechd -rate=0.75 -pitch=0.5 -module=espeak -voice=de -language=de -volume=0.8 -autoReadIncomming=True - -[braille] -enabled=False -layout=en - -[screen] -driver=linux -encoding=cp850 -screenUpdateDelay=0.4 -suspendingScreen=1,2 -autodetectSuspendingScreen=False - -[keyboard] -device=all -grabDevices=True -ignoreShortcuts=False -keyboardLayout=test -charEcho=True -charDeleteEcho=True -wordEcho=True -interruptOnKeyPress=False - -[general] -debugLevel=1 -punctuationLevel=1 -numberOfClipboards=10 -fenrirKeys=KEY_KP0 -timeFormat=%H:%M:%P -dateFormat="%A, %B %d, %Y" -autoSpellCheck=True -spellCheckLanguage=en_US - -[promote] -enabled=True -inactiveTimeoutSec=120 -list=chrys,test diff --git a/src/fenrir-package/commands/commands/spell_check.py b/src/fenrir-package/commands/commands/spell_check.py index 0d8a1f1c..2bc2cc01 100644 --- a/src/fenrir-package/commands/commands/spell_check.py +++ b/src/fenrir-package/commands/commands/spell_check.py @@ -13,9 +13,6 @@ class command(): self.spellChecker = None def run(self, environment): - if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'general', 'autoSpellCheck'): - return environment - if not initialized: environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True) return environment @@ -32,7 +29,7 @@ class command(): cursorPos = environment['screenData']['newCursor'].copy() # get the word - newContent = environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']] + newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']] x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) if currWord != '': From fc3d54369e15118fe3db7dbb5549c0c320f5bcc2 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 6 Sep 2016 22:39:13 +0200 Subject: [PATCH 2/4] fix spell command --- config/keyboard/test.conf | 4 +-- config/settings/settings.conf | 61 +++++++++++++++++++++++++++++------ 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index 4c04afdb..e92b385c 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -22,13 +22,13 @@ 1-FENRIR,1-KEY_F2=toggle_braille #1-FENRIR,1-KEY_F3=toggle_sound 1-FENRIR,1-KEY_F4=toggle_speech -#=toggle_auto_spell_check +1-FENRIR,1-KEY_M=toggle_auto_spell_check #=toggle_output #=toggle_auto_read #=quit_fenrir 1-FENRIR,1-KEY_T=time 1-FENRIR,1-KEY_R=date -1-FENRIR,1-KEY_M=spell_check +#=spell_check 1-FENRIR,1-KEY_A=foreward_keypress #1-FENRIR,1-KEY_F2=inc_speech_volume #1-FENRIR,1-KEY_F3=dec_sound_volume diff --git a/config/settings/settings.conf b/config/settings/settings.conf index b4c37a8d..93e83f44 100644 --- a/config/settings/settings.conf +++ b/config/settings/settings.conf @@ -1,21 +1,54 @@ [sound] +# Turn sound on or off: enabled=True + +# Select the driver used to play sounds, choices are sox and gstreamer. +# Sox is the default. driver=sox + +# Sound themes. This is the pack of sounds used for sound alerts. +# Sound packs may be located at /usr/share/sounds +# For system wide availability, or ~/.local/share/fenrir/sounds +# For the current user. theme=default + +# Sound volume controls how loud the sounds for your chosen soundpack are. +# 0 is quietest, 1.0 is loudest. volume=1.0 [speech] +# Turn speech on or off: enabled=True + +# Select speech driver, options are speechd (default) or espeak: driver=speechd -rate=0.75 + +# The rate selects how fast fenrir will speak. Options range from 0, slowest, to 1.0, fastest. +rate=0.45 + +# Pitch controls the pitch of the voice, select from 0, lowest, to 1.0, highest. pitch=0.5 + +# Volume controls the loudness of the voice, select from 0, quietest, to 1.0, loudest. +volume=1.0 + +# Module is used for speech-dispatcher, to select the speech module you want to use. +# Consult speech-dispatcher's configuration and help ti find out which modules are available. +# The default is espeak. module=espeak -voice=de -language=de -volume=0.8 + +# Voice selects the varient you want to use, for example, f5 will use the female voice #5 in espeak, +# or if using the espeak module in speech-dispatcher. To find out which voices are available, consult the documentation provided with your chosen synthesizer. +voice= + +# Select the language you want fenrir to use. +language=english-us + +# Read new text as it happens? autoReadIncomming=True [braille] +#braille is not implemented yet enabled=False layout=en @@ -28,25 +61,33 @@ autodetectSuspendingScreen=False [keyboard] device=all +# gives fenrir exclusive access to the keyboard and let consume keystrokes. just disable on problems. grabDevices=True ignoreShortcuts=False -keyboardLayout=test -charEcho=True +# the current shortcut layout located in /etc/fenrir/keyboard +keyboardLayout=desktop +# echo chars while typing. +charEcho=False +# echo deleted chars charDeleteEcho=True -wordEcho=True +# echo word after pressing space +wordEcho=False +# interrupt speech on any keypress interruptOnKeyPress=False [general] -debugLevel=1 +debugLevel=0 punctuationLevel=1 numberOfClipboards=10 +# define the current fenrir key fenrirKeys=KEY_KP0 timeFormat=%H:%M:%P -dateFormat="%A, %B %d, %Y" autoSpellCheck=True spellCheckLanguage=en_US [promote] enabled=True inactiveTimeoutSec=120 -list=chrys,test +list= + + From 34d367612d2ce3d27158c23176937744ad0769a5 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 6 Sep 2016 23:26:55 +0200 Subject: [PATCH 3/4] add command for adding word to spellcheck dict --- config/keyboard/desktop.conf | 1 + config/keyboard/laptop.conf | 1 + config/keyboard/test.conf | 5 +- .../commands/add_word_to_spell_check.py | 49 +++++++++++++++++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 src/fenrir-package/commands/commands/add_word_to_spell_check.py diff --git a/config/keyboard/desktop.conf b/config/keyboard/desktop.conf index 602a228b..dd38fb0b 100644 --- a/config/keyboard/desktop.conf +++ b/config/keyboard/desktop.conf @@ -29,6 +29,7 @@ 1-FENRIR,1-KEY_T=time 1-FENRIR,1-KEY_D=date #=spell_check +#=add_word_to_spell_check #=foreward_keypress #=inc_speech_volume #=dec_speech_volume diff --git a/config/keyboard/laptop.conf b/config/keyboard/laptop.conf index 623868b1..67fce7af 100644 --- a/config/keyboard/laptop.conf +++ b/config/keyboard/laptop.conf @@ -29,6 +29,7 @@ #=time #=date #=spell_check +#=add_word_to_spell_check #=foreward_keypress #=inc_speech_volume #=dec_speech_volume diff --git a/config/keyboard/test.conf b/config/keyboard/test.conf index e92b385c..d5222512 100644 --- a/config/keyboard/test.conf +++ b/config/keyboard/test.conf @@ -28,7 +28,8 @@ #=quit_fenrir 1-FENRIR,1-KEY_T=time 1-FENRIR,1-KEY_R=date -#=spell_check +1-FENRIR,1-KEY_M=spell_check +1-FENRIR,1-KEY_G=add_word_to_spell_check 1-FENRIR,1-KEY_A=foreward_keypress #1-FENRIR,1-KEY_F2=inc_speech_volume #1-FENRIR,1-KEY_F3=dec_sound_volume @@ -44,7 +45,7 @@ 1-FENRIR,1-KEY_S=last_clipboard 1-FENRIR,1-KEY_D=prev_clipboard 1-FENRIR,1-KEY_F=next_clipboard -1-FENRIR,1-KEY_G=curr_clipboard +#=curr_clipboard 1-FENRIR,1-KEY_Q=set_mark #1-FENRIR,1-KEY_V=marked_text 1-FENRIR,1-KEY_V=copy_marked_to_clipboard diff --git a/src/fenrir-package/commands/commands/add_word_to_spell_check.py b/src/fenrir-package/commands/commands/add_word_to_spell_check.py new file mode 100644 index 00000000..656a811f --- /dev/null +++ b/src/fenrir-package/commands/commands/add_word_to_spell_check.py @@ -0,0 +1,49 @@ +#!/bin/python +from utils import word_utils +initialized = False +try: + import enchant + initialized = True +except: + pass + +class command(): + def __init__(self): + self.language = '' + self.spellChecker = None + + def run(self, environment): + if not initialized: + environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True) + return environment + 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 + + if (environment['screenData']['newCursorReview'] != None): + cursorPos = environment['screenData']['newCursorReview'].copy() + else: + cursorPos = environment['screenData']['newCursor'].copy() + + # get the word + newContent = environment['screenData']['newContentText'].split('\n')[cursorPos['y']] + x, y, currWord = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) + + if currWord != '': + if self.spellChecker.check(currWord): + environment['runtime']['outputManager'].presentText(environment, 'not misspelled',soundIcon='mispell', interrupt=True) + else: + if self.spellChecker.is_added(currWord): + environment['runtime']['outputManager'].presentText(environment, 'not misspelled',soundIcon='Cancel', interrupt=True) + else: + self.spellChecker.add(currWord) + environment['runtime']['outputManager'].presentText(environment, currWord + ' added',soundIcon='Accept', interrupt=True) + + return environment + def setCallback(self, callback): + pass + def shutdown(self): + pass From e4a43931e88d72ee6bf5624371fb6e1a93241a64 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 6 Sep 2016 23:28:23 +0200 Subject: [PATCH 4/4] add my config --- config/settings/settings.conf.chrys | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 config/settings/settings.conf.chrys diff --git a/config/settings/settings.conf.chrys b/config/settings/settings.conf.chrys new file mode 100644 index 00000000..b4c37a8d --- /dev/null +++ b/config/settings/settings.conf.chrys @@ -0,0 +1,52 @@ +[sound] +enabled=True +driver=sox +theme=default +volume=1.0 + +[speech] +enabled=True +driver=speechd +rate=0.75 +pitch=0.5 +module=espeak +voice=de +language=de +volume=0.8 +autoReadIncomming=True + +[braille] +enabled=False +layout=en + +[screen] +driver=linux +encoding=cp850 +screenUpdateDelay=0.4 +suspendingScreen=1,2 +autodetectSuspendingScreen=False + +[keyboard] +device=all +grabDevices=True +ignoreShortcuts=False +keyboardLayout=test +charEcho=True +charDeleteEcho=True +wordEcho=True +interruptOnKeyPress=False + +[general] +debugLevel=1 +punctuationLevel=1 +numberOfClipboards=10 +fenrirKeys=KEY_KP0 +timeFormat=%H:%M:%P +dateFormat="%A, %B %d, %Y" +autoSpellCheck=True +spellCheckLanguage=en_US + +[promote] +enabled=True +inactiveTimeoutSec=120 +list=chrys,test