/usr/include/ktexteditor/commandinterface.h is in kdelibs5-dev 4:4.8.4-4+deb7u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | /* This file is part of the KDE project
Copyright (C) 2005 Christoph Cullmann (cullmann@kde.org)
Copyright (C) 2005-2006 Dominik Haumann (dhdev@gmx.de)
Copyright (C) 2008 Erlend Hamberg (ehamberg@gmail.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KDELIBS_KTEXTEDITOR_COMMANDINTERFACE_H
#define KDELIBS_KTEXTEDITOR_COMMANDINTERFACE_H
#include <ktexteditor/ktexteditor_export.h>
#include <ktexteditor/range.h>
#include <QtCore/QObject>
class QStringList;
class KCompletion;
namespace KTextEditor
{
class Editor;
class View;
/**
* \brief An Editor command line command.
*
* \section cmd_intro Introduction
*
* The Command class represents a command for the editor command line. A
* command simply consists of a string, for example \e find. To register a
* command use CommandInterface::registerCommand(). The Editor itself queries
* the command for a list of accepted strings/commands by calling cmds().
* If the command gets invoked the function exec() is called, i.e. you have
* to implement the \e reaction in exec(). Whenever the user needs help for
* a command help() is called.
*
* \section cmd_information Command Information
* To provide reasonable information about a specific command there are the
* following accessor functions for a given command string:
* - name() returns a label
* - description() returns a descriptive text
* - category() returns a category into which the command fits.
*
* These getters allow KTextEditor implementations to plug commands into menus
* and toolbars, so that a user can assign shortcuts.
*
* \section cmd_extension Command Extensions
*
* If your command needs to interactively react on changes while the user is
* typing text - look at the \e ifind command in Kate for example - you have
* to additionally derive your command from the class CommandExtension. The
* command extension provides methods to give help on \e flags or add a
* KCompletion object and process the typed text interactively. Besides that
* the class RangeCommand enables you to support ranges so that you can apply
* commands on regions of text.
*
* \see KTextEditor::CommandInterface, KTextEditor::CommandExtension,
* KTextEditor::RangeCommand
* \author Christoph Cullmann \<cullmann@kde.org\>
* \note KDE5: derive from QObject, so qobject_cast works for extension interfaces.
*/
class KTEXTEDITOR_EXPORT Command
{
public:
/**
* Virtual destructor.
*/
virtual ~Command () {}
public:
/**
* Return a list of strings a command may begin with.
* A string is the start part of a pure text which can be handled by this
* command, i.e. for the command s/sdl/sdf/g the corresponding string is
* simply \e s, and for char:1212 simply \e char.
* \return list of supported commands
*/
virtual const QStringList &cmds () = 0;
/**
* Execute the command for the given \p view and \p cmd string.
* Return the success value and a \p msg for status. As example we
* consider a replace command. The replace command would return the number
* of replaced strings as \p msg, like "16 replacements made." If an error
* occurred in the usage it would return \e false and set the \p msg to
* something like "missing argument." or such.
*
* \return \e true on success, otherwise \e false
*/
virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg) = 0;
/**
* Shows help for the given \p view and \p cmd string.
* If your command has a help text for \p cmd you have to return \e true
* and set the \p msg to a meaningful text. The help text is embedded by
* the Editor in a Qt::RichText enabled widget, e.g. a QToolTip.
* \return \e true if your command has a help text, otherwise \e false
*/
virtual bool help (KTextEditor::View *view, const QString &cmd, QString &msg) = 0;
};
/**
* \brief Extension interface for a Command.
*
* \ingroup kte_group_command_extensions
*
* \section cmdext_intro Introduction
*
* The CommandExtension extends the Command interface allowing to interact
* with commands during typing. This allows for completion and for example
* the isearch plugin. If you develop a command that wants to complete or
* process text as the user types the arguments, or that has flags, you can
* have your command inherit this class.
*
* If your command supports flags return them by reimplementing
* flagCompletions(). You can return your own KCompletion object if the
* command has available completion data. If you want to interactively react
* on changes return \e true in wantsToProcessText() for the given command
* and reimplement processText().
*
* \see KTextEditor::CommandInterface, KTextEditor::Command, KCompletion
* \author Christoph Cullmann \<cullmann@kde.org\>
*/
class KTEXTEDITOR_EXPORT CommandExtension
{
public:
/**
* Virtual destructor.
*/
virtual ~CommandExtension() {}
/**
* Fill in a \p list of flags to complete from. Each flag is a single
* letter, any following text in the string is taken to be a description
* of the flag's meaning, and showed to the user as a hint.
* Implement this method if your command has flags.
*
* This method is called each time the flag string in the typed command
* is changed, so that the available flags can be adjusted. When
* completions are displayed, existing flags are left out.
* \param list flag list
*/ //### this is yet to be tried
virtual void flagCompletions( QStringList&list ) = 0;
/**
* Return a KCompletion object that will substitute the command line
* default one while typing the first argument of the command \p cmdname.
* The text will be added to the command separated by one space character.
*
* Implement this method if your command can provide a completion object.
*
* \param view the view the command will work on
* \param cmdname the command name associated with this request.
* \return the completion object or NULL, if you do not support a
* completion object
*/
virtual KCompletion *completionObject( KTextEditor::View *view,
const QString & cmdname ) = 0;
/**
* Check, whether the command wants to process text interactively for the
* given command with name \p cmdname.
* If you return true, the command's processText() method is called
* whenever the text in the command line changed.
*
* Reimplement this to return true, if your commands wants to process the
* text while typing.
*
* \param cmdname the command name associated with this query.
* \return \e true, if your command wants to process text interactively,
* otherwise \e false
* \see processText()
*/
virtual bool wantsToProcessText( const QString &cmdname ) = 0;
/**
* This is called by the command line each time the argument text for the
* command changed, if wantsToProcessText() returns \e true.
* \param view the current view
* \param text the current command text typed by the user
* \see wantsToProcessText()
*/ // ### yet to be tested. The obvious candidate is isearch.
virtual void processText( KTextEditor::View *view, const QString &text ) = 0;
};
/**
* \brief Command extension interface for the Editor.
*
* \ingroup kte_group_editor_extensions
*
* \section cmdiface_intro Introduction
*
* The CommandInterface extends the Editor to support command line commands.
* An application or a Plugin can register new commands by using
* registerCommand(). To unregister a command call unregisterCommand(). To
* check, whether a command with a given name exists use queryCommand().
*
* \section cmdiface_access Accessing the CommandInterface
*
* The CommandInterface is supposed to be an extension interface for the
* Editor, i.e. the Editor inherits the interface \e provided that the
* used KTextEditor library implements the interface. Use qobject_cast to
* access the interface:
* \code
* // editor is of type KTextEditor::Editor*
* KTextEditor::CommandInterface *iface =
* qobject_cast<KTextEditor::CommandInterface*>( editor );
*
* if( iface ) {
* // the implementation supports the interface
* // do stuff
* }
* \endcode
*
* \see KTextEditor::Editor, KTextEditor::Command,
* KTextEditor::CommandExtension
* \author Christoph Cullmann \<cullmann@kde.org\>
*/
class KTEXTEDITOR_EXPORT CommandInterface
{
public:
/**
* Virtual destructor.
*/
virtual ~CommandInterface () {}
public:
/**
* Register a the new command \p cmd. The command will be registered for
* all documents, i.e. every command is global.
*
* \param cmd command to register
* \return \e true on success, otherwise \e false
* \see unregisterCommand()
*/
virtual bool registerCommand (Command *cmd) = 0;
/**
* Unregister the command \p cmd. The command will be unregistered for
* all documents.
*
* \param cmd command to unregister
* \return \e true on success, otherwise \e false
* \see registerCommand()
*/
virtual bool unregisterCommand (Command *cmd) = 0;
/**
* Query for the command \p cmd.
* If the command \p cmd does not exist the return value is NULL.
*
* \param cmd name of command to query for
* \return the found command or NULL if no such command exists
*/
virtual Command *queryCommand (const QString &cmd) const = 0;
/**
* Get a list of all registered commands.
* \return list of all commands
* \see queryCommand(), commandList()
*/
virtual QList<Command*> commands() const = 0;
/**
* Get a list of available command line strings.
* \return command line strings
* \see commands()
*/
virtual QStringList commandList() const = 0;
};
/**
* \brief Extension interface for a Command making the exec method take a line
* range
*
* \ingroup kte_group_command_extensions
*
* \section cmdext_intro Introduction
*
* The RangeCommand extension extends the Command interface by making it
* possible to send a range to a command indicating that it should only do its
* work on those lines.
*
* The method supportsRange() takes a QString reference and should return true
* if the given command name supports a range and false if not.
*
* \see KTextEditor::CommandInterface, KTextEditor::Command, KTextEditor::Range
* \author Erlend Hamberg \<ehamberg@gmail.com\>
* \since 4.2
* \note KDE5: merge with KTextEditor::Command?
*/
class KTEXTEDITOR_EXPORT RangeCommand
{
public:
/**
* Virtual destructor.
*/
virtual ~RangeCommand() {}
/**
* Execute the command for the given \p range on the given \p view and \p
* cmd string. Return the success value and a \p msg for status.
*
* \return \e true on success, otherwise \e false
*/
virtual bool exec (KTextEditor::View *view, const QString &cmd, QString &msg,
const KTextEditor::Range &range) = 0;
/**
* Find out if a given command can act on a range. This is used for checking
* if a command should be called when the user also gave a range or if an
* error should be raised.
*
* \return \e true if command supports acting on a range of lines, false if
* not
*/
virtual bool supportsRange (const QString &cmd) = 0;
};
}
Q_DECLARE_INTERFACE(KTextEditor::CommandInterface, "org.kde.KTextEditor.CommandInterface")
#endif
// kate: space-indent on; indent-width 2; replace-tabs on;
|