def __init__(self, lint, args, editor, results_iter, message): AbstractProcess.__init__(self, lint, args, editor) # self.lint = lint # self.args = args # self.editor = editor self.results_iter = results_iter self.message = message # Must be callable. # Set up styling for annotations. self.console.setAnnotationDisplay(2) self.font = Qt.QFont('Courier', 9, Qt.QFont.Normal, True) self.info = QsciStyle(-1, 'Hilite style for lint info', Qt.QColor('#222222'), Qt.QColor('#FFFFFF'), self.font) self.warning = QsciStyle(-1, 'Hilite style for lint warnings', Qt.QColor('#222222'), Qt.QColor('#FFFF44'), self.font) self.error = QsciStyle(-1, 'Hilite style for lint errors', Qt.QColor('#FFFFFF'), Qt.QColor('#EE0000'), self.font) self.severities = { 'I': self.info, 'C': self.info, 'W': self.warning, 'R': self.warning, 'E': self.error, 'F': self.error } self.connect(self, Qt.SIGNAL('results()'), self.apply_results) return
def __setRevisionText(self): " Sets the revision margin text " for revNumber in self.__revisionInfo: author = self.__revisionInfo[revNumber]['author'] if '@' in author: # Most probably this is an e-mail address. Leave just name. self.__revisionInfo[revNumber]['shortAuthor'] = author.split( '@')[0] else: self.__revisionInfo[revNumber]['shortAuthor'] = author skin = GlobalData().skin revisionMarginFont = QFont(skin.lineNumFont) revisionMarginFont.setItalic(True) style = QsciStyle(-1, "Revision margin style", skin.revisionMarginColor, skin.revisionMarginPaper, revisionMarginFont) lineNumber = 0 self.__maxLength = -1 # Altering line background support currentRevision = -1 needMarker = True for lineRevision in self.__lineRevisions: if lineRevision in self.__revisionInfo: marginText = " " + ":".join([ str(lineRevision), self.__revisionInfo[lineRevision]['shortAuthor'] ]) else: marginText = " " + str(lineRevision) textLength = len(marginText) if textLength > self.__maxLength: self.__maxLength = textLength self.setMarginText(lineNumber, marginText, style) # Set the line background if needed if lineRevision != currentRevision: currentRevision = lineRevision needMarker = not needMarker if needMarker: self.markerAdd(lineNumber, self.__alterMarker) lineNumber += 1 self.setRevisionMarginWidth() return
def __init__(self, distributedObjects, filename, parent): ScintillaWrapper.__init__(self, parent) self.breakpointOverlays = {} filename = str(filename) self.distributedObjects = distributedObjects self.debugController = self.distributedObjects.debugController self.__bpModel = self.distributedObjects.breakpointModel self.tracepointController = self.distributedObjects.tracepointController self.signalProxy = self.distributedObjects.signalProxy self.filename = filename self.lastContextMenuLine = 0 self.markerBp = QPixmap(":/markers/bp.png") self.markerBpDisabled = QPixmap(":/markers/bp_dis.png") self.markerTp = QPixmap(":/markers/tp.png") self.markerExec = QPixmap(":/markers/exec_pos.png") self.markerStack = QPixmap(":/markers/stack_pos.png") self.markerExecSignal = QPixmap(":/markers/exec_pos_signal.png") self.shown = False self.setToolTip("") self.setWhatsThis("") self.setMarginLineNumbers(self.MARGIN_NUMBERS, True) # set sensitivity self.setMarginSensitivity(self.MARGIN_NUMBERS, True) self.setMarginSensitivity(self.MARGIN_MARKER_BP, True) self.setMarginSensitivity(self.MARGIN_MARKER_TP, True) # define symbol self.markerDefine(self.markerBp, self.MARGIN_MARKER_BP) self.markerDefine(self.markerBpDisabled, self.MARGIN_MARKER_BP_DIS) self.markerDefine(self.markerTp, self.MARGIN_MARKER_TP) self.markerDefine(self.markerExec, self.MARGIN_MARKER_EXEC) self.markerDefine(self.markerStack, self.MARGIN_MARKER_STACK) self.markerDefine(self.markerExecSignal, self.MARGIN_MARKER_EXEC_SIGNAL) self.markerDefine(QsciScintilla.Background, self.MARKER_HIGHLIGHTED_LINE) # define width and mask to show margin self.setMarginWidth(self.MARGIN_MARKER_BP, 10) self.setMarginMarkerMask(self.MARGIN_MARKER_BP, 1 << self.MARGIN_MARKER_BP | 1 << self.MARGIN_MARKER_BP_DIS) self.setMarginWidth(self.MARGIN_MARKER_TP, 10) self.setMarginMarkerMask(self.MARGIN_MARKER_TP, 1 << self.MARGIN_MARKER_TP) self.setMarginWidth(self.MARGIN_MARKER_EXEC, 10) self.setMarginMarkerMask(self.MARGIN_MARKER_EXEC, 1 << self.MARGIN_MARKER_EXEC | 1 << self.MARGIN_MARKER_EXEC_SIGNAL | 1 << self.MARGIN_MARKER_STACK) self.setMarginWidth(self.MARKER_HIGHLIGHTED_LINE, 0) self.setMarginMarkerMask(self.MARKER_HIGHLIGHTED_LINE, 1 << self.MARKER_HIGHLIGHTED_LINE) self.INDICATOR_TOOLTIP = self.indicatorDefine(self.BoxIndicator) self.setIndicatorDrawUnder(True, self.INDICATOR_TOOLTIP) self.setReadOnly(False) self.modificationChanged.connect(self.__setFileModified) self.SendScintilla(QsciScintilla.SCI_SETMOUSEDWELLTIME, 500) # override scintillas context menu with our own self.SendScintilla(QsciScintilla.SCI_USEPOPUP, 0) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.showContextMenu) self.marginClicked.connect(self.onMarginClicked) self.SCN_DOUBLECLICK.connect(self.editDoubleClicked) self.dwellStart.connect(self.onDwellStart) self.dwellEnd.connect(self.onDwellEnd) self.__bpModel.rowsInserted.connect(self.breakpointsInserted) # don't connect to rowsRemoved here since the breakpoint is already gone # from the model when it's emitted self.__bpModel.rowsAboutToBeRemoved.connect(self.breakpointsRemoved) self.__bpModel.dataChanged.connect(self.breakpointsModified) _model = self.tracepointController.model() _model.rowsInserted.connect(self.getTracepointsFromModel) _model.rowsRemoved.connect(self.getTracepointsFromModel) act = self.distributedObjects.actions act.ToggleTrace.triggered.connect(self.toggleTracepoint) self.__allowToolTip = True self.__enableToolTip(True) self.__popupMenu = None self.__disAsmStyle = QsciStyle() self.__fileWatcher = QFileSystemWatcher([self.filename]) self.__fileWatcher.fileChanged.connect(self.__fileChanged) # this timer is used for a workaround: QFileSystemWatcher will sometimes # report a change multiple times; therefore, in self.__fileChanged, we # simply start the timer on a notification and discard all notifications # while the timer is running self.__fileChangedTimer = QTimer() self.__fileChangedTimer.setSingleShot(True) self.__fileChangedTimer.setInterval(100) ScintillaWrapper.init(self, distributedObjects) self.setLexer(QsciLexerCPP()) self.openFile()