Skip to content
Permalink
Browse files

Use italic for comments in code editors

  • Loading branch information
nyalldawson committed Oct 5, 2020
1 parent f5cd52f commit 425dfcc8f3b91276277f3adf5ba0e808b9acb141
@@ -38,10 +38,18 @@ void QgsCodeEditorCSS::initializeLexer()
{
QsciLexerCSS *lexer = new QsciLexerCSS( this );

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

font.setItalic( true );
lexer->setFont( font, QsciLexerCSS::Comment );

font.setItalic( false );
font.setBold( true );
lexer->setFont( font, QsciLexerCSS::SingleQuotedString );
lexer->setFont( font, QsciLexerCSS::DoubleQuotedString );

lexer->setDefaultColor( lexerColor( ColorRole::Default ) );
lexer->setDefaultPaper( lexerColor( ColorRole::Background ) );
lexer->setPaper( lexerColor( ColorRole::Background ), -1 );
@@ -111,6 +111,11 @@ void QgsCodeEditorExpression::initializeLexer()
font.setBold( true );
mSqlLexer->setFont( font, QsciLexerSQL::Keyword );

font.setBold( false );
font.setItalic( true );
mSqlLexer->setFont( font, QsciLexerSQL::Comment );
mSqlLexer->setFont( font, QsciLexerSQL::CommentLine );

mSqlLexer->setColor( Qt::darkYellow, QsciLexerSQL::DoubleQuotedString ); // fields

mSqlLexer->setColor( defaultColor, QsciLexerSQL::Default );
@@ -46,6 +46,11 @@ void QgsCodeEditorHTML::initializeLexer()
lexer->setDefaultPaper( lexerColor( ColorRole::Background ) );
lexer->setFont( font, -1 );

font.setItalic( true );
lexer->setFont( font, QsciLexerHTML::HTMLComment );
lexer->setFont( font, QsciLexerHTML::JavaScriptComment );
lexer->setFont( font, QsciLexerHTML::JavaScriptCommentLine );

lexer->setColor( defaultColor, QsciLexerHTML::Default );
lexer->setColor( lexerColor( ColorRole::Tag ), QsciLexerHTML::Tag );
lexer->setColor( lexerColor( ColorRole::UnknownTag ), QsciLexerHTML::UnknownTag );
@@ -38,10 +38,14 @@ void QgsCodeEditorJavascript::initializeLexer()
{
QsciLexerJavaScript *lexer = new QsciLexerJavaScript( this );

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

font.setItalic( true );
lexer->setFont( font, QsciLexerJavaScript::Comment );
lexer->setFont( font, QsciLexerJavaScript::CommentLine );

lexer->setDefaultColor( lexerColor( ColorRole::Default ) );
lexer->setDefaultPaper( lexerColor( ColorRole::Background ) );
lexer->setPaper( lexerColor( ColorRole::Background ), -1 );
@@ -57,6 +57,16 @@ void QgsCodeEditorPython::initializeLexer()
pyLexer->setDefaultColor( defaultColor );
pyLexer->setDefaultPaper( lexerColor( ColorRole::Background ) );
pyLexer->setFont( font, -1 );

font.setItalic( true );
pyLexer->setFont( font, QsciLexerPython::Comment );
pyLexer->setFont( font, QsciLexerPython::CommentBlock );

font.setItalic( false );
font.setBold( true );
pyLexer->setFont( font, QsciLexerPython::SingleQuotedString );
pyLexer->setFont( font, QsciLexerPython::DoubleQuotedString );

pyLexer->setColor( defaultColor, QsciLexerPython::Default );
pyLexer->setColor( lexerColor( ColorRole::Class ), QsciLexerPython::ClassName );
pyLexer->setColor( lexerColor( ColorRole::Method ), QsciLexerPython::FunctionMethodName );
@@ -48,6 +48,11 @@ void QgsCodeEditorSQL::initializeLexer()
font.setBold( true );
mSqlLexer->setFont( font, QsciLexerSQL::Keyword );

font.setBold( false );
font.setItalic( true );
mSqlLexer->setFont( font, QsciLexerSQL::Comment );
mSqlLexer->setFont( font, QsciLexerSQL::CommentLine );

mSqlLexer->setColor( defaultColor, QsciLexerSQL::Default );
mSqlLexer->setColor( lexerColor( ColorRole::Comment ), QsciLexerSQL::Comment );
mSqlLexer->setColor( lexerColor( ColorRole::CommentLine ), QsciLexerSQL::CommentLine );

0 comments on commit 425dfcc

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