Пример #1
0
 def _add_scope_deco(self, start, end, parent_start, parent_end, base_color,
                     factor):
     """
     Adds a scope decoration that enclose the current scope
     :param start: Start of the current scope
     :param end: End of the current scope
     :param parent_start: Start of the parent scope
     :param parent_end: End of the parent scope
     :param base_color: base color for scope decoration
     :param factor: color factor to apply on the base color (to make it
         darker).
     """
     color = drift_color(base_color, factor=factor)
     # upper part
     if start > 0:
         d = TextDecoration(self.editor.document(),
                            start_line=parent_start, end_line=start)
         d.set_full_width(True, clear=False)
         d.draw_order = 2
         d.set_background(color)
         self.editor.decorations.append(d)
         self._scope_decos.append(d)
     # lower part
     if end <= self.editor.document().blockCount():
         d = TextDecoration(self.editor.document(),
                            start_line=end, end_line=parent_end + 1)
         d.set_full_width(True, clear=False)
         d.draw_order = 2
         d.set_background(color)
         self.editor.decorations.append(d)
         self._scope_decos.append(d)
Пример #2
0
    def add_marker(self, marker):
        """
        Adds the marker to the panel.

        :param marker: Marker to add
        :type marker: pyqode.core.modes.Marker
        """
        self._markers.append(marker)
        doc = self.editor.document()
        assert isinstance(doc, QtGui.QTextDocument)
        block = doc.findBlockByLineNumber(marker._position)
        marker.block = block
        d = TextDecoration(block)
        d.set_full_width()
        if self._background:
            d.set_background(QtGui.QBrush(self._background))
            marker.decoration = d
        self.editor.decorations.append(d)
        self.repaint()