Example #1
0
 def _get_format_from_document(
         self, token: str,
         document: QtGui.QTextDocument) -> QtGui.QTextCharFormat:
     """Return a QTextCharFormat for token from document."""
     code, html = next(self._formatter._format_lines([(token, "dummy")]))
     self._document.setHtml(html)
     return gui.TextCursor(self._document).charFormat()
Example #2
0
def test_textcursor():
    cursor = gui.TextCursor()
    cursor.set_position(1, "move")
    cursor.move_position("start", "move", 1)
    cursor.select("document")
    cursor.replace_text(0, 2, "test")
    cursor.select_text(1, 3)
    cursor.span()
    with cursor.edit_block():
        pass
Example #3
0
 def get_text_cursor(self) -> gui.TextCursor:
     return gui.TextCursor(self.textCursor())
Example #4
0
 def create_cursor(self) -> Iterator[gui.TextCursor]:
     cursor = gui.TextCursor(self.document())
     yield cursor
     self.setTextCursor(cursor)
Example #5
0
 def current_cursor(self) -> Iterator[gui.TextCursor]:
     cursor = gui.TextCursor(self.textCursor())
     yield cursor
     self.setTextCursor(cursor)
Example #6
0
 def get_last_cursor_position(self) -> gui.TextCursor:
     return gui.TextCursor(self.lastCursorPosition())