本文整理匯總了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()