1 | /* |
---|---|
2 | SPDX-FileCopyrightText: 2014 Christoph Rüßler <christoph.ruessler@mailbox.org> |
3 | |
4 | SPDX-License-Identifier: LGPL-2.0-or-later |
5 | */ |
6 | |
7 | #include "katehighlightingcmds.h" |
8 | |
9 | #include <ktexteditor/application.h> |
10 | #include <ktexteditor/editor.h> |
11 | #include <ktexteditor/view.h> |
12 | |
13 | #include "katedocument.h" |
14 | #include "katehighlight.h" |
15 | #include "katesyntaxmanager.h" |
16 | |
17 | #include <QUrl> |
18 | |
19 | KateCommands::Highlighting *KateCommands::Highlighting::m_instance = nullptr; |
20 | |
21 | bool KateCommands::Highlighting::exec(KTextEditor::View *view, const QString &cmd, QString &, const KTextEditor::Range &) |
22 | { |
23 | if (cmd.startsWith(s: QLatin1String("reload-highlighting"))) { |
24 | KateHlManager::self()->reload(); |
25 | return true; |
26 | } else if (cmd.startsWith(s: QLatin1String("edit-highlighting"))) { |
27 | KTextEditor::DocumentPrivate *document = static_cast<KTextEditor::DocumentPrivate *>(view->document()); |
28 | KateHighlighting *highlighting = document->highlight(); |
29 | |
30 | if (!highlighting->noHighlighting()) { |
31 | QUrl url = QUrl::fromLocalFile(localfile: highlighting->getIdentifier()); |
32 | KTextEditor::Application *app = KTextEditor::Editor::instance()->application(); |
33 | app->openUrl(url); |
34 | } |
35 | |
36 | return true; |
37 | } |
38 | |
39 | return true; |
40 | } |
41 | |
42 | bool KateCommands::Highlighting::help(KTextEditor::View *, const QString &, QString &) |
43 | { |
44 | return false; |
45 | } |
46 |