CommandExtension Class Reference
from PyKDE4.ktexteditor import *
Namespace: KTextEditor
Detailed Description
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
Methods | |
KCompletion | completionObject (self, KTextEditor.View view, QString cmdname) |
flagCompletions (self, QStringList list) | |
processText (self, KTextEditor.View view, QString text) | |
bool | wantsToProcessText (self, QString cmdname) |
Method Documentation
KCompletion completionObject | ( | self, | ||
KTextEditor.View | view, | |||
QString | cmdname | |||
) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
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.
- Parameters:
-
view the view the command will work on
- Parameters:
-
cmdname the command name associated with this request.
- Returns:
- the completion object or NULL, if you do not support a completion object
flagCompletions | ( | self, | ||
QStringList | list | |||
) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
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.
- Parameters:
-
list flag list
processText | ( | self, | ||
KTextEditor.View | view, | |||
QString | text | |||
) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
This is called by the command line each time the argument text for the command changed, if wantsToProcessText() returns true.
- Parameters:
-
view the current view
- Parameters:
-
text the current command text typed by the user
- See also:
- wantsToProcessText()
bool wantsToProcessText | ( | self, | ||
QString | cmdname | |||
) |
- Abstract method:
- This method is abstract and can be overridden but not called directly.
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.
- Parameters:
-
cmdname the command name associated with this query.
- Returns:
- true, if your command wants to process text interactively, otherwise false
- See also:
- processText()