• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • applications API Reference
  • KDE Home
  • Contact Us
 

KTextEditor

  • KTextEditor
  • Command
Public Member Functions | List of all members
KTextEditor::Command Class Referenceabstract

#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.

See also
KTextEditor::CommandInterface, KTextEditor::CommandExtension, KTextEditor::RangeCommand
Author
Christoph Cullmann <cullm.nosp@m.ann@.nosp@m.kde.o.nosp@m.rg>
Note
KDE5: derive from QObject, so qobject_cast works for extension interfaces.

Definition at line 76 of file commandinterface.h.

Constructor & Destructor Documentation

virtual KTextEditor::Command::~Command ( )
inlinevirtual

Virtual destructor.

Definition at line 82 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
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 9 2020 03:56:48 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTextEditor

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

applications API Reference

Skip menu "applications API Reference"
  •   kate
  •       kate
  •   KTextEditor
  •   Kate
  • Konsole

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal