def __init__(self, parent=None): """ Initialize the class by setting up the editor @param parent: parent of the widget """ super(XmlCodeEditor, self).__init__(parent) self.lexer_ = Qsci.QsciLexerXML(self) self.initial_content = None self.parsed_content = None
def __init__(self, parent=None): Qsci.QsciScintilla.__init__(self, parent) self.setLexer(Qsci.QsciLexerXML()) self.text_object = TextObject("") self.highlight_index = self.indicatorDefine(self.RoundBoxIndicator, -1) self.setIndicatorDrawUnder(True, self.highlight_index) self.setIndicatorForegroundColor(QtGui.QColor("#dddddd"), self.highlight_index) self.orig_text = self.text_object.orig_text
def setEditorType(self, tpe: EditorType, inner=False): self.editType = tpe if not inner: self.editorTypeBox.setCurrentIndex(tpe.value) if tpe == EditorType.JSON: self.editor.changeLexer(Qsci.QsciLexerJSON(self.editor), 'JSON') elif tpe == EditorType.XML: self.editor.changeLexer(Qsci.QsciLexerXML(self.editor), 'XML') elif tpe == EditorType.HTML: self.editor.changeLexer(Qsci.QsciLexerHTML(self.editor), 'HTML') elif tpe == EditorType.Javascript: self.editor.changeLexer(Qsci.QsciLexerJavaScript(self.editor), 'Javascript') else: self.editor.changeLexer(Qsci.QsciLexerMarkdown(self.editor), 'Text<') self.editorTypeChanged.emit(tpe.value)
def __init__(self, parent=None): super().__init__(parent) # Set the default font font = QFont() font.setFamily('Courier') font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.setMarginsFont(font) # Margin 0 is used for line numbers fontmetrics = QFontMetrics(font) self.setMarginsFont(font) self.setMarginWidth(0, fontmetrics.width("000") + 6) self.setMarginLineNumbers(0, True) self.setMarginsBackgroundColor(QColor("#E3F0FF")) # Brace matching: enable for a brace immediately before or after # the current position # self.setBraceMatching(QsciScintilla.SloppyBraceMatch) # Current line visible with special background color self.setCaretLineVisible(True) self.setCaretLineBackgroundColor(QColor("#A5ABBD")) # Set Python lexer # Set style for Python comments (style number 1) to a fixed-width # courier. # lexer = Qsci.QsciLexerXML(self) lexer.setDefaultFont(font) self.setLexer(lexer) # self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier') # Don't want to see the horizontal scrollbar at all # Use raw message to Scintilla here (all messages are documented # here: http://www.scintilla.org/ScintillaDoc.html) self.SendScintilla(QsciScintilla.SCI_SETHSCROLLBAR, 0) # not too small self.setMinimumSize(300, 100)