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.
This commit is contained in:
mgrojo
2017-11-19 21:20:33 +01:00
parent 24a573dc68
commit b26948da14

View File

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