def complete_possible(cursor): """ Determine whether there is text before the cursor position that may be completed. :param cursor: position. :return: True if there is non-whitespace text immediately before the cursor. """ text = get_block_plain_text(cursor.block()) return bool(text[: cursor.columnNumber()].strip())
def highlightBlock(self, string): """ Highlight a block of text. Reimplemented to highlight selectively. """ if self._highlighting_on: # The input to this function is a unicode string that may contain # paragraph break characters, non-breaking spaces, etc. Here we acquire # the string as plain text so we can compare it. current_block = self.currentBlock() string = get_block_plain_text(current_block) super(SelectiveHighlighter, self).highlightBlock(string[self._current_offset:])