aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/syntaxhighlighter.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2023-05-16 14:57:37 +0200
committerDavid Schulz <david.schulz@qt.io>2023-05-25 07:01:35 +0000
commitf235a72554693414d39ae1d59dc42d13b7deca2a (patch)
tree892151e0b0ce5157c138bce123c863477c5a0045 /src/plugins/texteditor/syntaxhighlighter.cpp
parent31090ded156173e17a6be2772f4f098de60787a6 (diff)
TextEditor: add tests for semantic highlighter
Change-Id: Id64c933f01c0dbc0e077656b6f4260b93e124311 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/texteditor/syntaxhighlighter.cpp')
-rw-r--r--src/plugins/texteditor/syntaxhighlighter.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/plugins/texteditor/syntaxhighlighter.cpp b/src/plugins/texteditor/syntaxhighlighter.cpp
index de72c7b0db..6d2616193e 100644
--- a/src/plugins/texteditor/syntaxhighlighter.cpp
+++ b/src/plugins/texteditor/syntaxhighlighter.cpp
@@ -23,8 +23,12 @@ class SyntaxHighlighterPrivate
Q_DECLARE_PUBLIC(SyntaxHighlighter)
public:
SyntaxHighlighterPrivate()
+ : SyntaxHighlighterPrivate(TextEditorSettings::fontSettings())
+ { }
+
+ SyntaxHighlighterPrivate(const FontSettings &fontSettings)
{
- updateFormats(TextEditorSettings::fontSettings());
+ updateFormats(fontSettings);
}
QPointer<QTextDocument> doc;
@@ -76,6 +80,16 @@ void SyntaxHighlighter::delayedRehighlight()
rehighlight();
}
+#ifdef WITH_TESTS
+SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent, const FontSettings &fontsettings)
+ : QObject(parent), d_ptr(new SyntaxHighlighterPrivate(fontsettings))
+{
+ d_ptr->q_ptr = this;
+ if (parent)
+ setDocument(parent);
+}
+#endif
+
void SyntaxHighlighterPrivate::applyFormatChanges(int from, int charsRemoved, int charsAdded)
{
bool formatsChanged = false;