def __init__(self,parent,colorStyle): #QsciLexerPython.__init__(self, parent) QsciLexerJavaScript.__init__(self, parent) self.parent = parent self.colorStyle = colorStyle self.plainFont = QFont() self.plainFont.setFamily(fontName) self.plainFont.setFixedPitch(True) self.plainFont.setPointSize(fontSize) self.boldFont = QFont(self.plainFont) self.boldFont.setBold(True) self.setFoldCompact(True) self.styles = [ #index description color paper font eol QsciStyle(0, QString("base"), self.colorStyle.color, self.colorStyle.paper, self.plainFont, True), QsciStyle(1, QString("comment"), QColor("#3f7f5f"), self.colorStyle.paper, self.plainFont, True), QsciStyle(4, QString("number"), QColor("#008000"), self.colorStyle.paper, self.plainFont, True), QsciStyle(5, QString("Keyword"), QColor("#7f0055"), self.colorStyle.paper, self.boldFont, True), QsciStyle(6, QString("String"), QColor("#7f0010"),self.colorStyle.paper, self.plainFont, True), #QsciStyle(10, QString("Operator"), QColor("#ff0000"), self.colorStyle.paper, self.plainFont, False), #QsciStyle(11, QString("Identifier"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False), #QsciStyle(12, QString("CommentBlock"), QColor("#3f5fbf"), self.colorStyle.paper, self.plainFont, False), #QsciStyle(13, QString("UnclosedString"), QColor("#010101"), self.colorStyle.paper, self.plainFont, False), #QsciStyle(14, QString("HighlightedIdentifier"), QColor("#0000ff"), self.colorStyle.paper, self.plainFont, False), #QsciStyle(15, QString("Decorator"), QColor("#000000"), self.colorStyle.paper, self.plainFont, False), ]
def __init__(self, parent=None): QsciLexerJavaScript.__init__(self, parent) Lexer.__init__(self) self.commentString = "//" self.streamCommentString = {'start': '/* ', 'end': ' */'} self.boxCommentString = {'start': '/* ', 'middle': ' * ', 'end': ' */'} return
def __init__(self,parent): QsciLexerJavaScript.__init__(self, parent) self.parent = parent self.plainFont = QFont() self.plainFont.setFamily(config.fontName()) self.plainFont.setFixedPitch(True) self.plainFont.setPointSize(config.fontSize()) self.boldFont = QFont(self.plainFont) self.boldFont.setBold(True) self.setFoldCompact(True)
def __init__( self, parent = None ): QsciLexerJavaScript.__init__( self, parent ) Lexer.__init__( self ) self.commentString = "//" self.streamCommentString = { 'start' : '/* ', 'end' : ' */' } self.boxCommentString = { 'start' : '/* ', 'middle' : ' * ', 'end' : ' */' } return
def __init__(self, parent): QsciLexerJavaScript.__init__(self, parent) self.lexer = Lexer.Lexer(self.language()) self.setDefaultPaper(self.lexer.get_globaldefault_paper()) self.setFont(self.lexer.get_default_font()) self.comment_string = QString("//") self.stream_comment_string = { 'start' : QString('/* '), 'end' : QString(' */') }
def __init__(self, text, textType, parent=None): super(TextEditorWidget, self).__init__(parent) font = QtGui.QFont() font.setFamily('Courier') font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.setMarginsFont(font) fontmetrics = QtGui.QFontMetrics(font) self.setMarginsFont(font) self.setMarginWidth(0, fontmetrics.width("00000") + 6) self.setMarginLineNumbers(0, True) self.setMarginsBackgroundColor(QtGui.QColor("#cccccc")) self.setBraceMatching(QsciScintilla.SloppyBraceMatch) self.setCaretLineVisible(True) self.setCaretLineBackgroundColor(QtGui.QColor("#ffe4e4")) if textType == CSS: lexer = QsciLexerCSS() elif textType == JSON: lexer = QsciLexerJavaScript() else: lexer = QsciLexerHTML() lexer.setDefaultFont(font) self.setLexer(lexer) self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier') self.setText(text)
def __init__(self, filename='', parent=None): ''' Constructor ''' QWidget.__init__(self, parent) self.filename = filename self.label = 'untitled' self.modified = False self.layout = QVBoxLayout(self) self.editor = QsciScintilla() self.layout.addWidget(self.editor, stretch=1) # Give the editor its content if len(filename) > 0: # Open the file and read in its contents f = open(filename, 'r') contents = f.read() self.editor.setText(contents) f.close() self.label = os.path.basename(filename) # Setup the features of the editor lexer = QsciLexerJavaScript() self.editor.setLexer(lexer) # Connect signals self.editor.textChanged.connect(self.onTextChanged)
class JavascriptEditor(BaseEditor): def __init__(self, parent=None, line_num_margin=3, autocomplete_list=None): super(JavascriptEditor, self).__init__(parent, line_num_margin, autocomplete_list) # Set HTML lexer self.lexer = QsciLexerJavaScript(self) self.lexer.setDefaultFont(self.editor_font) # Set auto-completion self.api = QsciAPIs(self.lexer) if autocomplete_list is not None: # Add additional completion strings for i in autocomplete_list: self.api.add(i) self.api.prepare() self.setAutoCompletionThreshold(3) self.setAutoCompletionSource(QsciScintilla.AcsAPIs) self.setLexer(self.lexer)
def defaultKeywords(self, kwSet): """ Public method to get the default keywords. @param kwSet number of the keyword set (integer) @return string giving the keywords (string) or None """ return QsciLexerJavaScript.keywords(self, kwSet)
def __init__(self, parent=None): """ Constructor @param parent parent widget of this lexer """ QsciLexerJavaScript.__init__(self, parent) Lexer.__init__(self) self.commentString = QString("//") self.streamCommentString = { 'start' : QString('/* '), 'end' : QString(' */') } self.boxCommentString = { 'start' : QString('/* '), 'middle' : QString(' * '), 'end' : QString(' */') }
dumpLexer( QsciLexerPython() ) dumpLexer( QsciLexerBash() ) dumpLexer( QsciLexerBatch() ) dumpLexer( QsciLexerCMake() ) dumpLexer( QsciLexerCPP() ) dumpLexer( QsciLexerCSharp() ) dumpLexer( QsciLexerCSS() ) dumpLexer( QsciLexerDiff() ) dumpLexer( QsciLexerD() ) dumpLexer( QsciLexerFortran77() ) dumpLexer( QsciLexerFortran() ) dumpLexer( QsciLexerHTML() ) dumpLexer( QsciLexerIDL() ) dumpLexer( QsciLexerJava() ) dumpLexer( QsciLexerJavaScript() ) dumpLexer( QsciLexerLua() ) dumpLexer( QsciLexerMakefile() ) dumpLexer( QsciLexerPascal() ) dumpLexer( QsciLexerPerl() ) dumpLexer( QsciLexerPostScript() ) dumpLexer( QsciLexerPOV() ) dumpLexer( QsciLexerProperties() ) dumpLexer( QsciLexerRuby() ) dumpLexer( QsciLexerSQL() ) dumpLexer( QsciLexerTCL() ) dumpLexer( QsciLexerTeX() ) dumpLexer( QsciLexerVHDL() ) dumpLexer( QsciLexerXML() ) dumpLexer( QsciLexerYAML() )
def defaultEolFill(self, ix): for i in self.styles: if i.style() == ix: return i.eolFill() return QsciLexerJavaScript.defaultEolFill(self, ix)
def defaultPaper(self, ix): for i in self.styles: if i.style() == ix: return i.paper() return QsciLexerJavaScript.defaultPaper(self, ix)
def defaultFont(self, ix): for i in self.styles: if i.style() == ix: return i.font() return QsciLexerJavaScript.defaultFont(self, ix)
def defaultColor(self, style): '''Returns the foreground colour of the text for style number style''' color = self.lexer.get_default_color(style, self.description(style)) if color != 'not': return color return QsciLexerJavaScript.defaultColor(self, style)