本文整理汇总了Python中pyqode.core.api.TextBlockHelper.set_fold_trigger_state方法的典型用法代码示例。如果您正苦于以下问题:Python TextBlockHelper.set_fold_trigger_state方法的具体用法?Python TextBlockHelper.set_fold_trigger_state怎么用?Python TextBlockHelper.set_fold_trigger_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.core.api.TextBlockHelper
的用法示例。
在下文中一共展示了TextBlockHelper.set_fold_trigger_state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collapse_all
# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import set_fold_trigger_state [as 别名]
def collapse_all(self):
"""
Collapses all triggers and makes all blocks with fold level > 0
invisible.
"""
self._clear_block_deco()
block = self.editor.document().firstBlock()
last = self.editor.document().lastBlock()
while block.isValid():
lvl = TextBlockHelper.get_fold_lvl(block)
trigger = TextBlockHelper.is_fold_trigger(block)
if trigger:
if lvl == 0:
self._show_previous_blank_lines(block)
TextBlockHelper.set_fold_trigger_state(block, True)
block.setVisible(lvl == 0)
if block == last and block.text().strip() == '':
block.setVisible(True)
self._show_previous_blank_lines(block)
block = block.next()
self._refresh_editor_and_scrollbars()
tc = self.editor.textCursor()
tc.movePosition(tc.Start)
self.editor.setTextCursor(tc)
self.collapse_all_triggered.emit()
示例2: expand_all
# 需要导入模块: from pyqode.core.api import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.TextBlockHelper import set_fold_trigger_state [as 别名]
def expand_all(self):
"""
Expands all fold triggers.
"""
block = self.editor.document().firstBlock()
while block.isValid():
TextBlockHelper.set_fold_trigger_state(block, False)
block.setVisible(True)
block = block.next()
self._clear_block_deco()
self._refresh_editor_and_scrollbars()
self.expand_all_triggered.emit()