# class KTextEditor.CommandExtension

### abstract class

Table of contents
Modules
ktexteditor Classes
All Classes

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

Extension interface for a Command.

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 true in wantsToProcessText() for the given command and reimplement processText().

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

### methods

- completionObject (view, cmdname)

  returns (KCompletion)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  view | KTextEditor.View |
  cmdname | QString |

  Return a KCompletion object that will substitute the command line default one while typing the first argument of the command 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.

  view - the view the command will work on

  cmdname - the command name associated with this request. Returns the completion object or 0, if you do not support a completion object

- flagCompletions (list)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  list | QStringList |

  Fill in a 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.

  list - flag list // this is yet to be tried

- processText (view, text)

  returns nothing
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  view | KTextEditor.View |
  text | QString |

  This is called by the command line each time the argument text for the command changed, if wantsToProcessText() returns true.

  view - the current view

  text - the current command text typed by the user

  See also wantsToProcessText() // yet to be tested. The obvious candidate is isearch.

- wantsToProcessText (cmdname)

  returns (bool)
  pure virtual

  Argument | Type | Default
  --- | --- | ---
  cmdname | QString |

  Check, whether the command wants to process text interactively for the given command with name 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.

  cmdname - the command name associated with this query. Returns true, if your command wants to process text interactively, otherwise false

  See also processText()