KTextEditor

katehighlightingcmds.cpp
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
19KateCommands::Highlighting *KateCommands::Highlighting::m_instance = nullptr;
20
21bool KateCommands::Highlighting::exec(KTextEditor::View *view, const QString &cmd, QString &, const KTextEditor::Range &)
22{
23 if (cmd.startsWith(QLatin1String("reload-highlighting"))) {
24 KateHlManager::self()->reload();
25 return true;
26 } else if (cmd.startsWith(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(highlighting->getIdentifier());
33 app->openUrl(url);
34 }
35
36 return true;
37 }
38
39 return true;
40}
41
42bool KateCommands::Highlighting::help(KTextEditor::View *, const QString &, QString &)
43{
44 return false;
45}
This class allows the application that embeds the KTextEditor component to allow it access to applica...
Definition application.h:44
KTextEditor::Document * openUrl(const QUrl &url, const QString &encoding=QString())
Open the document url with the given encoding.
Backend of KTextEditor::Document related public KTextEditor interfaces.
static Editor * instance()
Accessor to get the Editor instance.
virtual KTextEditor::Application * application() const =0
Current hosting application, if any set.
An object representing a section of text, from one Cursor to another.
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
virtual Document * document() const =0
Get the view's document, that means the view is a view of the returned document.
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QUrl fromLocalFile(const QString &localFile)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.