本文整理汇总了Python中PyQt5.QtGui.QTextCursor.endEditBlock方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.endEditBlock方法的具体用法?Python QTextCursor.endEditBlock怎么用?Python QTextCursor.endEditBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.endEditBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_changes
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import endEditBlock [as 别名]
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
示例2: indent_line
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import endEditBlock [as 别名]
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()