• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

Kate

  • kde-4.14
  • applications
  • kate
  • part
  • utils
katecmds.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries and the Kate part.
2  *
3  * Copyright (C) 2003-2005 Anders Lund <anders@alweb.dk>
4  * Copyright (C) 2001-2010 Christoph Cullmann <cullmann@kde.org>
5  * Copyright (C) 2001 Charles Samuels <charles@kde.org>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public License
18  * along with this library; see the file COPYING.LIB. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __KATE_CMDS_H__
24 #define __KATE_CMDS_H__
25 
26 #include <ktexteditor/commandinterface.h>
27 #include "kateviinputmodemanager.h"
28 #include "kateviglobal.h"
29 #include "kateregexpsearch.h"
30 
31 #include <QtCore/QStringList>
32 
33 class KateDocument;
34 class KCompletion;
35 
40 namespace KateCommands
41 {
42 
49 class CoreCommands : public KTextEditor::Command, public KTextEditor::CommandExtension,
50  public KTextEditor::RangeCommand
51 {
52  CoreCommands() { }
53  static CoreCommands* m_instance;
54 
55  public:
56  ~CoreCommands() { m_instance = 0; }
57 
65  bool exec( class KTextEditor::View *view, const QString &cmd, QString &errorMsg );
66 
76  bool exec( class KTextEditor::View *view, const QString &cmd, QString &errorMsg,
77  const KTextEditor::Range &range = KTextEditor::Range(-1, -0, -1, 0) );
78 
79  bool supportsRange(const QString &range);
80 
82  bool help( class KTextEditor::View *, const QString &, QString & );
83 
88  const QStringList &cmds();
89 
93  KCompletion *completionObject( KTextEditor::View *, const QString & );
94 
95  virtual void flagCompletions( QStringList& ) {}
96  virtual bool wantsToProcessText( const QString & ) { return false; }
97  virtual void processText( KTextEditor::View *, const QString & ) {}
98 
99  static CoreCommands* self() {
100  if (m_instance == 0) {
101  m_instance = new CoreCommands();
102  }
103  return m_instance;
104  }
105 };
106 
110 class ViCommands : public KTextEditor::Command, public KTextEditor::CommandExtension,
111  public KTextEditor::RangeCommand
112 {
113  ViCommands() { }
114  static ViCommands* m_instance;
115 
116  public:
117  ~ViCommands() { m_instance = 0; }
118 
126  bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg );
127 
137  bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg,
138  const KTextEditor::Range &range = KTextEditor::Range(-1, -0, -1, 0));
139 
140  bool supportsRange(const QString &range);
141 
143  bool help( class KTextEditor::View *, const QString &, QString & ) {return false;}
144 
149  const QStringList &cmds();
150 
154  KCompletion *completionObject( KTextEditor::View *, const QString & );
155 
156  virtual void flagCompletions( QStringList& ) {}
157  virtual bool wantsToProcessText( const QString & ) { return false; }
158  virtual void processText( KTextEditor::View *, const QString & ) {}
159 
160  static ViCommands* self() {
161  if (m_instance == 0) {
162  m_instance = new ViCommands();
163  }
164  return m_instance;
165  }
166 private:
167  const QStringList& mappingCommands();
168  KateViGlobal::MappingMode modeForMapCommand(const QString& mapCommand);
169  bool isMapCommandRecursive(const QString& mapCommand);
170 };
171 
175 class AppCommands : public KTextEditor::Command
176 {
177  AppCommands();
178  static AppCommands* m_instance;
179 
180  public:
181  ~AppCommands() { m_instance = 0; }
182 
190  bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg );
191 
193  bool help( class KTextEditor::View *, const QString &, QString & );
194 
199  const QStringList &cmds();
200 
201  static AppCommands* self() {
202  if (m_instance == 0) {
203  m_instance = new AppCommands();
204  }
205  return m_instance;
206  }
207 
208  private:
209  QRegExp re_write;
210  /*QRegExp re_quit;
211  QRegExp re_exit;
212  QRegExp re_changeBuffer;
213  QRegExp re_edit;
214  QRegExp re_new;*/
215 };
220 class SedReplace : public KTextEditor::Command, public KTextEditor::RangeCommand
221 {
222  SedReplace() { }
223  static SedReplace* m_instance;
224 
225  public:
226  ~SedReplace() { m_instance = 0; }
227 
243  bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg);
244 
245  bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg,
246  const KTextEditor::Range &r);
247 
248  bool supportsRange(const QString &) { return true; }
249 
251  bool help (class KTextEditor::View *, const QString &, QString &) { return false; }
252 
257  const QStringList &cmds () { static QStringList l("s"); if (l.isEmpty()) l << "%s" << "$s"; return l; }
258 
259  static SedReplace* self() {
260  if (m_instance == 0) {
261  m_instance = new SedReplace();
262  }
263  return m_instance;
264  }
265 
273  static bool parse(const QString& sedReplaceString, QString& destDelim, int& destFindBeginPos, int& destFindEndPos, int& destReplaceBeginPos, int& destReplaceEndPos);
274 
275  class InteractiveSedReplacer
276  {
277  public:
278  InteractiveSedReplacer(KateDocument* doc, const QString& findPattern, const QString& replacePattern, bool caseSensitive, bool onlyOnePerLine, int startLine, int endLine);
282  KTextEditor::Range currentMatch();
283  void skipCurrentMatch();
284  void replaceCurrentMatch();
285  void replaceAllRemaining();
286  QString currentMatchReplacementConfirmationMessage();
287  QString finalStatusReportMessage();
288  private:
289  const QString m_findPattern;
290  const QString m_replacePattern;
291  bool m_onlyOnePerLine;
292  int m_startLine;
293  int m_endLine;
294  KateDocument *m_doc;
295  KateRegExpSearch m_regExpSearch;
296 
297  int m_numReplacementsDone;
298  int m_numLinesTouched;
299  int m_lastChangedLineNum;
300 
301  KTextEditor::Cursor m_currentSearchPos;
302  const QVector<KTextEditor::Range> fullCurrentMatch();
303  QString replacementTextForCurrentMatch();
304  };
305 
306  private:
307 };
308 
317 class Character : public KTextEditor::Command
318 {
319  Character() { }
320  static Character* m_instance;
321 
322  public:
323  ~Character() { m_instance = 0; }
324 
332  bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg);
333 
335  bool help (class KTextEditor::View *, const QString &, QString &);
336 
341  const QStringList &cmds () { static QStringList test("char"); return test; }
342 
343  static Character* self() {
344  if (m_instance == 0) {
345  m_instance = new Character();
346  }
347  return m_instance;
348  }
349 };
350 
354 class Date : public KTextEditor::Command
355 {
356  Date() { }
357  static Date* m_instance;
358 
359  public:
360  ~Date() { m_instance = 0; }
361 
369  bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg);
370 
372  bool help (class KTextEditor::View *, const QString &, QString &);
373 
378  const QStringList &cmds () { static QStringList test("date"); return test; }
379 
380  static Date* self() {
381  if (m_instance == 0) {
382  m_instance = new Date();
383  }
384  return m_instance;
385  }
386 };
387 
388 
389 } // namespace KateCommands
390 #endif
391 
392 // kate: space-indent on; indent-width 2; replace-tabs on;
KateCommands::AppCommands::~AppCommands
~AppCommands()
Definition: katecmds.h:181
KateCommands::CoreCommands
This KTextEditor::Command provides access to a lot of the core functionality of kate part...
Definition: katecmds.h:49
KateCommands::SedReplace::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &errorMsg)
Execute command.
Definition: katecmds.cpp:920
KateCommands::CoreCommands::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.cpp:71
KateCommands::Date
insert the current date/time in the given format
Definition: katecmds.h:354
KateCommands::CoreCommands::supportsRange
bool supportsRange(const QString &range)
Definition: katecmds.cpp:498
KateCommands::CoreCommands::processText
virtual void processText(KTextEditor::View *, const QString &)
Definition: katecmds.h:97
KateCommands::CoreCommands::completionObject
KCompletion * completionObject(KTextEditor::View *, const QString &)
override completionObject from interfaces/document.h .
Definition: katecmds.cpp:509
KateCommands::CoreCommands::wantsToProcessText
virtual bool wantsToProcessText(const QString &)
Definition: katecmds.h:96
KateCommands::SedReplace::InteractiveSedReplacer::InteractiveSedReplacer
InteractiveSedReplacer(KateDocument *doc, const QString &findPattern, const QString &replacePattern, bool caseSensitive, bool onlyOnePerLine, int startLine, int endLine)
Definition: katecmds.cpp:1024
KateCommands::Date::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.h:378
KateCommands::ViCommands::supportsRange
bool supportsRange(const QString &range)
Definition: katecmds.cpp:703
KateCommands::Date::~Date
~Date()
Definition: katecmds.h:360
KateCommands::ViCommands::help
bool help(class KTextEditor::View *, const QString &, QString &)
This command does not have help.
Definition: katecmds.h:143
KateCommands::ViCommands::completionObject
KCompletion * completionObject(KTextEditor::View *, const QString &)
override completionObject from interfaces/document.h .
Definition: katecmds.cpp:714
KateCommands::SedReplace::help
bool help(class KTextEditor::View *, const QString &, QString &)
This command does not have help.
Definition: katecmds.h:251
KateCommands::AppCommands
This KTextEditor::Command provides vi commands for the application.
Definition: katecmds.h:175
KateCommands::Character::help
bool help(class KTextEditor::View *, const QString &, QString &)
This command does not have help.
Definition: katecmds.cpp:1159
KateCommands::ViCommands::wantsToProcessText
virtual bool wantsToProcessText(const QString &)
Definition: katecmds.h:157
KateCommands::ViCommands::~ViCommands
~ViCommands()
Definition: katecmds.h:117
KateCommands::SedReplace
Support vim/sed style search and replace.
Definition: katecmds.h:220
KateRegExpSearch
Object to help to search for regexp.
Definition: kateregexpsearch.h:40
KateCommands::ViCommands::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.cpp:550
KateCommands::Date::help
bool help(class KTextEditor::View *, const QString &, QString &)
This command does not have help.
Definition: katecmds.cpp:1220
KateCommands::SedReplace::InteractiveSedReplacer::finalStatusReportMessage
QString finalStatusReportMessage()
Definition: katecmds.cpp:1119
KateCommands::AppCommands::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &msg)
execute command
Definition: katecmds.cpp:825
KateCommands::SedReplace::InteractiveSedReplacer::currentMatchReplacementConfirmationMessage
QString currentMatchReplacementConfirmationMessage()
Definition: katecmds.cpp:1114
kateregexpsearch.h
KateCommands::CoreCommands::~CoreCommands
~CoreCommands()
Definition: katecmds.h:56
KateCommands::Character
insert a unicode or ascii character base 9+1: 1234 hex: 0x1234 or x1234 octal: 01231 ...
Definition: katecmds.h:317
kateviinputmodemanager.h
QRegExp
KateCommands::SedReplace::InteractiveSedReplacer::replaceAllRemaining
void replaceAllRemaining()
Definition: katecmds.cpp:1104
KateCommands::SedReplace::supportsRange
bool supportsRange(const QString &)
Definition: katecmds.h:248
KateCommands::CoreCommands::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &errorMsg)
execute command
Definition: katecmds.cpp:221
KateCommands::ViCommands
This KTextEditor::Command provides vi 'ex' commands.
Definition: katecmds.h:110
QList::isEmpty
bool isEmpty() const
KateCommands::ViCommands::processText
virtual void processText(KTextEditor::View *, const QString &)
Definition: katecmds.h:158
KateCommands::CoreCommands::flagCompletions
virtual void flagCompletions(QStringList &)
Definition: katecmds.h:95
KateCommands::AppCommands::help
bool help(class KTextEditor::View *, const QString &, QString &)
Help for AppCommands.
Definition: katecmds.cpp:851
KateCommands::SedReplace::InteractiveSedReplacer
Definition: katecmds.h:275
QString
KateCommands::AppCommands::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.cpp:808
KateCommands::ViCommands::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &msg)
execute command
Definition: katecmds.cpp:561
KateCommands::Character::~Character
~Character()
Definition: katecmds.h:323
QStringList
KateCommands::SedReplace::InteractiveSedReplacer::replaceCurrentMatch
void replaceCurrentMatch()
Definition: katecmds.cpp:1064
KateCommands::SedReplace::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.h:257
KateDocument
Definition: katedocument.h:74
QVector< KTextEditor::Range >
KateCommands::SedReplace::~SedReplace
~SedReplace()
Definition: katecmds.h:226
KateCommands::Date::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &errorMsg)
execute command
Definition: katecmds.cpp:1252
KateCommands::CoreCommands::help
bool help(class KTextEditor::View *, const QString &, QString &)
This command does not have help.
Definition: katecmds.cpp:90
KateCommands::SedReplace::InteractiveSedReplacer::currentMatch
KTextEditor::Range currentMatch()
Will return invalid Range if there are no further matches.
Definition: katecmds.cpp:1039
KateCommands::Character::exec
bool exec(class KTextEditor::View *view, const QString &cmd, QString &errorMsg)
execute command
Definition: katecmds.cpp:1173
KateViGlobal::MappingMode
MappingMode
Definition: kateviglobal.h:61
kateviglobal.h
KateCommands::ViCommands::flagCompletions
virtual void flagCompletions(QStringList &)
Definition: katecmds.h:156
KateCommands::Character::cmds
const QStringList & cmds()
supported commands as prefixes
Definition: katecmds.h:341
KateCommands::SedReplace::InteractiveSedReplacer::skipCurrentMatch
void skipCurrentMatch()
Definition: katecmds.cpp:1054
KateCommands::SedReplace::parse
static bool parse(const QString &sedReplaceString, QString &destDelim, int &destFindBeginPos, int &destFindEndPos, int &destReplaceBeginPos, int &destReplaceEndPos)
Parses sedReplaceString to see if it is a valid sed replace expression (e.g.
Definition: katecmds.cpp:999
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:58 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal