Пример #1
0
 def _add_fold_decoration(self, block, region):
     """
     Add fold decorations (boxes arround a folded block in the editor
     widget).
     """
     draw_order = DRAW_ORDERS.get('codefolding')
     deco = TextDecoration(block, draw_order=draw_order)
     deco.signals.clicked.connect(self._on_fold_deco_clicked)
     deco.tooltip = region.text(max_lines=25)
     deco.block = block
     deco.select_line()
     deco.set_outline(drift_color(self._get_scope_highlight_color(), 110))
     deco.set_background(self._get_scope_highlight_color())
     deco.set_foreground(QColor('#808080'))
     self._block_decos.append(deco)
     self.editor.decorations.add(deco)
Пример #2
0
    def _decorate_block(self, start, end):
        """
        Create a decoration and add it to the editor.

        Args:
            start (int) start line of the decoration
            end (int) end line of the decoration
        """
        color = self._get_scope_highlight_color()
        draw_order = DRAW_ORDERS.get('codefolding')
        d = TextDecoration(self.editor.document(), start_line=max(0, start - 1),
                           end_line=end, draw_order=draw_order)
        d.set_background(color)
        d.set_full_width(True, clear=False)
        self.editor.decorations.add(d)
        self._scope_decos.append(d)
Пример #3
0
 def _add_fold_decoration(self, block, end_line):
     """
     Add fold decorations (boxes arround a folded block in the editor
     widget).
     """
     start_line = block.blockNumber()
     text = self.editor.get_text_region(start_line + 1, end_line)
     draw_order = DRAW_ORDERS.get('codefolding')
     deco = TextDecoration(block, draw_order=draw_order)
     deco.signals.clicked.connect(self._on_fold_deco_clicked)
     deco.tooltip = text
     deco.block = block
     deco.select_line()
     deco.set_outline(drift_color(self._get_scope_highlight_color(), 110))
     deco.set_background(self._get_scope_highlight_color())
     deco.set_foreground(QColor('#808080'))
     self._block_decos[start_line] = deco
     self.editor.decorations.add(deco)