forked from qt-creator/qt-creator
SyntaxHighlighter: Fix tst_highlighter
Change-Id: I96c6c7b9843384d14bfa37b6bfdd494c881949af Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -28,9 +28,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyntaxHighlighterRunnerPrivate(BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator,
|
SyntaxHighlighterRunnerPrivate(BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator,
|
||||||
QTextDocument *document)
|
QTextDocument *document, FontSettings fontSettings)
|
||||||
: m_creator(creator)
|
: m_creator(creator)
|
||||||
, m_document(document)
|
, m_document(document)
|
||||||
|
, m_fontSettings(fontSettings)
|
||||||
{
|
{
|
||||||
m_highlighter.reset(m_creator());
|
m_highlighter.reset(m_creator());
|
||||||
createHighlighter();
|
createHighlighter();
|
||||||
@@ -109,14 +110,16 @@ private:
|
|||||||
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator m_creator;
|
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator m_creator;
|
||||||
std::unique_ptr<SyntaxHighlighter> m_highlighter;
|
std::unique_ptr<SyntaxHighlighter> m_highlighter;
|
||||||
QTextDocument *m_document = nullptr;
|
QTextDocument *m_document = nullptr;
|
||||||
const FontSettings m_fontSettings = TextEditorSettings::fontSettings();
|
FontSettings m_fontSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------- BaseSyntaxHighlighterRunner --------------------------------------
|
// ----------------------------- BaseSyntaxHighlighterRunner --------------------------------------
|
||||||
|
|
||||||
BaseSyntaxHighlighterRunner::BaseSyntaxHighlighterRunner(
|
BaseSyntaxHighlighterRunner::BaseSyntaxHighlighterRunner(
|
||||||
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator, QTextDocument *document)
|
BaseSyntaxHighlighterRunner::SyntaxHighLighterCreator creator,
|
||||||
: d(new SyntaxHighlighterRunnerPrivate(creator, document))
|
QTextDocument *document,
|
||||||
|
const TextEditor::FontSettings &fontSettings)
|
||||||
|
: d(new SyntaxHighlighterRunnerPrivate(creator, document, fontSettings))
|
||||||
{
|
{
|
||||||
m_document = document;
|
m_document = document;
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/syntaxhighlighter.h>
|
#include <texteditor/syntaxhighlighter.h>
|
||||||
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <KSyntaxHighlighting/Definition>
|
#include <KSyntaxHighlighting/Definition>
|
||||||
|
|
||||||
@@ -28,7 +30,10 @@ public:
|
|||||||
QString text;
|
QString text;
|
||||||
};
|
};
|
||||||
|
|
||||||
BaseSyntaxHighlighterRunner(SyntaxHighLighterCreator creator, QTextDocument *document);
|
BaseSyntaxHighlighterRunner(SyntaxHighLighterCreator creator,
|
||||||
|
QTextDocument *document,
|
||||||
|
const TextEditor::FontSettings &fontSettings
|
||||||
|
= TextEditorSettings::fontSettings());
|
||||||
virtual ~BaseSyntaxHighlighterRunner();
|
virtual ~BaseSyntaxHighlighterRunner();
|
||||||
|
|
||||||
void setExtraFormats(const QMap<int, QList<QTextLayout::FormatRange>> &formats);
|
void setExtraFormats(const QMap<int, QList<QTextLayout::FormatRange>> &formats);
|
||||||
|
@@ -56,13 +56,11 @@ Second with spaces
|
|||||||
|
|
||||||
Last)";
|
Last)";
|
||||||
|
|
||||||
|
|
||||||
doc = new QTextDocument();
|
doc = new QTextDocument();
|
||||||
doc->setPlainText(text);
|
doc->setPlainText(text);
|
||||||
|
|
||||||
highlighterRunner
|
highlighterRunner = new BaseSyntaxHighlighterRunner(
|
||||||
= new BaseSyntaxHighlighterRunner([this] { return new SyntaxHighlighter(doc, fontsettings); },
|
[this] { return new SyntaxHighlighter(doc, fontsettings); }, doc, fontsettings);
|
||||||
doc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const HighlightingResults &highlightingResults()
|
static const HighlightingResults &highlightingResults()
|
||||||
|
Reference in New Issue
Block a user