# class KTextEditor.CommandInterface

### abstract class

Table of contents
Modules
ktexteditor Classes
All Classes

Module | ktexteditor
Namespace | ktexteditor
Class | KTextEditor.CommandInterface
Inherits |

Command extension interface for the Editor.

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().

Accessing the CommandInterface

The CommandInterface is supposed to be an extension interface for the Editor, i.e. the Editor inherits the interface provided that the used KTextEditor library implements the interface. Use qobject_cast to access the interface:

    // editor is of type KTextEditor.Editor*
    KTextEditor.CommandInterface *iface =
    qobject_cast<KTextEditor.CommandInterface*>( editor );

    if( iface ) {
    // the implementation supports the interface
    // do stuff
    }

See also KTextEditor.Editor, KTextEditor.Command, KTextEditor.CommandExtension Author Christoph Cullmann \<cullmann@kde.org\>

### methods

- commandList ()

  returns (QStringList)
  pure virtual

  Get a list of available command line strings. Returns command line strings

  See also commands()

- commands ()

  returns (list of KTextEditor.Command)
  pure virtual

  Get a list of all registered commands. Returns list of all commands

  See also queryCommand(), commandList()

- queryCommand (cmd)

  returns (KTextEditor.Command)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  cmd | QString |

  Query for the command cmd. If the command cmd does not exist the return value is 0.

  cmd - name of command to query for Returns the found command or 0 if no such command exists

- registerCommand (cmd)

  returns (bool)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  cmd | KTextEditor.Command |

  Register a the new command cmd. The command will be registered for all documents, i.e. every command is global.

  cmd - command to register Returns true on success, otherwise false

  See also unregisterCommand()

- unregisterCommand (cmd)

  returns (bool)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  cmd | KTextEditor.Command |

  Unregister the command cmd. The command will be unregistered for all documents.

  cmd - command to unregister Returns true on success, otherwise false

  See also registerCommand()