Example #1
0
 def apply_changes(self):
     """Apply the changes and update the tokens."""
     c = QTextCursor(self._d)
     # record a sensible position for undo
     c.setPosition(self._changes_list[-1][0])
     c.joinPreviousEditBlock() if self.combine_undo else c.beginEditBlock()
     try:
         for start, end, text in self._changes_list:
             c.movePosition(QTextCursor.End) if end is None else c.setPosition(end)
             c.setPosition(start, QTextCursor.KeepAnchor)
             c.insertText(text)
     finally:
         c.endEditBlock()
         if self.combine_undo is None:
             self.combine_undo = True
Example #2
0
 def apply_changes(self):
     """Apply the changes and update the tokens."""
     c = QTextCursor(self._d)
     # record a sensible position for undo
     c.setPosition(self._changes_list[-1][0])
     c.joinPreviousEditBlock() if self.combine_undo else c.beginEditBlock()
     try:
         for start, end, text in self._changes_list:
             c.movePosition(
                 QTextCursor.End) if end is None else c.setPosition(end)
             c.setPosition(start, QTextCursor.KeepAnchor)
             c.insertText(text)
     finally:
         c.endEditBlock()
         if self.combine_undo is None:
             self.combine_undo = True
Example #3
0
 def indent_line(self, line_no, indent_length):
     block = self._get_block(line_no)
     cursor = QTextCursor(block)
     cursor.joinPreviousEditBlock()
     cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)
     if indent_length < 0:
         for i in range(-indent_length):
             cursor.deleteChar()
     else:
         cursor.insertText(" " * indent_length)
     if indent_length:
         cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)
         line = unicode(cursor.block().text())
         if len(line) and line[0] == " ":
             cursor.movePosition(QTextCursor.NextWord, QTextCursor.MoveAnchor)
         self.editview.setTextCursor(cursor)
     cursor.endEditBlock()
Example #4
0
 def indent_line(self, line_no, indent_length):
     block = self._get_block(line_no)
     cursor = QTextCursor(block)
     cursor.joinPreviousEditBlock()
     cursor.movePosition(QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)
     if indent_length <  0:
         for i in range(-indent_length):
             cursor.deleteChar()
     else:
         cursor.insertText(" " * indent_length)
     if indent_length:
         cursor.movePosition(
             QTextCursor.StartOfBlock, QTextCursor.MoveAnchor)
         line = unicode(cursor.block().text())
         if len(line) and line[0] == " ":
             cursor.movePosition(
                 QTextCursor.NextWord, QTextCursor.MoveAnchor)
         self.editview.setTextCursor(cursor)
     cursor.endEditBlock()