def paintEvent(self, event): # Paints the line numbers self._line_color_u = drift_color(self._background_brush.color(), 250) self._line_color_s = drift_color(self._background_brush.color(), 280) Panel.paintEvent(self, event) if self.isVisible(): painter = QtGui.QPainter(self) # get style options (font, size) width = self.width() height = self.editor.fontMetrics().height() font = self.editor.font() bold_font = self.editor.font() bold_font.setBold(True) pen = QtGui.QPen(self._line_color_u) pen_selected = QtGui.QPen(self._line_color_s) painter.setFont(font) # get selection range sel_start, sel_end = TextHelper(self.editor).selection_range() has_sel = sel_start != sel_end cl = TextHelper(self.editor).current_line_nbr() # draw every visible blocks for top, line, block in self.editor.visible_blocks: if ((has_sel and sel_start <= line <= sel_end) or (not has_sel and cl == line)): painter.setPen(pen_selected) painter.setFont(bold_font) else: painter.setPen(pen) painter.setFont(font) painter.drawText(-3, top, width, height, QtCore.Qt.AlignRight, str(line + 1))
def __init__(self, highlight_caret_scope=False): Panel.__init__(self) self._native = True self._custom_indicators = ( ':/pyqode-icons/rc/arrow_right_off.png', ':/pyqode-icons/rc/arrow_right_on.png', ':/pyqode-icons/rc/arrow_down_off.png', ':/pyqode-icons/rc/arrow_down_on.png' ) self._custom_color = QtGui.QColor('gray') self._block_nbr = -1 self._highlight_caret = False self.highlight_caret_scope = highlight_caret_scope self._indic_size = 16 #: the list of deco used to highlight the current fold region ( #: surrounding regions are darker) self._scope_decos = [] #: the list of folded blocs decorations self._block_decos = [] self.setMouseTracking(True) self.scrollable = True self._mouse_over_line = None self._current_scope = None self._prev_cursor = None self.context_menu = None self.action_collapse = None self.action_expand = None self.action_collapse_all = None self.action_expand_all = None self._original_background = None self._highlight_runner = DelayJobRunner(delay=250)
def paintEvent(self, event): Panel.paintEvent(self, event) painter = QtGui.QPainter(self) for top, block_nbr, block in self.editor.visible_blocks: user_data = block.userData() if hasattr(user_data, "markers"): markers = user_data.markers for i, marker in enumerate(markers): if (hasattr(marker, 'panel_ref') and marker.panel_ref == self): # only draw our markers if marker in self._to_remove: try: user_data.markers.remove(None) self._to_remove.remove(marker) except ValueError: pass continue if marker and marker.icon: rect = QtCore.QRect() rect.setX(0) rect.setY(top) rect.setWidth(self.sizeHint().width()) rect.setHeight(self.sizeHint().height()) if isinstance(marker.icon, tuple): key = marker.icon[0] else: key = marker.icon if key not in self._icons: key, val = self.make_marker_icon(marker.icon) if key and val: self._icons[key] = val else: continue self._icons[key].paint(painter, rect)
def __init__(self): Panel.__init__(self, dynamic=True) self.job_runner = DelayJobRunner(delay=500) Ui_SearchPanel.__init__(self) self.setupUi(self) self.toolButtonClose.clicked.connect(self.on_close) self.actionSearch.triggered.connect(self.on_search) self.actionActionSearchAndReplace.triggered.connect( self.on_search_and_replace) self.lineEditReplace.prompt_text = _(' Replace') #: Occurrences counter self.cpt_occurences = 0 self._previous_stylesheet = "" self._separator = None self._decorations = [] self._occurrences = [] self._current_occurrence_index = 0 self._bg = None self._fg = None self._update_buttons(txt="") self.lineEditSearch.installEventFilter(self) self.lineEditReplace.installEventFilter(self) self._init_actions() self._init_style() self.checkBoxRegex.stateChanged.connect( self.checkBoxWholeWords.setDisabled)
def __init__(self): Panel.__init__(self, dynamic=True) self.job_runner = DelayJobRunner(delay=500) Ui_SearchPanel.__init__(self) self.setupUi(self) self.toolButtonClose.clicked.connect(self.on_close) self.actionSearch.triggered.connect(self.on_search) self.actionActionSearchAndReplace.triggered.connect(self.on_search_and_replace) self.lineEditReplace.prompt_text = _(' Replace') #: Occurrences counter self.cpt_occurences = 0 self._previous_stylesheet = "" self._separator = None self._decorations = [] self._occurrences = [] self._current_occurrence_index = 0 self._bg = None self._fg = None self._update_buttons(txt="") self.lineEditSearch.installEventFilter(self) self.lineEditReplace.installEventFilter(self) self._init_actions() self._init_style() self.checkBoxRegex.stateChanged.connect( self.checkBoxWholeWords.setDisabled)
def __init__(self): Panel.__init__(self) self.scrollable = True self._selecting = False self._sel_start = -1 self._line_color_u = self.palette().color( QtGui.QPalette.Disabled, QtGui.QPalette.WindowText) self._line_color_s = self.palette().color( QtGui.QPalette.Normal, QtGui.QPalette.WindowText)
def __init__(self): Panel.__init__(self) self._markers = [] self._icons = {} self._previous_line = -1 self.scrollable = True self._job_runner = DelayJobRunner(delay=100) self.setMouseTracking(True) self._to_remove = []
def __init__(self): Panel.__init__(self) self.scrollable = True self._selecting = False self._sel_start = -1 self._line_color_u = self.palette().color(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText) self._line_color_s = self.palette().color(QtGui.QPalette.Normal, QtGui.QPalette.WindowText)
def paintEvent(self, event): Panel.paintEvent(self, event) painter = QtGui.QPainter(self) for top, block_nbr, block in self.editor.visible_blocks: for marker in self._markers: if marker.block == block and marker.icon: rect = QtCore.QRect() rect.setX(0) rect.setY(top) rect.setWidth(self.sizeHint().width()) rect.setHeight(self.sizeHint().height()) marker.icon.paint(painter, rect)
def __init__(self): Panel.__init__(self) self.job_runner = DelayJobRunner(delay=500) Ui_SearchPanel.__init__(self) self.setupUi(self) self.lineEditReplace.prompt_text = ' Replace' #: Occurrences counter self.cpt_occurences = 0 self._previous_stylesheet = "" self._separator = None self._decorations = [] self._occurrences = [] self._current_occurrence_index = -1 self._bg = None self._fg = None self._update_buttons(txt="") self.lineEditSearch.installEventFilter(self) self.lineEditReplace.installEventFilter(self) self._init_actions() self._init_style() self.checkBoxRegex.stateChanged.connect( self.checkBoxWholeWords.setDisabled)
def eventFilter(self, obj, event): if event.type() == QtCore.QEvent.KeyPress: if (event.key() == QtCore.Qt.Key_Tab or event.key() == QtCore.Qt.Key_Backtab): return True elif (event.key() == QtCore.Qt.Key_Return or event.key() == QtCore.Qt.Key_Enter): if obj == self.lineEditReplace: if event.modifiers() & QtCore.Qt.ControlModifier: self.replace_all() else: self.replace() elif obj == self.lineEditSearch: self.select_next() return True elif event.key() == QtCore.Qt.Key_Escape: self.on_toolButtonClose_clicked() return Panel.eventFilter(self, obj, event)
def focusOutEvent(self, event): self.job_runner.cancel_requests() Panel.focusOutEvent(self, event)