KTextEditor
#include <commandinterface.h>
Public Member Functions | |
virtual | ~Command () |
virtual const QStringList & | cmds ()=0 |
virtual bool | exec (KTextEditor::View *view, const QString &cmd, QString &msg)=0 |
virtual bool | help (KTextEditor::View *view, const QString &cmd, QString &msg)=0 |
Detailed Description
An Editor command line command.
Introduction
The Command class represents a command for the editor command line. A command simply consists of a string, for example 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 reaction in exec(). Whenever the user needs help for a command help() is called.
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.
Command Extensions
If your command needs to interactively react on changes while the user is typing text - look at the 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 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.
- Note
- KDE5: derive from QObject, so qobject_cast works for extension interfaces.
Definition at line 76 of file commandinterface.h.
Constructor & Destructor Documentation
|
inlinevirtual |
Virtual destructor.
Definition at line 82 of file commandinterface.h.
Member Function Documentation
|
pure virtual |
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 s, and for char:1212 simply char.
- Returns
- list of supported commands
|
pure virtual |
Execute the command for the given view
and cmd
string.
Return the success value and a msg
for status. As example we consider a replace command. The replace command would return the number of replaced strings as msg
, like "16 replacements made." If an error occurred in the usage it would return false and set the msg
to something like "missing argument." or such.
- Returns
- true on success, otherwise false
|
pure virtual |
The documentation for this class was generated from the following file:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:27:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.