ui: Fixed text color resetting in code view
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
QVector<QtHighlighter::HighlightingRule> QtHighlighter::s_highlightingRules;
|
||||
QtHighlighter::HighlightingRule QtHighlighter::s_quotationRule;
|
||||
QtHighlighter::HighlightingRule QtHighlighter::s_commentRule;
|
||||
QTextCharFormat QtHighlighter::s_textFormat;
|
||||
|
||||
void QtHighlighter::createHighlightingRules()
|
||||
{
|
||||
@@ -36,6 +37,8 @@ void QtHighlighter::createHighlightingRules()
|
||||
|
||||
ColorScheme* scheme = ColorScheme::getInstance().get();
|
||||
|
||||
s_textFormat.setForeground(QColor(scheme->getSyntaxColor("normal").c_str()));
|
||||
|
||||
QColor directiveColor(scheme->getSyntaxColor("directive").c_str());
|
||||
QColor keywordColor(scheme->getSyntaxColor("keyword").c_str());
|
||||
QColor typeColor(scheme->getSyntaxColor("type").c_str());
|
||||
@@ -88,6 +91,15 @@ void QtHighlighter::highlightDocument()
|
||||
|
||||
QTextDocument* doc = document();
|
||||
|
||||
int docStart = 0;
|
||||
int docEnd = 0;
|
||||
for (int i = 0; i < doc->blockCount(); i++)
|
||||
{
|
||||
docEnd += doc->findBlockByLineNumber(i).length();
|
||||
}
|
||||
docEnd -= 1;
|
||||
applyFormat(docStart, docEnd, s_textFormat);
|
||||
|
||||
std::vector<std::pair<int, int>> ranges;
|
||||
|
||||
for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next())
|
||||
|
||||
@@ -42,6 +42,7 @@ private:
|
||||
static QVector<HighlightingRule> s_highlightingRules;
|
||||
static HighlightingRule s_quotationRule;
|
||||
static HighlightingRule s_commentRule;
|
||||
static QTextCharFormat s_textFormat;
|
||||
};
|
||||
|
||||
#endif // QT_HIGHLIGHTER_H
|
||||
|
||||
Reference in New Issue
Block a user