KTextEditor

cmds.h
1 /*
2  SPDX-FileCopyrightText: 2003-2005 Anders Lund <[email protected]>
3  SPDX-FileCopyrightText: 2001-2010 Christoph Cullmann <[email protected]>
4  SPDX-FileCopyrightText: 2001 Charles Samuels <[email protected]>
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 "kateregexpsearch.h"
13 #include "mappings.h"
14 #include <KTextEditor/Command>
15 #include <katesedcmd.h>
16 #include <vimode/commandinterface.h>
17 
18 #include <QStringList>
19 
20 namespace KTextEditor
21 {
22 class DocumentPrivate;
23 }
24 class KCompletion;
25 
26 namespace KateVi
27 {
31 class Commands : public KTextEditor::Command, public KateViCommandInterface
32 {
33  Commands()
34  : KTextEditor::Command(QStringList() << mappingCommands() << QStringLiteral("d") << QStringLiteral("delete") << QStringLiteral("j")
35  << QStringLiteral("c") << QStringLiteral("change") << QStringLiteral("<") << QStringLiteral(">")
36  << QStringLiteral("y") << QStringLiteral("yank") << QStringLiteral("ma") << QStringLiteral("mark")
37  << QStringLiteral("k"))
38  {
39  }
40  static Commands *m_instance;
41 
42 public:
43  ~Commands() override
44  {
45  m_instance = nullptr;
46  }
47 
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 
61  bool help(class KTextEditor::View *, const QString &, QString &) override
62  {
63  return false;
64  }
65 
69  KCompletion *completionObject(KTextEditor::View *, const QString &) override;
70 
71  static Commands *self()
72  {
73  if (m_instance == nullptr) {
74  m_instance = new Commands();
75  }
76  return m_instance;
77  }
78 
79 private:
80  const QStringList &mappingCommands();
81  Mappings::MappingMode modeForMapCommand(const QString &mapCommand);
82  bool isMapCommandRecursive(const QString &mapCommand);
83 };
84 
89 class SedReplace : public KateCommands::SedReplace, public KateViCommandInterface
90 {
91  SedReplace()
92  {
93  }
94  static SedReplace *m_instance;
95 
96 public:
97  ~SedReplace() override
98  {
99  m_instance = nullptr;
100  }
101 
102  static SedReplace *self()
103  {
104  if (m_instance == nullptr) {
105  m_instance = new SedReplace();
106  }
107  return m_instance;
108  }
109 
110 protected:
111  bool interactiveSedReplace(KTextEditor::ViewPrivate *kateView, QSharedPointer<InteractiveSedReplacer> interactiveSedReplace) override;
112 };
113 
114 }
115 
116 #endif /* KATEVI_CMDS_H */
bool help(class KTextEditor::View *, const QString &, QString &) override
This command does not have help.
Definition: cmds.h:61
Support vim/sed style search and replace.
Definition: katesedcmd.h:34
This KTextEditor::Command provides vi &#39;ex&#39; commands.
Definition: cmds.h:31
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
Definition: katetextblock.h:21
An object representing a section of text, from one Cursor to another.
An Editor command line command.
Support vim/sed style search and replace.
Definition: cmds.h:89
A text widget with KXMLGUIClient that represents a Document.
Definition: view.h:146
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 03:31:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.