Skip to content

Commit

Permalink
Fix rendering of CSS comments in QgsCodeEditorCSS
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 7, 2020
1 parent 4996144 commit 3f40dbf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/gui/auto_generated/codeeditors/qgscodeeditorcss.sip.in
Expand Up @@ -10,6 +10,8 @@





class QgsCodeEditorCSS : QgsCodeEditor
{
%Docstring
Expand Down
20 changes: 19 additions & 1 deletion src/gui/codeeditors/qgscodeeditorcss.cpp
Expand Up @@ -36,7 +36,7 @@ QgsCodeEditorCSS::QgsCodeEditorCSS( QWidget *parent )

void QgsCodeEditorCSS::initializeLexer()
{
QsciLexerCSS *lexer = new QsciLexerCSS( this );
QsciLexerCSS *lexer = new QgsQsciLexerCSS( this );

QFont font = lexerFont();
lexer->setDefaultFont( font );
Expand Down Expand Up @@ -71,3 +71,21 @@ void QgsCodeEditorCSS::initializeLexer()

setLexer( lexer );
}

//
// QgsQsciLexerCSS
//
QgsQsciLexerCSS::QgsQsciLexerCSS( QObject *parent )
: QsciLexerCSS( parent )
{

}

QString QgsQsciLexerCSS::description( int style ) const
{
// see https://www.riverbankcomputing.com/pipermail/qscintilla/2019-July/001415.html
if ( style == QsciLexerCSS::Comment )
return QStringLiteral( "Comment" );

return QsciLexerCSS::description( style );
}
17 changes: 17 additions & 0 deletions src/gui/codeeditors/qgscodeeditorcss.h
Expand Up @@ -19,10 +19,27 @@
#include "qgscodeeditor.h"
#include "qgis_sip.h"
#include "qgis_gui.h"
#include <Qsci/qscilexercss.h>

SIP_IF_MODULE( HAVE_QSCI_SIP )


#ifndef SIP_RUN
///@cond PRIVATE
class QgsQsciLexerCSS : public QsciLexerCSS
{
Q_OBJECT
public:

QgsQsciLexerCSS( QObject *parent = nullptr );

QString description( int style ) const override;

};
///@endcond
#endif


/**
* \ingroup gui
* A CSS editor based on QScintilla2. Adds syntax highlighting and
Expand Down

0 comments on commit 3f40dbf

Please sign in to comment.