1/*
2 SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_SCRIPTHELPERS_H
8#define KATE_SCRIPTHELPERS_H
9
10#include <QJSValue>
11#include <QObject>
12#include <ktexteditor_export.h>
13
14class QJSEngine;
15
16namespace Kate
17{
18/** Top-level script functions */
19namespace Script
20{
21/** read complete file contents, helper */
22KTEXTEDITOR_EXPORT bool readFile(const QString &sourceUrl, QString &sourceCode);
23
24} // namespace Script
25
26class KTEXTEDITOR_EXPORT ScriptHelper : public QObject
27{
28 Q_OBJECT
29 QJSEngine *m_engine;
30
31public:
32 explicit ScriptHelper(QJSEngine *engine)
33 : m_engine(engine)
34 {
35 }
36 Q_INVOKABLE QString read(const QString &file);
37 Q_INVOKABLE void require(const QString &file);
38 Q_INVOKABLE void debug(const QString &msg);
39 Q_INVOKABLE QString _i18n(const QString &msg);
40 Q_INVOKABLE QString _i18nc(const QString &textContext, const QString &text);
41 Q_INVOKABLE QString _i18np(const QString &trSingular, const QString &trPlural, int number);
42 Q_INVOKABLE QString _i18ncp(const QString &trContext, const QString &trSingular, const QString &trPlural, int number = 0);
43};
44
45} // namespace Kate
46
47#endif
48

source code of ktexteditor/src/script/katescripthelpers.h