Changeset View
Changeset View
Standalone View
Standalone View
addons/externaltools/kateexternaltoolscommand.cpp
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | * | ||||
3 | * Copyright 2019 Dominik Haumann <dhaumann@kde.org> | ||||
4 | * | ||||
5 | * This library is free software; you can redistribute it and/or | ||||
6 | * modify it under the terms of the GNU Library General Public | ||||
7 | * License as published by the Free Software Foundation; either | ||||
8 | * version 2 of the License, or (at your option) any later version. | ||||
9 | * | ||||
10 | * This library is distributed in the hope that it will be useful, | ||||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | * Library General Public License for more details. | ||||
14 | * | ||||
15 | * You should have received a copy of the GNU Library General Public License | ||||
16 | * along with this library; see the file COPYING.LIB. If not, write to | ||||
17 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||||
18 | * Boston, MA 02110-1301, USA. | ||||
19 | */ | ||||
20 | #include "kateexternaltoolscommand.h" | ||||
21 | #include "externaltoolsplugin.h" | ||||
22 | | ||||
23 | KateExternalToolsCommand::KateExternalToolsCommand(KateExternalToolsPlugin* plugin) | ||||
24 | : KTextEditor::Command(plugin->commands()) | ||||
25 | , m_plugin(plugin) | ||||
26 | { | ||||
27 | } | ||||
28 | | ||||
29 | bool KateExternalToolsCommand::exec(KTextEditor::View* view, const QString& cmd, QString& msg, | ||||
30 | const KTextEditor::Range& range) | ||||
31 | { | ||||
32 | Q_UNUSED(msg) | ||||
33 | Q_UNUSED(range) | ||||
34 | | ||||
35 | const QString command = cmd.trimmed(); | ||||
36 | const auto tool = m_plugin->toolForCommand(command); | ||||
37 | if (tool) { | ||||
38 | m_plugin->runTool(*tool, view); | ||||
39 | return true; | ||||
40 | } | ||||
41 | return false; | ||||
42 | } | ||||
43 | | ||||
44 | bool KateExternalToolsCommand::help(KTextEditor::View*, const QString&, QString&) | ||||
45 | { | ||||
46 | return false; | ||||
47 | } | ||||
48 | | ||||
49 | // kate: space-indent on; indent-width 4; replace-tabs on; |