KTextEditor

katecommandlinescript.h
1/*
2 SPDX-FileCopyrightText: 2009-2018 Dominik Haumann <dhaumann@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KATE_COMMANDLINE_SCRIPT_H
8#define KATE_COMMANDLINE_SCRIPT_H
9
10#include "katescript.h"
11
12#include <KTextEditor/Command>
13
14#include <QJsonArray>
15
16namespace KTextEditor
17{
18class View;
19}
20
21class KateCommandLineScriptHeader
22{
23public:
24 KateCommandLineScriptHeader()
25 {
26 }
27
28 inline void setFunctions(const QStringList &functions)
29 {
30 m_functions = functions;
31 }
32 inline const QStringList &functions() const
33 {
34 return m_functions;
35 }
36
37 inline void setActions(const QJsonArray &actions)
38 {
39 m_actions = actions;
40 }
41 inline const QJsonArray &actions() const
42 {
43 return m_actions;
44 }
45
46private:
47 QStringList m_functions; ///< the functions the script contains
48 QJsonArray m_actions; ///< the action for this script
49};
50
51/**
52 * A specialized class for scripts that are of type ScriptType::Indentation.
53 */
55{
56public:
57 KateCommandLineScript(const QString &url, const KateCommandLineScriptHeader &header);
58
59 const KateCommandLineScriptHeader &commandHeader();
60
61 bool callFunction(const QString &cmd, const QStringList &args, QString &errorMessage);
62
63 //
64 // KTextEditor::Command interface
65 //
66public:
67 bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override;
68 bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) override;
69 bool supportsRange(const QString &cmd) override;
70
71private:
72 KateCommandLineScriptHeader m_commandHeader;
73};
74
75#endif
An Editor command line command.
An object representing a section of text, from one Cursor to another.
static constexpr Range invalid() noexcept
Returns an invalid range.
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
A specialized class for scripts that are of type ScriptType::Indentation.
bool supportsRange(const QString &cmd) override
Find out if a given command can act on a range.
bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override
Shows help for the given view and cmd string.
bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range=KTextEditor::Range::invalid()) override
Execute the command for the given view and cmd string.
KateScript objects represent a script that can be executed and inspected.
Definition katescript.h:107
const QString & url()
The script's URL.
Definition katescript.h:122
const QString & errorMessage()
Return a context-specific error message.
Definition katescript.h:155
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:15:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.