forked from qt-creator/qt-creator
TextEditor: add convenience function to clear all extra highlights
Change-Id: Id3a3c45041a23ba100447d926ed6ab829abbc92b Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -176,14 +176,8 @@ QByteArray CppEditorDocument::contentsText() const
|
|||||||
|
|
||||||
void CppEditorDocument::applyFontSettings()
|
void CppEditorDocument::applyFontSettings()
|
||||||
{
|
{
|
||||||
if (TextEditor::SyntaxHighlighter *highlighter = syntaxHighlighter()) {
|
if (TextEditor::SyntaxHighlighter *highlighter = syntaxHighlighter())
|
||||||
// Clear all additional formats since they may have changed
|
highlighter->clearAllExtraFormats(); // Clear all additional formats since they may have changed
|
||||||
QTextBlock b = document()->firstBlock();
|
|
||||||
while (b.isValid()) {
|
|
||||||
highlighter->clearExtraFormats(b);
|
|
||||||
b = b.next();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
TextDocument::applyFontSettings(); // rehighlights and updates additional formats
|
||||||
if (m_processor)
|
if (m_processor)
|
||||||
m_processor->semanticRehighlight();
|
m_processor->semanticRehighlight();
|
||||||
|
@@ -721,6 +721,15 @@ void SyntaxHighlighter::clearExtraFormats(const QTextBlock &block)
|
|||||||
d->inReformatBlocks = wasInReformatBlocks;
|
d->inReformatBlocks = wasInReformatBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SyntaxHighlighter::clearAllExtraFormats()
|
||||||
|
{
|
||||||
|
QTextBlock b = document()->firstBlock();
|
||||||
|
while (b.isValid()) {
|
||||||
|
clearExtraFormats(b);
|
||||||
|
b = b.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Generate at least n different colors for highlighting, excluding background
|
/* Generate at least n different colors for highlighting, excluding background
|
||||||
* color. */
|
* color. */
|
||||||
|
|
||||||
|
@@ -65,6 +65,7 @@ public:
|
|||||||
|
|
||||||
void setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &&formats);
|
void setExtraFormats(const QTextBlock &block, QVector<QTextLayout::FormatRange> &&formats);
|
||||||
void clearExtraFormats(const QTextBlock &block);
|
void clearExtraFormats(const QTextBlock &block);
|
||||||
|
void clearAllExtraFormats();
|
||||||
|
|
||||||
static QList<QColor> generateColors(int n, const QColor &background);
|
static QList<QColor> generateColors(int n, const QColor &background);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user