Kate
katecmds.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries and the Kate part. 00002 * 00003 * Copyright (C) 2003-2005 Anders Lund <anders@alweb.dk> 00004 * Copyright (C) 2001-2010 Christoph Cullmann <cullmann@kde.org> 00005 * Copyright (C) 2001 Charles Samuels <charles@kde.org> 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public License 00018 * along with this library; see the file COPYING.LIB. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #ifndef __KATE_CMDS_H__ 00024 #define __KATE_CMDS_H__ 00025 00026 #include <ktexteditor/commandinterface.h> 00027 00028 #include <QtCore/QStringList> 00029 00030 class KateDocument; 00031 class KCompletion; 00032 00037 namespace KateCommands 00038 { 00039 00046 class CoreCommands : public KTextEditor::Command, public KTextEditor::CommandExtension, 00047 public KTextEditor::RangeCommand 00048 { 00049 public: 00057 bool exec( class KTextEditor::View *view, const QString &cmd, QString &errorMsg ); 00058 00068 bool exec( class KTextEditor::View *view, const QString &cmd, QString &errorMsg, 00069 const KTextEditor::Range &range = KTextEditor::Range(-1, -0, -1, 0)); 00070 00071 bool supportsRange(const QString &range); 00072 00074 bool help( class KTextEditor::View *, const QString &, QString & ) {return false;} 00075 00080 const QStringList &cmds(); 00081 00085 KCompletion *completionObject( KTextEditor::View *, const QString & ); 00086 00087 virtual void flagCompletions( QStringList& ) {} 00088 virtual bool wantsToProcessText( const QString & ) { return false; } 00089 virtual void processText( KTextEditor::View *, const QString & ) {} 00090 }; 00091 00095 class ViCommands : public KTextEditor::Command, public KTextEditor::CommandExtension, 00096 public KTextEditor::RangeCommand 00097 { 00098 public: 00106 bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg ); 00107 00117 bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg, 00118 const KTextEditor::Range &range = KTextEditor::Range(-1, -0, -1, 0)); 00119 00120 bool supportsRange(const QString &range); 00121 00123 bool help( class KTextEditor::View *, const QString &, QString & ) {return false;} 00124 00129 const QStringList &cmds(); 00130 00134 KCompletion *completionObject( KTextEditor::View *, const QString & ); 00135 00136 virtual void flagCompletions( QStringList& ) {} 00137 virtual bool wantsToProcessText( const QString & ) { return false; } 00138 virtual void processText( KTextEditor::View *, const QString & ) {} 00139 }; 00140 00141 00145 class AppCommands : public KTextEditor::Command 00146 { 00147 public: 00148 AppCommands(); 00149 virtual ~AppCommands() {} 00157 bool exec( class KTextEditor::View *view, const QString &cmd, QString &msg ); 00158 00160 bool help( class KTextEditor::View *, const QString &, QString & ); 00161 00166 const QStringList &cmds(); 00167 00168 private: 00169 QRegExp re_write; 00170 /*QRegExp re_quit; 00171 QRegExp re_exit; 00172 QRegExp re_changeBuffer; 00173 QRegExp re_edit; 00174 QRegExp re_new;*/ 00175 }; 00180 class SedReplace : public KTextEditor::Command, public KTextEditor::RangeCommand 00181 { 00182 public: 00198 bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg); 00199 00200 bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg, 00201 const KTextEditor::Range &r); 00202 00203 bool supportsRange(const QString &) { return true; } 00204 00206 bool help (class KTextEditor::View *, const QString &, QString &) { return false; } 00207 00212 const QStringList &cmds () { static QStringList l("s"); if (l.isEmpty()) l << "%s" << "$s"; return l; } 00213 00214 private: 00234 static int sedMagic(KateDocument *doc, int &line, 00235 const QString &find, const QString &replace, const QString &delim, 00236 bool noCase, bool repeat, 00237 int startcol=0, int endcol=-1); 00238 }; 00239 00248 class Character : public KTextEditor::Command 00249 { 00250 public: 00258 bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg); 00259 00261 bool help (class KTextEditor::View *, const QString &, QString &) { return false; } 00262 00267 const QStringList &cmds () { static QStringList test("char"); return test; } 00268 }; 00269 00273 class Date : public KTextEditor::Command 00274 { 00275 public: 00283 bool exec (class KTextEditor::View *view, const QString &cmd, QString &errorMsg); 00284 00286 bool help (class KTextEditor::View *, const QString &, QString &) { return false; } 00287 00292 const QStringList &cmds () { static QStringList test("date"); return test; } 00293 }; 00294 00295 00296 } // namespace KateCommands 00297 #endif 00298 00299 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference