def setup_lexer(self): # Set Python lexer lexer = QsciLexerPython(self) lexer.setDefaultFont(self._font) self.setLexer(lexer) lexer.setDefaultPaper(QtGui.QColor("#000000")) lexer.setPaper(QtGui.QColor("#000000")) lexer.setAutoIndentStyle(QsciScintilla.AiOpening) self.setstyle() self.setIndentationsUseTabs(False) self.setBackspaceUnindents(True) self.setIndentationWidth(4)
def __init__(self, parent=None): super(SimplePythonEditor, self).__init__(parent) # Set the default font font = QtGui.QFont() font.setFamily("DejaVu Sans Mono") font.setStyleHint(QtGui.QFont.Monospace) font.setFixedPitch(True) font.setPointSize(int(sizeconfig)) self.setFont(font) self.setMarginsFont(font) # Margin 0 is used for line numbers fontmetrics = QtGui.QFontMetrics(font) self.setMarginsFont(font) self.setMarginWidth(0, 30) self.setMarginLineNumbers(0, True) self.setMarginsBackgroundColor(QtGui.QColor("#cccccc")) # Clickable margin 1 for showing markers self.setMarginSensitivity(1, True) self.connect(self, SIGNAL("marginClicked(int, int, Qt::KeyboardModifiers)"), self.on_margin_clicked) self.markerDefine(QsciScintilla.RightArrow, self.ARROW_MARKER_NUM) self.setMarkerBackgroundColor(QtGui.QColor("#ee1111"), self.ARROW_MARKER_NUM) # Brace matching: enable for a brace immediately before or after # the current position # self.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.setIndentationWidth(4) # set autocomplete self.autoCompleteFromAPIs() # Current line visible with special background color self.setCaretLineVisible(True) self.setCaretLineBackgroundColor(QtGui.QColor(str(actualline))) # Set Python lexer # Set style for Python comments (style number 1) to a fixed-width # courier. # lexer = QsciLexerPython() lexer.setFont(font) lexer.setDefaultColor(QtGui.QColor(str(fontcolor))) lexer.setDefaultPaper(QtGui.QColor(str(backgroundcolor))) self.setLexer(lexer) """ Default = 0, Comment = 1, Number = 2, DoubleQuotedString = 3, SingleQuotedString = 4, Keyword = 5, TripleSingleQuotedString = 6, TripleDoubleQuotedString = 7, ClassName = 8, FunctionMethodName = 9, Operator = 10, Identifier = 11, CommentBlock = 12, UnclosedString = 13, HighlightedIdentifier = 14, Decorator = 15 """ self.SendScintilla(QsciScintilla.SCI_STYLESETFORE, 1, QtGui.QColor(str(commentcol))) self.SendScintilla(QsciScintilla.SCI_STYLESETFORE, 2, QtGui.QColor(str(numbercol)))