Merge branch 'master' into inputHandlingRework
This commit is contained in:
		| @@ -25,8 +25,9 @@ | ||||
| #=toggle_output | ||||
| #=toggle_autoRead | ||||
| 1-FENRIR,1-KEY_Q=quit_fenrir | ||||
| `-FENRIR,1-KEY_T=time | ||||
| 1-FENRIR,1-KEY_T=time | ||||
| 1-FENRIR,1-KEY_D=date | ||||
| #=spell_check | ||||
| #=foreward_keypress | ||||
| #=inc_speech_volume | ||||
| #=dec_speech_volume | ||||
|   | ||||
| @@ -26,6 +26,8 @@ | ||||
| #=toggle_autoRead | ||||
| #=quit_fenrir | ||||
| #=time | ||||
| #=date | ||||
| #=spell_check | ||||
| #=foreward_keypress | ||||
| #=inc_speech_volume | ||||
| #=dec_speech_volume | ||||
|   | ||||
| @@ -27,6 +27,7 @@ | ||||
| #=quit_fenrir | ||||
| 1-FENRIR,1-KEY_T=time | ||||
| 1-FENRIR,1-KEY_R=date | ||||
| #=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 | ||||
|   | ||||
							
								
								
									
										61
									
								
								src/fenrir-package/commands/commands/spell_check.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								src/fenrir-package/commands/commands/spell_check.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| #!/bin/python | ||||
| from utils import word_utils | ||||
| initialized = False | ||||
| try: | ||||
|     import enchant | ||||
|     initialized = True | ||||
| except: | ||||
|     print('nööP') | ||||
|      | ||||
| class command(): | ||||
|     def __init__(self): | ||||
|         pass | ||||
|      | ||||
|     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       | ||||
|         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']: | ||||
|             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 spellChecker.check(currWord): | ||||
|                 environment['runtime']['outputManager'].presentText(environment, 'misspelled', interrupt=True) | ||||
|  | ||||
|         return environment | ||||
|     def setCallback(self, callback): | ||||
|         pass | ||||
|     def shutdown(self): | ||||
|         pass | ||||
| @@ -16,7 +16,6 @@ class command(): | ||||
|             return environment | ||||
|  | ||||
|         if not initialized: | ||||
|            environment['runtime']['outputManager'].presentText(environment, 'pychant is not installed', interrupt=True)  | ||||
|            return environment       | ||||
|         spellChecker = enchant.Dict(environment['runtime']['settingsManager'].getSetting(environment, 'general', 'spellCheckLanguage')) | ||||
|     | ||||
|   | ||||
		Reference in New Issue
	
	Block a user