def highlightBlock(self, text): # Function for formatting if not self.dict: # the text inside this text return # edit field, sets the format formats = QTextCharFormat() # of the text that not match formats.setUnderlineColor(Qt.red) # to the dicts. Red underline. formats.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) for w in re.finditer(self.words, text): if not self.dict.check(w.group()): self.setFormat(w.start(), w.end() - w.start(), formats)
def highlightBlock(self, text): if not self.dict: return format = QTextCharFormat() format.setUnderlineColor(Qt.red) format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) for word_object in re.finditer(self.WORDS, text): if not self.dict.check(word_object.group()): self.setFormat(word_object.start(), word_object.end() - word_object.start(), format)
def highlightBlock(self, text): words = re.compile('[^_\\W]+', flags=re.UNICODE) char_format = QTextCharFormat() char_format.setUnderlineColor(Qt.red) char_format.setUnderlineStyle(QTextCharFormat.SpellCheckUnderline) # collect data for checking mark = [] for match in words.finditer(text): final_format = QTextCharFormat() final_format.merge(char_format) final_format.merge(self.format(match.start())) if self._dictionary.word_needs_no_verification(match.group(0)): continue mark.append((match.group(0).lower(), match.start(), match.end() - match.start(), final_format)) # word check for word, start, length, fmt in mark: if not self._dictionary.check_word(word): self.setFormat(start, length, fmt)