KTextEditor
commandinterface.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 Copyright (C) 2005 Christoph Cullmann (cullmann@kde.org) 00003 Copyright (C) 2005-2006 Dominik Haumann (dhdev@gmx.de) 00004 Copyright (C) 2008 Erlend Hamberg (ehamberg@gmail.com) 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 #ifndef KDELIBS_KTEXTEDITOR_COMMANDINTERFACE_H 00023 #define KDELIBS_KTEXTEDITOR_COMMANDINTERFACE_H 00024 00025 #include <ktexteditor/ktexteditor_export.h> 00026 #include <ktexteditor/range.h> 00027 #include <QtCore/QObject> 00028 00029 class QStringList; 00030 class KCompletion; 00031 00032 namespace KTextEditor 00033 { 00034 00035 class Editor; 00036 class View; 00037 00076 class KTEXTEDITOR_EXPORT Command 00077 { 00078 public: 00082 virtual ~Command () {} 00083 00084 public: 00092 virtual const QStringList &cmds () = 0; 00093 00104 virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg) = 0; 00105 00113 virtual bool help (KTextEditor::View *view, const QString &cmd, QString &msg) = 0; 00114 }; 00115 00138 class KTEXTEDITOR_EXPORT CommandExtension 00139 { 00140 public: 00144 virtual ~CommandExtension() {} 00145 //### this is yet to be tried 00157 virtual void flagCompletions( QStringList&list ) = 0; 00158 00171 virtual KCompletion *completionObject( KTextEditor::View *view, 00172 const QString & cmdname ) = 0; 00173 00188 virtual bool wantsToProcessText( const QString &cmdname ) = 0; 00189 // ### yet to be tested. The obvious candidate is isearch. 00197 virtual void processText( KTextEditor::View *view, const QString &text ) = 0; 00198 }; 00199 00233 class KTEXTEDITOR_EXPORT CommandInterface 00234 { 00235 public: 00239 virtual ~CommandInterface () {} 00240 00241 public: 00250 virtual bool registerCommand (Command *cmd) = 0; 00251 00260 virtual bool unregisterCommand (Command *cmd) = 0; 00261 00269 virtual Command *queryCommand (const QString &cmd) const = 0; 00270 00276 virtual QList<Command*> commands() const = 0; 00277 00283 virtual QStringList commandList() const = 0; 00284 }; 00285 00306 class KTEXTEDITOR_EXPORT RangeCommand 00307 { 00308 public: 00312 virtual ~RangeCommand() {} 00313 00320 virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg, 00321 const KTextEditor::Range &range) = 0; 00322 00331 virtual bool supportsRange (const QString &cmd) = 0; 00332 }; 00333 00334 } 00335 00336 Q_DECLARE_INTERFACE(KTextEditor::CommandInterface, "org.kde.KTextEditor.CommandInterface") 00337 00338 #endif 00339 00340 // kate: space-indent on; indent-width 2; replace-tabs on;
KDE 4.6 API Reference