def run(self): if not initialized: self.env['runtime']['outputManager'].presentText( _('pyenchant is not installed'), interrupt=True) return if self.env['runtime']['settingsManager'].getSetting( 'general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except: return cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor( ) # get the word newContent = self.env['screen']['newContentText'].split('\n')[ cursorPos['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord( cursorPos['x'], 0, newContent) if not currWord.isspace(): if not self.spellChecker.check(currWord): self.env['runtime']['outputManager'].presentText( _('misspelled'), soundIcon='mispell', interrupt=True) elif not ignore: self.env['runtime']['outputManager'].presentText( _('correct'), soundIcon='', interrupt=True)
def run(self): if not initialized: self.env['runtime']['outputManager'].presentText( _('pyenchant is not installed'), interrupt=True) return if self.env['runtime']['settingsManager'].getSetting( 'general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except: return cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor( ) # get the word newContent = self.env['screen']['newContentText'].split('\n')[ cursorPos['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord( cursorPos['x'], 0, newContent) currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~') if not currWord.isspace(): if self.spellChecker.is_removed(currWord): self.env['runtime']['outputManager'].presentText( _('{0} is not in the dictionary').format(currWord, ), soundIcon='Cancel', interrupt=True) else: self.spellChecker.remove(currWord) self.env['runtime']['outputManager'].presentText( _('{0} removed').format(currWord, ), soundIcon='Accept', interrupt=True)
def run(self): # is navigation? if not abs(self.env['screen']['oldCursor']['x'] - self.env['screen']['newCursor']['x']) > 1: return # just when cursor move worddetection is needed if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): return # for now no new line if self.env['runtime']['cursorManager'].isCursorVerticalMove(): return # currently writing if self.env['runtime']['screenManager'].isDelta(): return # get the word newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] x, y, currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) # is there a word? if currWord == '': return # at the start of a word if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ (self.env['screen']['newCursor']['x'] != x): return self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
def run(self): # is it enabled? if not self.env['runtime']['settingsManager'].getSettingAsBool('keyboard', 'wordEcho'): return # is naviation? if self.env['screen']['newCursor']['x'] - self.env['screen']['oldCursor']['x'] != 1: return # just when cursor move worddetection is needed if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): return # for now no new line if self.env['runtime']['cursorManager'].isCursorVerticalMove(): return # currently writing if self.env['runtime']['screenManager'].isDelta(): return # get the word newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] x, y, currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) # is there a word? if currWord == '': return # at the end of a word if not newContent[self.env['screen']['newCursor']['x']].isspace(): return # at the end of a word if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ (x + len(currWord) != self.env['screen']['newCursor']['x']-1): return self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False)
def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) if currWord.isspace(): self.env['runtime']['outputManager'].presentText(_("blank"), interrupt=True, flush=False) else: firstSequence = True for c in currWord: currChar = char_utils.getPhonetic(c) self.env['runtime']['outputManager'].presentText( currChar, interrupt=firstSequence, announceCapital=True, flush=False) firstSequence = False if endOfScreen: if self.env['runtime']['settingsManager'].getSettingAsBool( 'review', 'endOfScreen'): self.env['runtime']['outputManager'].presentText( _('end of screen'), interrupt=True, soundIcon='EndOfScreen') if lineBreak: if self.env['runtime']['settingsManager'].getSettingAsBool( 'review', 'lineBreak'): self.env['runtime']['outputManager'].presentText( _('line break'), interrupt=False, soundIcon='EndOfLine')
def run(self): self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor() self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], currWord, endOfScreen, lineBreak = \ word_utils.getCurrentWord(self.env['screen']['newCursorReview']['x'], self.env['screen']['newCursorReview']['y'], self.env['screen']['newContentText']) if currWord.isspace(): self.env['runtime']['outputManager'].presentText(_("blank"), interrupt=True, flush=False) else: self.env['runtime']['outputManager'].presentText(currWord, interrupt=True, flush=False) if endOfScreen: if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'endOfScreen'): self.env['runtime']['outputManager'].presentText(_('end of screen'), interrupt=True, soundIcon='EndOfScreen') if lineBreak: if self.env['runtime']['settingsManager'].getSettingAsBool('review', 'lineBreak'): self.env['runtime']['outputManager'].presentText(_('line break'), interrupt=False, soundIcon='EndOfLine')
def run(self): if not initialized: self.env['runtime']['outputManager'].presentText(_('pyenchant is not installed'), interrupt=True) return if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except: return cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() # get the word newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) if not currWord.isspace(): if not self.spellChecker.check(currWord): self.env['runtime']['outputManager'].presentText(_('misspelled'),soundIcon='mispell', interrupt=True) elif not ignore: self.env['runtime']['outputManager'].presentText(_('correct'),soundIcon='', interrupt=True)
def run(self): if not initialized: self.env['runtime']['outputManager'].presentText(_('pyenchant is not installed'), interrupt=True) return if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except Exception as e: return cursorPos = self.env['runtime']['cursorManager'].getReviewOrTextCursor() # get the word newContent = self.env['screen']['newContentText'].split('\n')[cursorPos['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(cursorPos['x'], 0, newContent) currWord = currWord.strip(string.whitespace + '!"#$%&\()*+,-./:;<=§>?@[\\]^_{|}~') if currWord != '': if self.spellChecker.is_added(currWord): self.env['runtime']['outputManager'].presentText(_('{0} is already in dictionary').format(currWord,), soundIcon='Cancel', interrupt=True) else: self.spellChecker.add(currWord) self.env['runtime']['outputManager'].presentText(_('{0} added to dictionary').format(currWord,), soundIcon='Accept', interrupt=True)
def run(self): if not initialized: return if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'): return if self.env['runtime']['settingsManager'].getSetting('general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except: return # just when horizontal cursor move worddetection is needed if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): return # for now no new line if self.env['runtime']['cursorManager'].isCursorVerticalMove(): return # more than a keyecho? if len(self.env['screen']['newDelta']) > 1: return # deletion if self.env['runtime']['screenManager'].isNegativeDelta(): return # first place could not be the end of a word if self.env['screen']['newCursor']['x'] == 0: return # get the word (just for speedup only look at current line newContent = self.env['screen']['newContentText'].split('\n')[self.env['screen']['newCursor']['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screen']['newCursor']['x'], 0, newContent) # was this a typed word? if self.env['runtime']['screenManager'].isDelta(): if not(newContent[self.env['screen']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']): return else: currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~') else: # or just arrow arround? if not newContent[self.env['screen']['newCursor']['x']].isspace(): return if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ (x + len(currWord) != self.env['screen']['newCursor']['x']-1): return # just on end of word if self.env['screen']['newCursor']['x'] > 0: if not newContent[self.env['screen']['oldCursor']['x'] - 1].lower() in string.ascii_lowercase: return # ignore bash buildins if currWord in ['cd','fg','bg','alias','bind','dir','caller','buildin','command','declare','echo','enable','help','let','local','logout',\ 'mapfile','printf','read','readarray','source','type','typeset','ulimit','unalias']: return # ignore the application name if currWord.upper() == 'FENRIR': return if currWord[0] =='-': return if currWord[0] == '/': return if currWord[0] == '#': return if currWord.startswith('./'): return if '@' in currWord and '.' in currWord: return if currWord[0] == '@': return if currWord.isnumeric(): return if currWord.isdecimal(): return if currWord.isspace(): return try: if os.path.exists("/bin/"+currWord): return except: pass try: if os.path.exists("/usr/bin/"+currWord): return except: pass try: if os.path.exists("/sbin/"+currWord): return except: pass if not self.spellChecker.check(currWord): self.env['runtime']['outputManager'].presentText(_('misspelled'), soundIcon='mispell', interrupt=False, flush=False)
def run(self): if not initialized: return if not self.env['runtime']['settingsManager'].getSettingAsBool( 'general', 'autoSpellCheck'): return if self.env['runtime']['settingsManager'].getSetting( 'general', 'spellCheckLanguage') != self.language: try: self.updateSpellLanguage() except: return # just when horizontal cursor move worddetection is needed if not self.env['runtime']['cursorManager'].isCursorHorizontalMove(): return # for now no new line if self.env['runtime']['cursorManager'].isCursorVerticalMove(): return # more than a keyecho? if len(self.env['screen']['newDelta']) > 1: return # deletion if self.env['runtime']['screenManager'].isNegativeDelta(): return # first place could not be the end of a word if self.env['screen']['newCursor']['x'] == 0: return # get the word (just for speedup only look at current line newContent = self.env['screen']['newContentText'].split('\n')[ self.env['screen']['newCursor']['y']] x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord( self.env['screen']['newCursor']['x'], 0, newContent) # was this a typed word? if self.env['runtime']['screenManager'].isDelta(): if not (newContent[self.env['screen']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screen']['oldCursor']['x']): return else: currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~') else: # or just arrow arround? if not newContent[self.env['screen']['newCursor']['x']].isspace(): return if (x + len(currWord) != self.env['screen']['newCursor']['x']) and \ (x + len(currWord) != self.env['screen']['newCursor']['x']-1): return # just on end of word if self.env['screen']['newCursor']['x'] > 0: if not newContent[self.env['screen']['oldCursor']['x'] - 1].lower() in string.ascii_lowercase: return # ignore bash buildins if currWord in ['cd','fg','bg','alias','bind','dir','caller','buildin','command','declare','echo','enable','help','let','local','logout',\ 'mapfile','printf','read','readarray','source','type','typeset','ulimit','unalias']: return # ignore the application name if currWord.upper() == 'FENRIR': return if currWord[0] == '-': return if currWord[0] == '/': return if currWord[0] == '#': return if currWord.startswith('./'): return if '@' in currWord and '.' in currWord: return if currWord[0] == '@': return if currWord.isnumeric(): return if currWord.isdecimal(): return if currWord.isspace(): return try: if os.path.exists("/bin/" + currWord): return except: pass try: if os.path.exists("/usr/bin/" + currWord): return except: pass try: if os.path.exists("/sbin/" + currWord): return except: pass if not self.spellChecker.check(currWord): self.env['runtime']['outputManager'].presentText( _('misspelled'), soundIcon='mispell', interrupt=False, flush=False)