forked from qt-creator/qt-creator
Made the highlighting for locals and fields configurable
Reviewed-by: mae
This commit is contained in:
@@ -898,12 +898,6 @@ void CPPEditor::highlightTypeUsages(int from, int to)
|
|||||||
Q_ASSERT(!chunks.isEmpty());
|
Q_ASSERT(!chunks.isEmpty());
|
||||||
QTextBlock b = doc->findBlockByNumber(m_nextHighlightBlockNumber);
|
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);
|
QMapIterator<int, QVector<SemanticInfo::Use> > it(chunks);
|
||||||
while (b.isValid() && it.hasNext()) {
|
while (b.isValid() && it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
@@ -926,11 +920,11 @@ void CPPEditor::highlightTypeUsages(int from, int to)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SemanticInfo::Use::Field:
|
case SemanticInfo::Use::Field:
|
||||||
formatRange.format = memberUseFormat;
|
formatRange.format = m_fieldFormat;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SemanticInfo::Use::Local:
|
case SemanticInfo::Use::Local:
|
||||||
formatRange.format = localUseFormat;
|
formatRange.format = m_localFormat;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1641,7 +1635,6 @@ void CPPEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
|||||||
|
|
||||||
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
|
const QVector<QTextCharFormat> formats = fs.toTextCharFormats(categories);
|
||||||
highlighter->setFormats(formats.constBegin(), formats.constEnd());
|
highlighter->setFormats(formats.constBegin(), formats.constEnd());
|
||||||
highlighter->rehighlight();
|
|
||||||
|
|
||||||
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
|
m_occurrencesFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES));
|
||||||
m_occurrencesUnusedFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_UNUSED));
|
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_occurrencesUnusedFormat.setToolTip(tr("Unused variable"));
|
||||||
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
|
m_occurrenceRenameFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_OCCURRENCES_RENAME));
|
||||||
m_typeFormat = fs.toTextCharFormat(QLatin1String(TextEditor::Constants::C_TYPE));
|
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));
|
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
|
// only set the background, we do not want to modify foreground properties set by the syntax highlighter or the link
|
||||||
m_occurrencesFormat.clearForeground();
|
m_occurrencesFormat.clearForeground();
|
||||||
m_occurrenceRenameFormat.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)
|
void CPPEditor::setTabSettings(const TextEditor::TabSettings &ts)
|
||||||
|
|||||||
@@ -285,6 +285,8 @@ private:
|
|||||||
QTextCharFormat m_occurrencesUnusedFormat;
|
QTextCharFormat m_occurrencesUnusedFormat;
|
||||||
QTextCharFormat m_occurrenceRenameFormat;
|
QTextCharFormat m_occurrenceRenameFormat;
|
||||||
QTextCharFormat m_typeFormat;
|
QTextCharFormat m_typeFormat;
|
||||||
|
QTextCharFormat m_localFormat;
|
||||||
|
QTextCharFormat m_fieldFormat;
|
||||||
QTextCharFormat m_keywordFormat;
|
QTextCharFormat m_keywordFormat;
|
||||||
|
|
||||||
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
QList<QTextEdit::ExtraSelection> m_renameSelections;
|
||||||
|
|||||||
@@ -108,6 +108,8 @@ const char * const C_OCCURRENCES_RENAME = "Occurrences.Rename";
|
|||||||
const char * const C_NUMBER = "Number";
|
const char * const C_NUMBER = "Number";
|
||||||
const char * const C_STRING = "String";
|
const char * const C_STRING = "String";
|
||||||
const char * const C_TYPE = "Type";
|
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_KEYWORD = "Keyword";
|
||||||
const char * const C_OPERATOR = "Operator";
|
const char * const C_OPERATOR = "Operator";
|
||||||
const char * const C_PREPROCESSOR = "Preprocessor";
|
const char * const C_PREPROCESSOR = "Preprocessor";
|
||||||
|
|||||||
@@ -126,6 +126,8 @@ TextEditorSettings::TextEditorSettings(QObject *parent)
|
|||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_NUMBER), tr("Number"), Qt::darkBlue));
|
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_STRING), tr("String"), Qt::darkGreen));
|
||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_TYPE), tr("Type"), Qt::darkMagenta));
|
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_KEYWORD), tr("Keyword"), Qt::darkYellow));
|
||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator")));
|
formatDescriptions.append(FormatDescription(QLatin1String(C_OPERATOR), tr("Operator")));
|
||||||
formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue));
|
formatDescriptions.append(FormatDescription(QLatin1String(C_PREPROCESSOR), tr("Preprocessor"), Qt::darkBlue));
|
||||||
|
|||||||
Reference in New Issue
Block a user