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)
def _on_results_available(self, results): if len(results) > 1: for start, end in results: deco = TextDecoration(self.editor.textCursor(), start_pos=start, end_pos=end) if self.underlined: deco.set_as_underlined(self._background) else: deco.set_background(QtGui.QBrush(self._background)) deco.set_foreground(self._foreground) deco.draw_order = 3 self.editor.decorations.append(deco) self._decorations.append(deco)
def _add_fold_decoration(self, block, region): """ Add fold decorations (boxes arround a folded block in the editor widget). """ deco = TextDecoration(block) deco.signals.clicked.connect(self._on_fold_deco_clicked) deco.tooltip = region.text(max_lines=25) deco.draw_order = 1 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(QtGui.QColor('#808080')) self._block_decos.append(deco) self.editor.decorations.append(deco)
def _add_fold_decoration(self, block, region): """ Add fold decorations (boxes arround a folded block in the editor widget). """ deco = TextDecoration(block) deco.signals.clicked.connect(self._on_fold_deco_clicked) deco.tooltip = region.text(max_lines=25) deco.draw_order = 1 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(QtGui.QColor('#808080')) self._block_decos.append(deco) self.editor.decorations.append(deco)
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()
def _on_results_available(self, results): if len(results) > 500: # limit number of results (on very big file where a lots of # occurrences can be found, this would totally freeze the editor # during a few seconds, with a limit of 500 we can make sure # the editor will always remain responsive). results = results[:500] if len(results) > 1: for start, end in results: deco = TextDecoration(self.editor.textCursor(), start_pos=start, end_pos=end) if self.underlined: deco.set_as_underlined(self._background) else: deco.set_background(QtGui.QBrush(self._background)) deco.set_foreground(self._foreground) deco.draw_order = 3 self.editor.decorations.append(deco) self._decorations.append(deco)
def _on_results_available(self, results): if len(results) > 500: # limit number of results (on very big file where a lots of # occurrences can be found, this would totally freeze the editor # during a few seconds, with a limit of 500 we can make sure # the editor will always remain responsive). results = results[:500] if len(results) > 1: for start, end in results: deco = TextDecoration(self.editor.textCursor(), start_pos=start, end_pos=end) if self.underlined: deco.set_as_underlined(self._background) else: deco.set_background(QtGui.QBrush(self._background)) deco.set_foreground(self._foreground) deco.draw_order = 3 self.editor.decorations.append(deco) self._decorations.append(deco)