KTextEditor

cmds.h
1/*
2 SPDX-FileCopyrightText: 2003-2005 Anders Lund <anders@alweb.dk>
3 SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <cullmann@kde.org>
4 SPDX-FileCopyrightText: 2001 Charles Samuels <charles@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KATEVI_CMDS_H
10#define KATEVI_CMDS_H
11
12#include "mappings.h"
13#include <KTextEditor/Command>
14#include <katesedcmd.h>
15
16#include <QStringList>
17
18namespace KTextEditor
19{
20class DocumentPrivate;
21}
22class KCompletion;
23
24namespace KateVi
25{
26class InputModeManager;
27/**
28 * This KTextEditor::Command provides vi 'ex' commands
29 */
31{
32 Commands()
33 : KTextEditor::Command(QStringList() << mappingCommands() << QStringLiteral("d") << QStringLiteral("delete") << QStringLiteral("j")
34 << QStringLiteral("c") << QStringLiteral("change") << QStringLiteral("<") << QStringLiteral(">")
35 << QStringLiteral("y") << QStringLiteral("yank") << QStringLiteral("ma") << QStringLiteral("mark")
36 << QStringLiteral("k"))
37 {
38 }
39 static Commands *m_instance;
40 InputModeManager *m_viInputModeManager;
41
42public:
43 ~Commands() override
44 {
45 m_instance = nullptr;
46 }
47
48 /**
49 * execute command on given range
50 * @param view view to use for execution
51 * @param cmd cmd string
52 * @param msg message returned from running the command
53 * @param range range to execute command on
54 * @return success
55 */
56 bool exec(class KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range = KTextEditor::Range(-1, -0, -1, 0)) override;
57
58 bool supportsRange(const QString &range) override;
59
60 /** This command does not have help. @see KTextEditor::Command::help */
61 bool help(class KTextEditor::View *, const QString &, QString &) override
62 {
63 return false;
64 }
65
66 /**
67 * Reimplement from KTextEditor::Command
68 */
70
71 static Commands *self()
72 {
73 if (m_instance == nullptr) {
74 m_instance = new Commands();
75 }
76 return m_instance;
77 }
78
79 void setViInputModeManager(InputModeManager *m)
80 {
81 m_viInputModeManager = m;
82 }
83
84private:
85 static const QStringList &mappingCommands();
86 static Mappings::MappingMode modeForMapCommand(const QString &mapCommand);
87 static bool isMapCommandRecursive(const QString &mapCommand);
88};
89
90/**
91 * Support vim/sed style search and replace
92 * @author Charles Samuels <charles@kde.org>
93 **/
95{
97 {
98 }
99 static SedReplace *m_instance;
100 InputModeManager *m_viInputModeManager;
101
102public:
103 ~SedReplace() override
104 {
105 m_instance = nullptr;
106 }
107
108 static SedReplace *self()
109 {
110 if (m_instance == nullptr) {
111 m_instance = new SedReplace();
112 }
113 return m_instance;
114 }
115
116 void setViInputModeManager(InputModeManager *m)
117 {
118 m_viInputModeManager = m;
119 }
120
121protected:
122 bool interactiveSedReplace(KTextEditor::ViewPrivate *kateView, std::shared_ptr<InteractiveSedReplacer> interactiveSedReplace) override;
123};
124
125}
126
127#endif /* KATEVI_CMDS_H */
An Editor command line command.
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
Support vim/sed style search and replace.
Definition katesedcmd.h:34
This KTextEditor::Command provides vi 'ex' commands.
Definition cmds.h:31
KCompletion * completionObject(KTextEditor::View *, const QString &) override
Reimplement from KTextEditor::Command.
Definition cmds.cpp:184
bool help(class KTextEditor::View *, const QString &, QString &) override
This command does not have help.
Definition cmds.h:61
bool exec(class KTextEditor::View *view, const QString &cmd, QString &msg, const KTextEditor::Range &range=KTextEditor::Range(-1, -0, -1, 0)) override
execute command on given range
Definition cmds.cpp:30
bool supportsRange(const QString &range) override
Find out if a given command can act on a range.
Definition cmds.cpp:172
Support vim/sed style search and replace.
Definition cmds.h:95
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 Fri Dec 20 2024 11:56:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.