当前位置: 首页>>代码示例>>Python>>正文


Python TextBlockHelper.is_fold_trigger方法代码示例

本文整理汇总了Python中pyqode.core.api.utils.TextBlockHelper.is_fold_trigger方法的典型用法代码示例。如果您正苦于以下问题:Python TextBlockHelper.is_fold_trigger方法的具体用法?Python TextBlockHelper.is_fold_trigger怎么用?Python TextBlockHelper.is_fold_trigger使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyqode.core.api.utils.TextBlockHelper的用法示例。


在下文中一共展示了TextBlockHelper.is_fold_trigger方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_parent_scope

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def find_parent_scope(block):
        """
        Find parent scope, if the block is not a fold trigger.

        :param block: block from which the research will start
        """
        # if we moved up for more than n lines, just give up otherwise this
        # would take too much time.
        limit = 5000
        counter = 0
        original = block
        if not TextBlockHelper.is_fold_trigger(block):
            # search level of next non blank line
            while block.text().strip() == '' and block.isValid():
                block = block.next()
            ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1
            block = original
            while (block.blockNumber() and counter < limit and
                   (not TextBlockHelper.is_fold_trigger(block) or
                    TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                counter += 1
                block = block.previous()
        if counter < limit:
            return block
        return None
开发者ID:brunoviu,项目名称:OpenCobolIDE,代码行数:27,代码来源:folding.py

示例2: find_parent_scope

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def find_parent_scope(block):
        """
        Find parent scope, if the block is not a fold trigger.

        :param block: block from which the research will start
        """
        original = block
        if not TextBlockHelper.is_fold_trigger(block):
            # search level of next non blank line
            while block.text().strip() == '' and block.isValid():
                block = block.next()
            ref_lvl = TextBlockHelper.get_fold_lvl(block) - 1
            block = original
            while (block.blockNumber() and
                   (not TextBlockHelper.is_fold_trigger(block) or
                    TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                block = block.previous()
        return block
开发者ID:pixpil,项目名称:gii,代码行数:20,代码来源:folding.py

示例3: unfold

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
 def unfold(self):
     """
     Unfolds the region.
     """
     # set all direct child blocks which are not triggers to be visible
     self._trigger.setVisible(True)
     TextBlockHelper.set_collapsed(self._trigger, False)
     for block in self.blocks(ignore_blank_lines=False):
         block.setVisible(True)
         if TextBlockHelper.is_fold_trigger(block):
             TextBlockHelper.set_collapsed(block, False)
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:13,代码来源:folding.py

示例4: __init__

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def __init__(self, block):
        """
        Create a fold-able region from a fold trigger block.

        :param block: The block **must** be a fold trigger.
        :type block: QTextBlock

        :raise: `ValueError` if the text block is not a fold trigger.
        """
        if not TextBlockHelper.is_fold_trigger(block):
            raise ValueError('Not a fold trigger')
        self._trigger = block
开发者ID:pixpil,项目名称:gii,代码行数:14,代码来源:folding.py

示例5: process_block

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def process_block(self, current_block, previous_block, text):
        """
        Processes a block and setup its folding info.

        This method call ``detect_fold_level`` and handles most of the tricky
        corner cases so that all you have to do is focus on getting the proper
        fold level foreach meaningful block, skipping the blank ones.

        :param current_block: current block to process
        :param previous_block: previous block
        :param text: current block text
        """
        prev_fold_level = TextBlockHelper.get_fold_lvl(previous_block)
        if text.strip() == '':
            # blank line always have the same level as the previous line
            fold_level = prev_fold_level
        else:
            fold_level = self.detect_fold_level(
                previous_block, current_block)
            if fold_level > self.limit:
                fold_level = self.limit

        prev_fold_level = TextBlockHelper.get_fold_lvl(previous_block)

        if fold_level > prev_fold_level:
            # apply on previous blank lines
            block = current_block.previous()
            while block.isValid() and block.text().strip() == '':
                TextBlockHelper.set_fold_lvl(block, fold_level)
                block = block.previous()
            TextBlockHelper.set_fold_trigger(
                block, True)

        # update block fold level
        if text.strip():
            TextBlockHelper.set_fold_trigger(
                previous_block, fold_level > prev_fold_level)
        TextBlockHelper.set_fold_lvl(current_block, fold_level)

        # user pressed enter at the beginning of a fold trigger line
        # the previous blank line will keep the trigger state and the new line
        # (which actually contains the trigger) must use the prev state (
        # and prev state must then be reset).
        prev = current_block.previous()  # real prev block (may be blank)
        if (prev and prev.isValid() and prev.text().strip() == '' and
                TextBlockHelper.is_fold_trigger(prev)):
            # prev line has the correct trigger fold state
            TextBlockHelper.set_collapsed(
                current_block, TextBlockHelper.is_collapsed(
                    prev))
            # make empty line not a trigger
            TextBlockHelper.set_fold_trigger(prev, False)
            TextBlockHelper.set_collapsed(prev, False)
开发者ID:OpenCobolIDE,项目名称:OpenCobolIDE,代码行数:55,代码来源:folding.py

示例6: child_regions

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
 def child_regions(self):
     """
     This generator generates the list of direct child regions.
     """
     start, end = self.get_range()
     block = self._trigger.next()
     ref_lvl = self.scope_level
     while block.blockNumber() <= end and block.isValid():
         lvl = TextBlockHelper.get_fold_lvl(block)
         trigger = TextBlockHelper.is_fold_trigger(block)
         if lvl == ref_lvl and trigger:
             yield FoldScope(block)
         block = block.next()
开发者ID:pixpil,项目名称:gii,代码行数:15,代码来源:folding.py

示例7: blocks

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def blocks(self, ignore_blank_lines=True):
        """
        This generator generates the list of blocks directly under the fold
        region. This list does not contain blocks from child regions.

        :param ignore_blank_lines: True to ignore last blank lines.
        """
        start, end = self.get_range(ignore_blank_lines=ignore_blank_lines)
        block = self._trigger.next()
        ref_lvl = self.scope_level
        while block.blockNumber() <= end and block.isValid():
            lvl = TextBlockHelper.get_fold_lvl(block)
            trigger = TextBlockHelper.is_fold_trigger(block)
            if lvl == ref_lvl and not trigger:
                yield block
            block = block.next()
开发者ID:pixpil,项目名称:gii,代码行数:18,代码来源:folding.py

示例8: parent

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def parent(self):
        """
        Return the parent scope.

        :return: FoldScope or None
        """
        if TextBlockHelper.get_fold_lvl(self._trigger) > 0 and \
                self._trigger.blockNumber():
            block = self._trigger.previous()
            ref_lvl = self.trigger_level - 1
            while (block.blockNumber() and
                    (not TextBlockHelper.is_fold_trigger(block) or
                     TextBlockHelper.get_fold_lvl(block) > ref_lvl)):
                block = block.previous()
            try:
                return FoldScope(block)
            except ValueError:
                return None
        return None
开发者ID:pixpil,项目名称:gii,代码行数:21,代码来源:folding.py

示例9: process_block

# 需要导入模块: from pyqode.core.api.utils import TextBlockHelper [as 别名]
# 或者: from pyqode.core.api.utils.TextBlockHelper import is_fold_trigger [as 别名]
    def process_block(self, current_block, previous_block, text):
        """
        Processes a block and setup its folding info.

        This method call ``detect_fold_level`` and handles most of the tricky
        corner cases so that all you have to do is focus on getting the proper
        fold level foreach meaningful block, skipping the blank ones.

        :param current_block: current block to process
        :param previous_block: previous block
        :param text: current block text
        """
        prev_fold_level = TextBlockHelper.get_fold_lvl(previous_block)
        if text.strip() == '':
            # blank line always have the same level as the previous line,
            fold_level = prev_fold_level
        else:
            fold_level = self.detect_fold_level(
                previous_block, current_block)
            if fold_level > self.limit:
                fold_level = self.limit

        if fold_level > prev_fold_level:
            # apply on previous blank lines
            block = current_block.previous()
            while block.isValid() and block.text().strip() == '':
                TextBlockHelper.set_fold_lvl(block, fold_level)
                block = block.previous()
            TextBlockHelper.set_fold_trigger(
                block, True)

        delta_abs = abs(fold_level - prev_fold_level)
        if delta_abs > 1:
            if fold_level > prev_fold_level:
                # try to fix inconsistent fold level
                _logger().debug(
                    '(l%d) inconsistent fold level, difference between '
                    'consecutive blocks cannot be greater than 1 (%d).',
                    current_block.blockNumber() + 1, delta_abs)
                fold_level = prev_fold_level + 1

        # update block fold level
        if text.strip():
            TextBlockHelper.set_fold_trigger(
                previous_block, fold_level > prev_fold_level)
        TextBlockHelper.set_fold_lvl(current_block, fold_level)

        # user pressed enter at the beginning of a fold trigger line
        # the previous blank line will keep the trigger state and the new line
        # (which actually contains the trigger) must use the prev state (
        # and prev state must then be reset).
        prev = current_block.previous()  # real prev block (may be blank)
        if (prev and prev.isValid() and prev.text().strip() == '' and
                TextBlockHelper.is_fold_trigger(prev)):
            # prev line has the correct trigger fold state
            TextBlockHelper.set_fold_trigger_state(
                current_block, TextBlockHelper.get_fold_trigger_state(
                    prev))
            # make empty line not a trigger
            TextBlockHelper.set_fold_trigger(prev, False)
            TextBlockHelper.set_fold_trigger_state(prev, False)
开发者ID:AlexLee,项目名称:cadquery-freecad-module,代码行数:63,代码来源:folding.py


注:本文中的pyqode.core.api.utils.TextBlockHelper.is_fold_trigger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。