aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <[email protected]>2015-07-27 13:41:07 +0200
committerChristoph Cullmann <[email protected]>2015-07-27 13:41:07 +0200
commit2d8e2b45567da473f784d979a5eefc76a952c433 (patch)
tree377097cadbf32dfcf249b4ba9485caafafd005e5
parent07f60d0afa789e23421da7b8c44908dd01dd6df0 (diff)
textfilter command works again, too
-rw-r--r--addons/textfilter/plugin_katetextfilter.cpp23
-rw-r--r--addons/textfilter/plugin_katetextfilter.h21
2 files changed, 33 insertions, 11 deletions
diff --git a/addons/textfilter/plugin_katetextfilter.cpp b/addons/textfilter/plugin_katetextfilter.cpp
index eb1d521..bfeae4e 100644
--- a/addons/textfilter/plugin_katetextfilter.cpp
+++ b/addons/textfilter/plugin_katetextfilter.cpp
@@ -48,6 +48,8 @@ PluginKateTextFilter::PluginKateTextFilter(QObject *parent, const QList<QVariant
, copyResult(false)
, mergeOutput(false)
{
+ // register command
+ new PluginKateTextFilterCommand(this);
}
PluginKateTextFilter::~PluginKateTextFilter()
@@ -218,14 +220,15 @@ void PluginKateTextFilter::runFilter(KTextEditor::View *kv, const QString &filte
}
//BEGIN Kate::Command methods
-bool PluginKateTextFilter::help(KTextEditor::View *, const QString&, QString &msg)
+
+PluginKateTextFilterCommand::PluginKateTextFilterCommand(PluginKateTextFilter *plugin)
+ : KTextEditor::Command(QStringList() << QStringLiteral("textfilter"), plugin)
+ , m_plugin(plugin)
{
- msg = i18n("<qt><p>Usage: <code>textfilter COMMAND</code></p>"
- "<p>Replace the selection with the output of the specified shell command.</p></qt>");
- return true;
}
-bool PluginKateTextFilter::exec(KTextEditor::View *v, const QString &cmd, QString &msg)
+bool PluginKateTextFilterCommand::exec (KTextEditor::View *view, const QString &cmd, QString &msg,
+ const KTextEditor::Range &)
{
QString filter = cmd.section(QLatin1Char(' '), 1).trimmed();
@@ -234,9 +237,17 @@ bool PluginKateTextFilter::exec(KTextEditor::View *v, const QString &cmd, QStrin
return false;
}
- runFilter(v, filter);
+ m_plugin->runFilter(view, filter);
return true;
}
+
+bool PluginKateTextFilterCommand::help (KTextEditor::View *, const QString &, QString &msg)
+{
+ msg = i18n("<qt><p>Usage: <code>textfilter COMMAND</code></p>"
+ "<p>Replace the selection with the output of the specified shell command.</p></qt>");
+ return true;
+
+}
//END
diff --git a/addons/textfilter/plugin_katetextfilter.h b/addons/textfilter/plugin_katetextfilter.h
index 48b5a1e..cd01865 100644
--- a/addons/textfilter/plugin_katetextfilter.h
+++ b/addons/textfilter/plugin_katetextfilter.h
@@ -28,7 +28,7 @@
#include <KProcess>
#include <QVariantList>
-class PluginKateTextFilter : public KTextEditor::Plugin//, public KTextEditor::Command
+class PluginKateTextFilter : public KTextEditor::Plugin
{
Q_OBJECT
@@ -42,10 +42,6 @@ class PluginKateTextFilter : public KTextEditor::Plugin//, public KTextEditor::C
QObject *createView(KTextEditor::MainWindow *mainWindow);
- // Kate::Command
- bool exec(KTextEditor::View *view, const QString &cmd, QString &msg);
- bool help(KTextEditor::View *view, const QString &cmd, QString &msg);
- private:
void runFilter(KTextEditor::View *kv, const QString & filter);
private:
@@ -63,6 +59,21 @@ class PluginKateTextFilter : public KTextEditor::Plugin//, public KTextEditor::C
void slotFilterProcessExited(int exitCode, QProcess::ExitStatus exitStatus);
};
+class PluginKateTextFilterCommand : public KTextEditor::Command
+{
+ Q_OBJECT
+
+public:
+ PluginKateTextFilterCommand (PluginKateTextFilter *plugin);
+ // Kate::Command
+ bool exec (KTextEditor::View *view, const QString &cmd, QString &msg,
+ const KTextEditor::Range &range = KTextEditor::Range::invalid());
+ bool help (KTextEditor::View *view, const QString &cmd, QString &msg);
+
+private:
+ PluginKateTextFilter *m_plugin;
+};
+
/**
* Plugin view to merge the actions into the UI
*/