@@ -106,27 +106,27 @@ void Highlighter::setSymbols(const QStringList &symbols)
106106 }
107107}
108108
109- void Highlighter::setStyle ( const CodeEditorStyle &newStyle )
109+ void Highlighter::setStyle (const CodeEditorStyle &newStyle)
110110{
111- mKeywordFormat .setForeground ( newStyle.keywordColor );
112- mKeywordFormat .setFontWeight ( newStyle.keywordWeight );
113- mClassFormat .setForeground ( newStyle.classColor );
114- mClassFormat .setFontWeight ( newStyle.classWeight );
115- mSingleLineCommentFormat .setForeground ( newStyle.commentColor );
116- mSingleLineCommentFormat .setFontWeight ( newStyle.commentWeight );
117- mMultiLineCommentFormat .setForeground ( newStyle.commentColor );
118- mMultiLineCommentFormat .setFontWeight ( newStyle.commentWeight );
119- mQuotationFormat .setForeground ( newStyle.quoteColor );
120- mQuotationFormat .setFontWeight ( newStyle.quoteWeight );
121- mSymbolFormat .setForeground ( newStyle.symbolFGColor );
122- mSymbolFormat .setBackground ( newStyle.symbolBGColor );
123- mSymbolFormat .setFontWeight ( newStyle.symbolWeight );
124- for ( HighlightingRule& rule : mHighlightingRules ) {
125- applyFormat ( rule );
111+ mKeywordFormat .setForeground (newStyle.keywordColor );
112+ mKeywordFormat .setFontWeight (newStyle.keywordWeight );
113+ mClassFormat .setForeground (newStyle.classColor );
114+ mClassFormat .setFontWeight (newStyle.classWeight );
115+ mSingleLineCommentFormat .setForeground (newStyle.commentColor );
116+ mSingleLineCommentFormat .setFontWeight (newStyle.commentWeight );
117+ mMultiLineCommentFormat .setForeground (newStyle.commentColor );
118+ mMultiLineCommentFormat .setFontWeight (newStyle.commentWeight );
119+ mQuotationFormat .setForeground (newStyle.quoteColor );
120+ mQuotationFormat .setFontWeight (newStyle.quoteWeight );
121+ mSymbolFormat .setForeground (newStyle.symbolFGColor );
122+ mSymbolFormat .setBackground (newStyle.symbolBGColor );
123+ mSymbolFormat .setFontWeight (newStyle.symbolWeight );
124+ for ( HighlightingRule& rule : mHighlightingRules ) {
125+ applyFormat (rule);
126126 }
127127
128- for ( HighlightingRule& rule : mHighlightingRulesWithSymbols ) {
129- applyFormat ( rule );
128+ for ( HighlightingRule& rule : mHighlightingRulesWithSymbols ) {
129+ applyFormat (rule);
130130 }
131131}
132132
@@ -162,43 +162,42 @@ void Highlighter::highlightBlock(const QString &text)
162162 }
163163}
164164
165- void Highlighter::applyFormat ( HighlightingRule &rule )
165+ void Highlighter::applyFormat (HighlightingRule &rule)
166166{
167- switch ( rule.ruleRole )
168- {
169- case RuleRole::Keyword:
170- rule.format = mKeywordFormat ;
171- break ;
172- case RuleRole::Class:
173- rule.format = mClassFormat ;
174- break ;
175- case RuleRole::Comment:
176- rule.format = mSingleLineCommentFormat ;
177- break ;
178- case RuleRole::Quote:
179- rule.format = mQuotationFormat ;
180- break ;
181- case RuleRole::Symbol:
182- rule.format = mSymbolFormat ;
183- break ;
167+ switch (rule.ruleRole ) {
168+ case RuleRole::Keyword:
169+ rule.format = mKeywordFormat ;
170+ break ;
171+ case RuleRole::Class:
172+ rule.format = mClassFormat ;
173+ break ;
174+ case RuleRole::Comment:
175+ rule.format = mSingleLineCommentFormat ;
176+ break ;
177+ case RuleRole::Quote:
178+ rule.format = mQuotationFormat ;
179+ break ;
180+ case RuleRole::Symbol:
181+ rule.format = mSymbolFormat ;
182+ break ;
184183 }
185184}
186185
187186CodeEditor::CodeEditor (QWidget *parent) :
188187 QPlainTextEdit(parent),
189- mWidgetStyle( new CodeEditorStyle( defaultStyleLight ))
188+ mWidgetStyle(new CodeEditorStyle(defaultStyleLight))
190189{
191190 mLineNumberArea = new LineNumberArea (this );
192- mHighlighter = new Highlighter ( document (), mWidgetStyle );
191+ mHighlighter = new Highlighter (document (), mWidgetStyle );
193192 mErrorPosition = -1 ;
194193
195- QFont font ( " Monospace" );
196- font.setStyleHint ( QFont::TypeWriter );
197- setFont ( font );
194+ QFont font (" Monospace" );
195+ font.setStyleHint (QFont::TypeWriter);
196+ setFont (font);
198197
199198 // set widget coloring by overriding widget style sheet
200199 setObjectName (" CodeEditor" );
201- setStyleSheet ( generateStyleString () );
200+ setStyleSheet (generateStyleString ());
202201
203202 connect (this , SIGNAL (blockCountChanged (int )), this , SLOT (updateLineNumberAreaWidth (int )));
204203 connect (this , SIGNAL (updateRequest (QRect,int )), this , SLOT (updateLineNumberArea (QRect,int )));
@@ -230,8 +229,8 @@ void CodeEditor::setStyle(const CodeEditorStyle& newStyle)
230229{
231230 *mWidgetStyle = newStyle;
232231 // apply new styling
233- setStyleSheet ( generateStyleString () );
234- mHighlighter ->setStyle ( newStyle );
232+ setStyleSheet (generateStyleString ());
233+ mHighlighter ->setStyle (newStyle);
235234 mHighlighter ->rehighlight ();
236235 highlightErrorLine ();
237236}
@@ -296,7 +295,7 @@ void CodeEditor::highlightErrorLine()
296295 selection.format .setBackground (mWidgetStyle ->highlightBGColor );
297296 selection.format .setProperty (QTextFormat::FullWidthSelection, true );
298297 selection.cursor = QTextCursor (document ());
299- if ( mErrorPosition >= 0 ) {
298+ if ( mErrorPosition >= 0 ) {
300299 selection.cursor .setPosition (mErrorPosition );
301300 } else {
302301 selection.cursor .setPosition (0 );
0 commit comments