Ejemplo n.º 1
0
    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['screenData']['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)
Ejemplo n.º 2
0
    def run(self):
        self.env['runtime']['cursorManager'].enterReviewModeCurrTextCursor()

        self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], currWord, endOfScreen, lineBreak = \
          word_utils.getCurrentWord(self.env['screenData']['newCursorReview']['x'], self.env['screenData']['newCursorReview']['y'], self.env['screenData']['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')
Ejemplo n.º 3
0
    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['screenData']['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 already removed from dict').format(currWord, ),
                    soundIcon='Cancel',
                    interrupt=True)
            else:
                self.spellChecker.remove(currWord)
                self.env['runtime']['outputManager'].presentText(
                    _('{0} removed').format(currWord, ),
                    soundIcon='Accept',
                    interrupt=True)
Ejemplo n.º 4
0
    def run(self):
        # first place could not be the end of a word
        if self.env['screenData']['newCursor']['x'] == 0:
            return
        # is it enabled?
        if not self.env['runtime']['settingsManager'].getSettingAsBool(
                'keyboard', 'wordEcho'):
            return

        # just when cursor move worddetection is needed
        if not self.env['runtime']['cursorManager'].isCursorHorizontalMove():
            return
        if self.env['runtime']['inputManager'].noKeyPressed():
            return
        # for now no new line
        if self.env['runtime']['cursorManager'].isCursorVerticalMove():
            return
        # get the word
        newContent = self.env['screenData']['newContentText'].split('\n')[
            self.env['screenData']['newCursor']['y']]
        x, y, currWord, endOfScreen, lineBreak = \
          word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)
        # currently writing
        if self.env['runtime']['screenManager'].isDelta():
            return
        else:
            # at the end of a word
            if not newContent[self.env['screenData']['newCursor']
                              ['x']].isspace():
                return
            if (x + len(currWord) != self.env['screenData']['newCursor']['x']) and \
              (x + len(currWord) != self.env['screenData']['newCursor']['x']-1):
                return

        if currWord != '':
            self.env['runtime']['outputManager'].presentText(currWord,
                                                             interrupt=True,
                                                             flush=False)
Ejemplo n.º 5
0
    def run(self):
        if not initialized:
            return        
        if not self.env['runtime']['settingsManager'].getSettingAsBool('general', 'autoSpellCheck'):
            return
        if self.env['runtime']['inputManager'].noKeyPressed():
            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['screenData']['newDelta']) > 1:
            return            
        # deletion
        if self.env['runtime']['screenManager'].isNegativeDelta():
            return             
        # first place could not be the end of a word
        if self.env['screenData']['newCursor']['x'] == 0:
            return
            
        # get the word (just for speedup only look at current line
        newContent = self.env['screenData']['newContentText'].split('\n')[self.env['screenData']['newCursor']['y']]
        x, y, currWord, endOfScreen, lineBreak = word_utils.getCurrentWord(self.env['screenData']['newCursor']['x'], 0, newContent)                  
        # was this a typed word?
        if self.env['runtime']['screenManager'].isDelta():
            if not(newContent[self.env['screenData']['oldCursor']['x']] in string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~' and x != self.env['screenData']['oldCursor']['x']):
                return
            else:
                currWord = currWord.strip(string.whitespace + '!"#$%&()*+,-./:;<=>?@[\\]^_{|}~')
        else:
        # or just arrow arround?
            if not newContent[self.env['screenData']['newCursor']['x']].isspace():
                return
            if (x + len(currWord) != self.env['screenData']['newCursor']['x']) and \
              (x + len(currWord) != self.env['screenData']['newCursor']['x']-1):
                return  

        # just on end of word
        if self.env['screenData']['newCursor']['x'] > 0:
            if not newContent[self.env['screenData']['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)