1 /*
2     SPDX-License-Identifier: GPL-2.0-or-later
3     SPDX-FileCopyrightText: 2014 Lucas Hermann Negri <lucashnegri@gmail.com>
4     SPDX-FileCopyrightText: 2019 Alexander Semke <alexander.semke@web.de>
5 */
6 
7 #include "luabackend.h"
8 #include "luaextensions.h"
9 #include "luasession.h"
10 #include "luasettingswidget.h"
11 #include "settings.h"
12 
LuaBackend(QObject * parent,const QList<QVariant> args)13 LuaBackend::LuaBackend( QObject* parent,const QList<QVariant> args ) : Cantor::Backend( parent,args )
14 {
15     new LuaScriptExtension(this);
16 }
17 
id() const18 QString LuaBackend::id() const
19 {
20     return QLatin1String("lua");
21 }
22 
version() const23 QString LuaBackend::version() const
24 {
25     return QLatin1String("LuaJIT 2.0");
26 }
27 
createSession()28 Cantor::Session* LuaBackend::createSession()
29 {
30     return new LuaSession(this);
31 }
32 
capabilities() const33 Cantor::Backend::Capabilities LuaBackend::capabilities() const
34 {
35     Cantor::Backend::Capabilities cap =
36         Cantor::Backend::SyntaxHighlighting |
37         Cantor::Backend::Completion;
38 
39     return cap;
40 }
41 
requirementsFullfilled(QString * const reason) const42 bool LuaBackend::requirementsFullfilled(QString* const reason) const
43 {
44     const QString& path = LuaSettings::self()->path().toLocalFile();
45     return Cantor::Backend::checkExecutable(QLatin1String("Lua"), path, reason);
46 }
47 
helpUrl() const48 QUrl LuaBackend::helpUrl() const
49 {
50     return QUrl(i18nc("Lua official documentation", "https://www.lua.org/docs.html"));
51 }
52 
description() const53 QString LuaBackend::description() const
54 {
55     return i18n("<b>Lua</b> is a fast and lightweight scripting language, with a simple procedural syntax." \
56                 " There are several libraries in Lua aimed at math and science.");
57 }
58 
settingsWidget(QWidget * parent) const59 QWidget* LuaBackend::settingsWidget(QWidget* parent) const
60 {
61     return new LuaSettingsWidget(parent, id());
62 }
63 
config() const64 KConfigSkeleton* LuaBackend::config() const
65 {
66     return LuaSettings::self();
67 }
68 
69 K_PLUGIN_FACTORY_WITH_JSON(luabackend, "luabackend.json", registerPlugin<LuaBackend>();)
70 #include "luabackend.moc"
71