File indexing completed on 2024-04-21 03:57:43

0001 /*
0002     SPDX-FileCopyrightText: 2014 Christoph Rüßler <christoph.ruessler@mailbox.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "katehighlightingcmds.h"
0008 
0009 #include <ktexteditor/application.h>
0010 #include <ktexteditor/editor.h>
0011 #include <ktexteditor/view.h>
0012 
0013 #include "katedocument.h"
0014 #include "katehighlight.h"
0015 #include "katesyntaxmanager.h"
0016 
0017 #include <QUrl>
0018 
0019 KateCommands::Highlighting *KateCommands::Highlighting::m_instance = nullptr;
0020 
0021 bool KateCommands::Highlighting::exec(KTextEditor::View *view, const QString &cmd, QString &, const KTextEditor::Range &)
0022 {
0023     if (cmd.startsWith(QLatin1String("reload-highlighting"))) {
0024         KateHlManager::self()->reload();
0025         return true;
0026     } else if (cmd.startsWith(QLatin1String("edit-highlighting"))) {
0027         KTextEditor::DocumentPrivate *document = static_cast<KTextEditor::DocumentPrivate *>(view->document());
0028         KateHighlighting *highlighting = document->highlight();
0029 
0030         if (!highlighting->noHighlighting()) {
0031             QUrl url = QUrl::fromLocalFile(highlighting->getIdentifier());
0032             KTextEditor::Application *app = KTextEditor::Editor::instance()->application();
0033             app->openUrl(url);
0034         }
0035 
0036         return true;
0037     }
0038 
0039     return true;
0040 }
0041 
0042 bool KateCommands::Highlighting::help(KTextEditor::View *, const QString &, QString &)
0043 {
0044     return false;
0045 }