diff options
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp')
| -rw-r--r-- | SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp b/SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp index 6ca5c59..58e4315 100644 --- a/SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp +++ b/SQLiteStudio3/guiSQLiteStudio/qtscriptsyntaxhighlighter.cpp @@ -1,6 +1,7 @@ #include "qtscriptsyntaxhighlighter.h" -#include "uiconfig.h" - +#include "style.h" +#include <QApplication> +#include <QStyle> #include <QPlainTextEdit> JavaScriptSyntaxHighlighter::JavaScriptSyntaxHighlighter(QTextDocument *parent) @@ -183,6 +184,7 @@ JavaScriptSyntaxHighlighter::JavaScriptSyntaxHighlighter(QTextDocument *parent) m_knownIds << "userAgent"; keywordsFormat.setFontWeight(QFont::Bold); + commentFormat.setFontItalic(true); } void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) @@ -197,6 +199,12 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) Regex = 5 }; + commentFormat.setForeground(QApplication::style()->standardPalette().dark()); + keywordsFormat.setForeground(QApplication::style()->standardPalette().windowText()); + keywordsFormat.setFontWeight(QFont::Bold); + normalFormat.setForeground(QApplication::style()->standardPalette().text()); + stringFormat.setForeground(STYLE->extendedPalette().editorString()); + int state = previousBlockState(); int start = 0; int i = 0; @@ -225,13 +233,13 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) state = Comment; } else if (ch == '/' && next == '/') { i = text.length(); - setFormat(start, text.length(), CFG_UI.Colors.JavaScriptComment.get()); + setFormat(start, text.length(), commentFormat); } else if (ch == '/' && next != '*') { ++i; state = Regex; } else { if (!QString("(){}[]").contains(ch)) - setFormat(start, 1, CFG_UI.Colors.JavaScriptOperator.get()); + setFormat(start, 1, normalFormat); ++i; state = Start; } @@ -239,7 +247,7 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) case Number: if (ch.isSpace() || !ch.isDigit()) { - setFormat(start, i - start, CFG_UI.Colors.JavaScriptNumber.get()); + setFormat(start, i - start, normalFormat); state = Start; } else { ++i; @@ -250,12 +258,10 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) if (ch.isSpace() || !(ch.isDigit() || ch.isLetter() || ch == '_')) { QString token = text.mid(start, i - start).trimmed(); if (m_keywords.contains(token)) - { - keywordsFormat.setForeground(CFG_UI.Colors.JavaScriptKeyword.get()); setFormat(start, i - start, keywordsFormat); - } else if (m_knownIds.contains(token)) - setFormat(start, i - start, CFG_UI.Colors.JavaScriptBuiltIn.get()); + setFormat(start, i - start, normalFormat); + state = Start; } else { ++i; @@ -267,7 +273,7 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) QChar prev = (i > 0) ? text.at(i - 1) : QChar(); if (prev != '\\') { ++i; - setFormat(start, i - start, CFG_UI.Colors.JavaScriptString.get()); + setFormat(start, i - start, stringFormat); state = Start; } else { ++i; @@ -281,7 +287,7 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) if (ch == '*' && next == '/') { ++i; ++i; - setFormat(start, i - start, CFG_UI.Colors.JavaScriptComment.get()); + setFormat(start, i - start, commentFormat); state = Start; } else { ++i; @@ -293,7 +299,7 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) QChar prev = (i > 0) ? text.at(i - 1) : QChar(); if (prev != '\\') { ++i; - setFormat(start, i - start, CFG_UI.Colors.JavaScriptString.get()); + setFormat(start, i - start, normalFormat); state = Start; } else { ++i; @@ -310,7 +316,7 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) } if (state == Comment) - setFormat(start, text.length(), CFG_UI.Colors.JavaScriptComment.get()); + setFormat(start, text.length(), commentFormat); else state = Start; @@ -318,8 +324,8 @@ void JavaScriptSyntaxHighlighter::highlightBlock(const QString &text) int pos = 0; int len = m_markString.length(); QTextCharFormat markerFormat; - markerFormat.setBackground(CFG_UI.Colors.JavaScriptMarker.get()); - markerFormat.setForeground(CFG_UI.Colors.JavaScriptFg.get()); + markerFormat.setBackground(QApplication::style()->standardPalette().alternateBase()); + markerFormat.setForeground(QApplication::style()->standardPalette().text()); for (;;) { pos = text.indexOf(m_markString, pos, m_markCaseSensitivity); if (pos < 0) |
