File indexing completed on 2024-03-24 04:00:27
0001 /* 0002 SPDX-FileCopyrightText: 2010-2018 Dominik Haumann <dhaumann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KATE_SCRIPTHELPERS_H 0008 #define KATE_SCRIPTHELPERS_H 0009 0010 #include <QJSValue> 0011 #include <QObject> 0012 #include <ktexteditor_export.h> 0013 0014 class QJSEngine; 0015 0016 namespace Kate 0017 { 0018 /** Top-level script functions */ 0019 namespace Script 0020 { 0021 /** read complete file contents, helper */ 0022 KTEXTEDITOR_EXPORT bool readFile(const QString &sourceUrl, QString &sourceCode); 0023 0024 } // namespace Script 0025 0026 class KTEXTEDITOR_EXPORT ScriptHelper : public QObject 0027 { 0028 Q_OBJECT 0029 QJSEngine *m_engine; 0030 0031 public: 0032 explicit ScriptHelper(QJSEngine *engine) 0033 : m_engine(engine) 0034 { 0035 } 0036 Q_INVOKABLE QString read(const QString &file); 0037 Q_INVOKABLE void require(const QString &file); 0038 Q_INVOKABLE void debug(const QString &msg); 0039 Q_INVOKABLE QString _i18n(const QString &msg); 0040 Q_INVOKABLE QString _i18nc(const QString &textContext, const QString &text); 0041 Q_INVOKABLE QString _i18np(const QString &trSingular, const QString &trPlural, int number); 0042 Q_INVOKABLE QString _i18ncp(const QString &trContext, const QString &trSingular, const QString &trPlural, int number = 0); 0043 }; 0044 0045 } // namespace Kate 0046 0047 #endif