• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KTextEditor

KTextEditor::Command

KTextEditor::Command Class Reference

#include <commandinterface.h>

List of all members.


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.

See also:
KTextEditor::CommandInterface, KTextEditor::CommandExtension
Author:
Christoph Cullmann <cullmann@kde.org>

Definition at line 70 of file commandinterface.h.


Public Member Functions

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
virtual ~Command ()

Constructor & Destructor Documentation

virtual KTextEditor::Command::~Command (  )  [inline, virtual]

Virtual destructor.

Definition at line 76 of file commandinterface.h.


Member Function Documentation

virtual const QStringList& KTextEditor::Command::cmds (  )  [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

virtual bool KTextEditor::Command::exec ( KTextEditor::View *  view,
const QString &  cmd,
QString &  msg 
) [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

virtual bool KTextEditor::Command::help ( KTextEditor::View *  view,
const QString &  cmd,
QString &  msg 
) [pure virtual]

Shows help for the given view and cmd string.

If your command has a help text for cmd you have to return true and set the msg to a meaningful text. The help text is embedded by the Editor in a Qt::RichText enabled widget, e.g. a QToolTip.

Returns:
true if your command has a help text, otherwise false


The documentation for this class was generated from the following file:
  • commandinterface.h

KTextEditor

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal