def _get_line(self, editor_cursor, lines=1): """Return the line at cursor position.""" try: cursor = QTextCursor(editor_cursor) except TypeError: print("ERROR: editor_cursor must be an instance of QTextCursor") else: cursor.movePosition(QTextCursor.StartOfLine) cursor.movePosition(QTextCursor.Down, QTextCursor.KeepAnchor, n=lines) line = cursor.selectedText() return line
def is_cell_separator(self, cursor=None, block=None): """Return True if cursor (or text block) is on a block separator""" assert cursor is not None or block is not None if cursor is not None: cursor0 = QTextCursor(cursor) cursor0.select(QTextCursor.BlockUnderCursor) text = to_text_string(cursor0.selectedText()) else: text = to_text_string(block.text()) if self.cell_separators is None: return False else: return text.lstrip().startswith(self.cell_separators)