KSyntaxHighlighting

kquicksyntaxhighlightingplugin.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Eike Hein <hein@kde.org>
3 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
4
5 SPDX-License-Identifier: MIT
6*/
7
8#include "kquicksyntaxhighlightingplugin.h"
9#include "kquicksyntaxhighlighter.h"
10
11#include <KSyntaxHighlighting/Definition>
12#include <KSyntaxHighlighting/Repository>
13#include <KSyntaxHighlighting/Theme>
14
15#include <memory>
16
17using namespace KSyntaxHighlighting;
18
19Repository *defaultRepository()
20{
21 static std::unique_ptr<Repository> s_instance;
22 if (!s_instance) {
23 s_instance = std::make_unique<Repository>();
24 }
25 return s_instance.get();
26}
27
28void KQuickSyntaxHighlightingPlugin::registerTypes(const char *uri)
29{
30 Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.syntaxhighlighting"));
31 qRegisterMetaType<Definition>();
32 qRegisterMetaType<QList<Definition>>();
33 qRegisterMetaType<Theme>();
34 qRegisterMetaType<QList<Theme>>();
35 qmlRegisterType<KQuickSyntaxHighlighter>(uri, 1, 0, "SyntaxHighlighter");
36 qmlRegisterUncreatableMetaObject(Definition::staticMetaObject, uri, 1, 0, "Definition", {});
37 qmlRegisterUncreatableMetaObject(Theme::staticMetaObject, uri, 1, 0, "Theme", {});
38 qmlRegisterSingletonType<Repository>(uri, 1, 0, "Repository", [](auto engine, auto scriptEngine) {
39 (void)engine;
40 auto repo = defaultRepository();
41 scriptEngine->setObjectOwnership(repo, QJSEngine::CppOwnership);
42 return defaultRepository();
43 });
44}
45
46#include "moc_kquicksyntaxhighlightingplugin.cpp"
Syntax highlighting engine for Kate syntax definitions.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:33 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.