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);