本文整理汇总了Python中PyQt5.QtGui.QTextCursor.insertFragment方法的典型用法代码示例。如果您正苦于以下问题:Python QTextCursor.insertFragment方法的具体用法?Python QTextCursor.insertFragment怎么用?Python QTextCursor.insertFragment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QTextCursor
的用法示例。
在下文中一共展示了QTextCursor.insertFragment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_minimap_doc
# 需要导入模块: from PyQt5.QtGui import QTextCursor [as 别名]
# 或者: from PyQt5.QtGui.QTextCursor import insertFragment [as 别名]
def update_minimap_doc(self, position, charsRemoved, charsAdded):
def select_blocks(first_block, last_block):
first_block_pos = first_block.position()
doc_cursor.setPosition(first_block_pos)
last_block_pos = last_block.position()
doc_cursor.setPosition(last_block_pos, QTextCursor.KeepAnchor)
doc_cursor.movePosition(
QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
print("selected text :", doc_cursor.selectedText())
return doc_cursor.selectedText()
doc_cursor = QTextCursor(self._doc)
minimap_cursor = QTextCursor(self._minimap_doc)
# IF one same block is modified
if self._minimap_doc.blockCount() == self._doc.blockCount():
doc_cursor.setPosition(position)
doc_cursor.select(QTextCursor.BlockUnderCursor)
minimap_cursor.setPosition(position)
minimap_cursor.select(QTextCursor.BlockUnderCursor)
minimap_cursor.insertFragment(doc_cursor.selection())
# TODO: if the doc is modified on more than one block but resulting in
# the same count of blocks (right now only the first block would be
# updated)
else:
# ELSE
doc_cursor.select(QTextCursor.Document)
minimap_cursor.select(QTextCursor.Document)
minimap_cursor.insertFragment(doc_cursor.selection())