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, 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")) lexer = QsciLexerCSS() lexer.setDefaultFont(font) self.setLexer(lexer) self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier')
def __init__(self, parent=None): QsciLexerCSS.__init__(self, parent) Lexer.__init__(self) self.commentString = "#" self.streamCommentString = {'start': '/* ', 'end': ' */'} return
def __init__(self, parent=None): super(CSSEditor, self).__init__(parent) self.setUtf8(True) # Set the default font font = QFont() font.setFamily('Courier') font.setFixedPitch(True) font.setPointSize(10) self.setFont(font) self.setMarginsFont(font) # Use 4 spaces instead of tabs self.setIndentationsUseTabs(False) self.setIndentationWidth(4) # 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("#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(QColor("#ee1111"), self.ARROW_MARKER_NUM) # 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("#ffe4e4")) # Set CSS lexer # Set style for CSS comments (style number 1) to a fixed-width # courier. # lexer = QsciLexerCSS() lexer.setDefaultFont(font) self.setLexer(lexer) self.SendScintilla(QsciScintilla.SCI_STYLESETFONT, 1, 'Courier') # not too small self.setMinimumSize(600, 450) # Allow horizontal scroll as line width increases self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTH, 5) self.SendScintilla(QsciScintilla.SCI_SETSCROLLWIDTHTRACKING, 1)
def __init__( self, parent = None ): QsciLexerCSS.__init__( self, parent ) Lexer.__init__( self ) self.commentString = "#" self.streamCommentString = { 'start' : '/* ', 'end' : ' */' } return
def __init__(self,parent): QsciLexerCSS.__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): QsciLexerCSS.__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, parent=None): """ Constructor @param parent parent widget of this lexer """ QsciLexerCSS.__init__(self, parent) Lexer.__init__(self) self.commentString = QString("#") self.streamCommentString = { 'start' : QString('/* '), 'end' : QString(' */') }
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 QsciLexerCSS.keywords(self, kwSet)
class CSSEditor(BaseEditor): def __init__(self, parent=None, line_num_margin=3, autocomplete_list=None): super(CSSEditor, self).__init__(parent, line_num_margin, autocomplete_list) # Set HTML lexer self.lexer = QsciLexerCSS(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 __init__(self, style, paper): QsciLexerCSS.__init__(self) self.lexerPaper = paper for key, attrib in style.items(): value = propertyID[key] self.setColor(QtGui.QColor(attrib[1]), value) self.setEolFill(True, value) self.setPaper(QtGui.QColor(attrib[5]), value) if self.lexerPaper[0] == "Plain": self.setPaper(QtGui.QColor(attrib[5]), value) else: self.setPaper(QtGui.QColor(self.lexerPaper[1]), value) font = QtGui.QFont(attrib[0], attrib[2]) font.setBold(attrib[3]) font.setItalic(attrib[4]) self.setFont(font, value) if self.lexerPaper[0] == "Plain": self.setDefaultPaper(QtGui.QColor("#ffffff")) else: self.setDefaultPaper(QtGui.QColor(self.lexerPaper[1]))
print "eolFill" + str( style ) + "=" + str( lexer.eolFill( style ) ) print "font" + str( style ) + "=" + lexer.font( style ).toString() indexes.append( str( style ) ) print "indexes=" + ",".join( indexes ) print "" return 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() )
def defaultColor(self, ix): for i in self.styles: if i.style() == ix: return i.color() return QsciLexerCSS.defaultColor(self, ix)
def defaultFont(self, ix): for i in self.styles: if i.style() == ix: return i.font() return QsciLexerCSS.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 QsciLexerCSS.defaultColor(self, style)
def defaultPaper(self, ix): for i in self.styles: if i.style() == ix: return i.paper() return QsciLexerCSS.defaultPaper(self, ix)
def defaultEolFill(self, ix): for i in self.styles: if i.style() == ix: return i.eolFill() return QsciLexerCSS.defaultEolFill(self, ix)