KTextEditor

appcommands.h
1/*
2 SPDX-FileCopyrightText: 2009 Erlend Hamberg <ehamberg@gmail.com>
3 SPDX-FileCopyrightText: 2011 Svyatoslav Kuzmich <svatoslav1@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#ifndef KATEVI_APP_COMMANDS_H
9#define KATEVI_APP_COMMANDS_H
10
11#include <KTextEditor/Command>
12#include <QObject>
13#include <QRegularExpression>
14
15namespace KTextEditor
16{
17class MainWindow;
18}
19
20namespace KateVi
21{
22class AppCommands : public KTextEditor::Command
23{
24 AppCommands();
25 static AppCommands *m_instance;
26
27public:
28 ~AppCommands() override;
29 bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) override;
30 bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override;
31
32 static AppCommands *self()
33 {
34 if (m_instance == nullptr) {
35 m_instance = new AppCommands();
36 }
37 return m_instance;
38 }
39
40private:
41 /**
42 * @returns a view in the given \p window that does not share a split
43 * view with the given \p view. If such view could not be found, then
44 * nullptr is returned.
45 */
46 static KTextEditor::View *findViewInDifferentSplitView(KTextEditor::MainWindow *window, KTextEditor::View *view);
47
48private:
49 void closeCurrentDocument();
50 void closeDocuments(const QList<KTextEditor::Document *> &documents);
51 void closeCurrentView();
52 void closeCurrentSplitView();
53 void closeOtherSplitViews();
54 void quit();
55
56private:
57 const QRegularExpression re_write;
58 const QRegularExpression re_close;
59 const QRegularExpression re_quit;
60 const QRegularExpression re_exit;
61 const QRegularExpression re_edit;
62 const QRegularExpression re_tabedit;
63 const QRegularExpression re_new;
64 const QRegularExpression re_split;
65 const QRegularExpression re_vsplit;
66 const QRegularExpression re_vclose;
67 const QRegularExpression re_only;
68};
69
70class BufferCommands : public KTextEditor::Command
71{
72 BufferCommands();
73 static BufferCommands *m_instance;
74
75public:
76 ~BufferCommands() override;
77 bool exec(KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range::invalid()) override;
78 bool help(KTextEditor::View *view, const QString &cmd, QString &msg) override;
79
80 static BufferCommands *self()
81 {
82 if (m_instance == nullptr) {
83 m_instance = new BufferCommands();
84 }
85 return m_instance;
86 }
87
88private:
89 void switchDocument(KTextEditor::View *, const QString &doc);
90 void prevBuffer(KTextEditor::View *);
91 void nextBuffer(KTextEditor::View *);
92 void firstBuffer(KTextEditor::View *);
93 void lastBuffer(KTextEditor::View *);
94 void prevTab(KTextEditor::View *);
95 void nextTab(KTextEditor::View *);
96 void firstTab(KTextEditor::View *);
97 void lastTab(KTextEditor::View *);
98
99 static void activateDocument(KTextEditor::View *, KTextEditor::Document *);
100 static QList<KTextEditor::Document *> documents();
101};
102}
103
104#endif /* KATEVI_APP_COMMANDS_H */
An Editor command line command.
A KParts derived class representing a text document.
Definition document.h:284
This class allows the application that embeds the KTextEditor component to allow it to access parts o...
Definition mainwindow.h:47
An object representing a section of text, from one Cursor to another.
static constexpr Range invalid() noexcept
Returns an invalid range.
A text widget with KXMLGUIClient that represents a Document.
Definition view.h:244
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Feb 24 2024 20:00:58 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.