From b26948da14f88c8a74f3de43c4970ee2c52e3946 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sun, 19 Nov 2017 21:20:33 +0100 Subject: [PATCH] Fix white over grey at invalid JSON in current line The default style for invalid JSON or unclosed strings uses red background and white foreground, but the current line has precedence, so it is by default white over grey. We change the default to something more readable for the current line at invalid JSON. See issue #1173. --- src/jsontextedit.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/jsontextedit.cpp b/src/jsontextedit.cpp index c7e2245a..80686b0f 100644 --- a/src/jsontextedit.cpp +++ b/src/jsontextedit.cpp @@ -124,7 +124,24 @@ void JsonTextEdit::reloadSettings() setupSyntaxHighlightingFormat("table", QsciLexerJSON::Number); setupSyntaxHighlightingFormat("identifier", QsciLexerJSON::Property); jsonLexer->setHighlightComments(true); - + + // The default style for invalid JSON or unclosed strings uses red + // background and white foreground, but the current line has + // precedence, so it is by default white over gray. We change the + // default to something more readable for the current line at + // invalid JSON. + QColor stringColor = QColor(Settings::getValue("syntaxhighlighter", "string_colour").toString()); + jsonLexer->setColor(stringColor, QsciLexerJSON::Error); + jsonLexer->setColor(stringColor, QsciLexerJSON::UnclosedString); + QFont errorFont(Settings::getValue("editor", "font").toString()); + errorFont.setPointSize(Settings::getValue("editor", "fontsize").toInt()); + errorFont.setItalic(true); + errorFont.setUnderline(true); + jsonLexer->setFont(errorFont, QsciLexerJSON::Error); + jsonLexer->setFont(errorFont, QsciLexerJSON::UnclosedString); + jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::Error); + jsonLexer->setPaper(jsonLexer->defaultPaper(QsciLexerJSON::String), QsciLexerJSON::UnclosedString); + // Set font QFont font(Settings::getValue("editor", "font").toString()); font.setStyleHint(QFont::TypeWriter);