Skip to content
Permalink
Browse files

Expose color buttons for all known color roles

  • Loading branch information
nyalldawson committed Oct 5, 2020
1 parent 63a5cda commit dcf7da73c5a964b31e796475c2451bd372d1e4e0
@@ -40,17 +40,17 @@ QgsCodeEditorOptionsWidget::QgsCodeEditorOptionsWidget( QWidget *parent )
{QgsCodeEditor::ColorRole::Decoration, mColorDecorator },
{QgsCodeEditor::ColorRole::Number, mColorNumber },
{QgsCodeEditor::ColorRole::Comment, mColorComment },
//{QgsCodeEditor::ColorRole::CommentLine, mColorCommentLine },
{QgsCodeEditor::ColorRole::CommentLine, mColorCommentLine },
{QgsCodeEditor::ColorRole::CommentBlock, mColorCommentBlock },
{QgsCodeEditor::ColorRole::Background, mColorBackground },
{QgsCodeEditor::ColorRole::Cursor, mColorCursor },
{QgsCodeEditor::ColorRole::CaretLine, mColorCaretLine },
//{QgsCodeEditor::ColorRole::Operator, mColorOperator },
//{QgsCodeEditor::ColorRole::QuotedOperator, mColorQuotedOperator },
//{QgsCodeEditor::ColorRole::Identifier, mColorIdentifier },
//{QgsCodeEditor::ColorRole::QuotedIdentifier, mColorQuotedIdentified },
//{QgsCodeEditor::ColorRole::Tag, mColorTag },
//{QgsCodeEditor::ColorRole::UnknownTag, mColorUnknownTag },
{QgsCodeEditor::ColorRole::Operator, mColorOperator },
{QgsCodeEditor::ColorRole::QuotedOperator, mColorQuotedOperator },
{QgsCodeEditor::ColorRole::Identifier, mColorIdentifier },
{QgsCodeEditor::ColorRole::QuotedIdentifier, mColorQuotedIdentifier },
{QgsCodeEditor::ColorRole::Tag, mColorTag },
{QgsCodeEditor::ColorRole::UnknownTag, mColorUnknownTag },
{QgsCodeEditor::ColorRole::SingleQuote, mColorSingleQuote },
{QgsCodeEditor::ColorRole::DoubleQuote, mColorDoubleQuote },
{QgsCodeEditor::ColorRole::TripleSingleQuote, mColorTripleSingleQuote },
@@ -37,7 +37,28 @@ QgsCodeEditorCSS::QgsCodeEditorCSS( QWidget *parent )
void QgsCodeEditorCSS::initializeLexer()
{
QsciLexerCSS *lexer = new QsciLexerCSS( this );
lexer->setDefaultFont( getMonospaceFont() );

const QFont font = getMonospaceFont();
lexer->setDefaultFont( font );
lexer->setFont( font, -1 );

lexer->setDefaultColor( color( ColorRole::Default ) );
lexer->setDefaultPaper( color( ColorRole::Background ) );

lexer->setColor( color( ColorRole::Tag ), QsciLexerCSS::Tag );
lexer->setColor( color( ColorRole::Class ), QsciLexerCSS::ClassSelector );
lexer->setColor( color( ColorRole::Keyword ), QsciLexerCSS::Attribute );
lexer->setColor( color( ColorRole::Method ), QsciLexerCSS::PseudoClass );
lexer->setColor( color( ColorRole::Method ), QsciLexerCSS::UnknownPseudoClass );
lexer->setColor( color( ColorRole::Operator ), QsciLexerCSS::Operator );
lexer->setColor( color( ColorRole::Number ), QsciLexerCSS::Value );
lexer->setColor( color( ColorRole::Comment ), QsciLexerCSS::Comment );
lexer->setColor( color( ColorRole::DoubleQuote ), QsciLexerCSS::DoubleQuotedString );
lexer->setColor( color( ColorRole::SingleQuote ), QsciLexerCSS::SingleQuotedString );
lexer->setColor( color( ColorRole::Identifier ), QsciLexerCSS::CSS1Property );
lexer->setColor( color( ColorRole::Identifier ), QsciLexerCSS::UnknownProperty );
lexer->setColor( color( ColorRole::Identifier ), QsciLexerCSS::CSS2Property );
lexer->setColor( color( ColorRole::Identifier ), QsciLexerCSS::CSS3Property );

setLexer( lexer );
}
@@ -49,8 +49,17 @@ void QgsCodeEditorHTML::initializeLexer()
lexer->setColor( defaultColor, QsciLexerHTML::Default );
lexer->setColor( color( ColorRole::Tag ), QsciLexerHTML::Tag );
lexer->setColor( color( ColorRole::UnknownTag ), QsciLexerHTML::UnknownTag );
lexer->setColor( color( ColorRole::Method ), QsciLexerHTML::Attribute );
lexer->setColor( color( ColorRole::Method ), QsciLexerHTML::UnknownAttribute );
lexer->setColor( color( ColorRole::Class ), QsciLexerHTML::Entity );
lexer->setColor( color( ColorRole::Number ), QsciLexerHTML::HTMLNumber );
lexer->setColor( color( ColorRole::Comment ), QsciLexerHTML::HTMLComment );
lexer->setColor( color( ColorRole::Comment ), QsciLexerHTML::JavaScriptComment );
lexer->setColor( color( ColorRole::CommentLine ), QsciLexerHTML::JavaScriptCommentLine );
lexer->setColor( color( ColorRole::Number ), QsciLexerHTML::JavaScriptNumber );
lexer->setColor( color( ColorRole::Keyword ), QsciLexerHTML::JavaScriptKeyword );
lexer->setColor( color( ColorRole::DoubleQuote ), QsciLexerHTML::JavaScriptDoubleQuotedString );
lexer->setColor( color( ColorRole::SingleQuote ), QsciLexerHTML::JavaScriptSingleQuotedString );
lexer->setColor( color( ColorRole::SingleQuote ), QsciLexerHTML::HTMLSingleQuotedString );
lexer->setColor( color( ColorRole::DoubleQuote ), QsciLexerHTML::HTMLDoubleQuotedString );

@@ -37,8 +37,23 @@ QgsCodeEditorJavascript::QgsCodeEditorJavascript( QWidget *parent )
void QgsCodeEditorJavascript::initializeLexer()
{
QsciLexerJavaScript *lexer = new QsciLexerJavaScript( this );
QFont f = getMonospaceFont();
lexer->setDefaultFont( f );
lexer->setFont( f, -1 );

const QFont font = getMonospaceFont();
lexer->setDefaultFont( font );
lexer->setFont( font, -1 );

lexer->setDefaultColor( color( ColorRole::Default ) );
lexer->setDefaultPaper( color( ColorRole::Background ) );

lexer->setColor( color( ColorRole::Class ), QsciLexerJavaScript::GlobalClass );
lexer->setColor( color( ColorRole::Keyword ), QsciLexerJavaScript::Keyword );
lexer->setColor( color( ColorRole::Operator ), QsciLexerJavaScript::Operator );
lexer->setColor( color( ColorRole::Number ), QsciLexerJavaScript::Number );
lexer->setColor( color( ColorRole::Comment ), QsciLexerJavaScript::Comment );
lexer->setColor( color( ColorRole::CommentLine ), QsciLexerJavaScript::CommentLine );
lexer->setColor( color( ColorRole::DoubleQuote ), QsciLexerJavaScript::DoubleQuotedString );
lexer->setColor( color( ColorRole::SingleQuote ), QsciLexerJavaScript::SingleQuotedString );
lexer->setColor( color( ColorRole::Identifier ), QsciLexerJavaScript::Identifier );

setLexer( lexer );
}
@@ -59,13 +59,16 @@ void QgsCodeEditorPython::initializeLexer()
pyLexer->setFont( font, -1 );
pyLexer->setColor( defaultColor, QsciLexerPython::Default );
pyLexer->setColor( color( ColorRole::Class ), QsciLexerPython::ClassName );
pyLexer->setColor( color( ColorRole::Method ), QsciLexerPython::FunctionMethodName );
pyLexer->setColor( color( ColorRole::Number ), QsciLexerPython::Number );
pyLexer->setColor( color( ColorRole::Operator ), QsciLexerPython::Operator );
pyLexer->setColor( color( ColorRole::Identifier ), QsciLexerPython::Identifier );
pyLexer->setColor( color( ColorRole::Comment ), QsciLexerPython::Comment );
pyLexer->setColor( color( ColorRole::CommentBlock ), QsciLexerPython::CommentBlock );
pyLexer->setColor( color( ColorRole::Keyword ), QsciLexerPython::Keyword );
pyLexer->setColor( color( ColorRole::Decoration ), QsciLexerPython::Decorator );
pyLexer->setColor( color( ColorRole::SingleQuote ), QsciLexerPython::SingleQuotedString );
pyLexer->setColor( color( ColorRole::SingleQuote ), QsciLexerPython::DoubleQuotedString );
pyLexer->setColor( color( ColorRole::DoubleQuote ), QsciLexerPython::DoubleQuotedString );
pyLexer->setColor( color( ColorRole::TripleSingleQuote ), QsciLexerPython::TripleSingleQuotedString );
pyLexer->setColor( color( ColorRole::TripleDoubleQuote ), QsciLexerPython::TripleDoubleQuotedString );

0 comments on commit dcf7da7

Please sign in to comment.
You can’t perform that action at this time.