summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/plugins/cppeditor/cppeditor.cpp23
-rw-r--r--src/plugins/cppeditor/cppeditor.h2
-rw-r--r--src/plugins/texteditor/texteditorconstants.h2
-rw-r--r--src/plugins/texteditor/texteditorsettings.cpp2
4 files changed, 20 insertions, 9 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp
index 034e178312..663bc73f62 100644
--- a/src/plugins/cppeditor/cppeditor.cpp
+++ b/src/plugins/cppeditor/cppeditor.cpp
@@ -898,12 +898,6 @@ void CPPEditor::highlightTypeUsages(int from, int to)
Q_ASSERT(!chunks.isEmpty());
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
- QTextCharFormat localUseFormat;
- localUseFormat.setForeground(Qt::darkBlue); // ### hardcoded
-
- QTextCharFormat memberUseFormat;
- memberUseFormat.setForeground(Qt::darkRed); // ### hardcoded
-
QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks);
while (b.isValid() && it.hasNext()) {
it.next();
@@ -926,11 +920,11 @@ void CPPEditor::highlightTypeUsages(int from, int to)
break;
case SemanticInfo::Use::Field:
- formatRange.format = memberUseFormat;
+ formatRange.format = m_fieldFormat;
break;
case SemanticInfo::Use::Local:
- formatRange.format = localUseFormat;
+ formatRange.format = m_localFormat;
break;
default:
@@ -1641,7 +1635,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
highlighter->setFormats(formats.constBegin(), formats.constEnd());
- highlighter->rehighlight();
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
m_occurrencesUnusedFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_UNUSED));
@@ -1651,11 +1644,23 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
m_occurrencesUnusedFormat.setToolTip(tr("Unused variable"));
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
m_typeFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_TYPE));
+ m_localFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_LOCAL));
+ m_fieldFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_FIELD));
m_keywordFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_KEYWORD));
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
m_occurrencesFormat.clearForeground();
m_occurrenceRenameFormat.clearForeground();
+
+ // Clear all additional formats since they may have changed
+ QTextBlock b = document()->firstBlock();
+ while (b.isValid()) {
+ highlighter->setExtraAdditionalFormats(b, QList<QTextLayout::FormatRange>());
+ b = b.next();
+ }
+
+ // This also triggers an update of the additional formats
+ highlighter->rehighlight();
}
void CPPEditor::setTabSettings(const TextEditor::TabSettings &ts)
diff --git a/src/plugins/cppeditor/cppeditor.h b/src/plugins/cppeditor/cppeditor.h
index 738a977586..cf07b3d51d 100644
--- a/src/plugins/cppeditor/cppeditor.h
+++ b/src/plugins/cppeditor/cppeditor.h
@@ -285,6 +285,8 @@ private:
QTextCharFormat m_occurrencesUnusedFormat;
QTextCharFormat m_occurrenceRenameFormat;
QTextCharFormat m_typeFormat;
+ QTextCharFormat m_localFormat;
+ QTextCharFormat m_fieldFormat;
QTextCharFormat m_keywordFormat;
QList<QTextEdit::ExtraSelection> m_renameSelections;
diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h
index 1dc5d365d4..e1c6b12deb 100644
--- a/src/plugins/texteditor/texteditorconstants.h
+++ b/src/plugins/texteditor/texteditorconstants.h
@@ -108,6 +108,8 @@ const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
const char * const C_NUMBER = "Number";
const char * const C_STRING = "String";
const char * const C_TYPE = "Type";
+const char * const C_LOCAL = "Local";
+const char * const C_FIELD = "Field";
const char * const C_KEYWORD = "Keyword";
const char * const C_OPERATOR = "Operator";
const char * const C_PREPROCESSOR = "Preprocessor";
diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp
index 48d0193138..96dc201fbd 100644
--- a/src/plugins/texteditor/texteditorsettings.cpp
+++ b/src/plugins/texteditor/texteditorsettings.cpp
@@ -126,6 +126,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue));
formatDescriptions.append(FormatDescription(QLatin1String(C_STRING), tr("String"), Qt::darkGreen));
formatDescriptions.append(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta));
+ formatDescriptions.append(FormatDescription(QLatin1String(C_LOCAL), tr("Local"), Qt::darkBlue));
+ formatDescriptions.append(FormatDescription(QLatin1String(C_FIELD), tr("Field"), Qt::darkRed));
formatDescriptions.append(FormatDescription(QLatin1String(C_KEYWORD), tr("Keyword"), Qt::darkYellow));
formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator")));
formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue));