KTextEditor::CodeCompletionInterface

KTextEditor::CodeCompletionInterface Class Referenceabstract

#include <KTextEditor/CodeCompletionInterface>

Inherited by KTextEditor::ViewPrivate.

Public Member Functions

virtual void abortCompletion ()=0
 
virtual void forceCompletion ()=0
 
virtual bool isAutomaticInvocationEnabled () const =0
 
virtual bool isCompletionActive () const =0
 
virtual void registerCompletionModel (CodeCompletionModel *model)=0
 
virtual void setAutomaticInvocationEnabled (bool enabled=true)=0
 
virtual void startCompletion (const Range &word, CodeCompletionModel *model)=0
 
virtual void unregisterCompletionModel (CodeCompletionModel *model)=0
 

Detailed Description

Code completion extension interface for the View.

Introduction

The CodeCompletionInterface is designed to provide code completion functionality for a KTextEditor::View. This interface provides the basic mechanisms to display a list of completions, update this list according to user input, and allow the user to select a completion.

Essentially, this provides an item view for the available completions. In order to use this interface, you will need to implement a CodeCompletionModel that generates the relevant completions given the current input.

Accessing the CodeCompletionInterface

The CodeCompletionInterface is an extension interface for a View, i.e. the View inherits the interface provided that the used KTextEditor library implements the interface. Use qobject_cast to access the interface:

// view is of type KTextEditor::View*
auto iface = qobject_cast<KTextEditor::CodeCompletionInterface*>(view);
if (iface) {
// the implementation supports the interface
// do stuff
} else {
// the implementation does not support the interface
}

Using the CodeCompletionInterface

The CodeCompletionInterface can be used in different ways, which we will call "automatic", and "manual".

Automatic

In automatic mode, the CodeCompletionInterface will take care of starting and aborting the generation of code completions as appropriate, when the users inserts or changes text.

To use the interface in this way, first register a CodeCompletionModel using registerCompletionModel(). Now call setAutomaticCompletionEnabled() to enabled automatic completions.

Manual

If you need more control over when code completions get shown or not, or which fragment of the text should be considered as the basis for generated completions, proceed as follows:

Call setAutomaticCompletionEnabled(false) to disable automatic completions. To start the generation of code completions for the current word, call startCompletion(), with the appropriate parameters. To hide the generated completions, use abortCompletion().

See also
KTextEditor::View, KTextEditor::CodeCompletionModel

Definition at line 97 of file codecompletioninterface.h.

Member Function Documentation

virtual void KTextEditor::CodeCompletionInterface::abortCompletion ( )
pure virtual

Abort the currently displayed code completion without executing any currently selected completion.

This is safe, even when the completion box is not currently active.

See also
isCompletionActive()
virtual void KTextEditor::CodeCompletionInterface::forceCompletion ( )
pure virtual

Force execution of the currently selected completion, and hide the code completion box.

virtual bool KTextEditor::CodeCompletionInterface::isAutomaticInvocationEnabled ( ) const
pure virtual

Determine the status of automatic code completion invocation.

virtual bool KTextEditor::CodeCompletionInterface::isCompletionActive ( ) const
pure virtual

Query whether the code completion box is currently displayed.

virtual void KTextEditor::CodeCompletionInterface::registerCompletionModel ( CodeCompletionModel model)
pure virtual

Register a new code completion model.

Parameters
modelnew completion model
See also
unregisterCompletionModel()
virtual void KTextEditor::CodeCompletionInterface::setAutomaticInvocationEnabled ( bool  enabled = true)
pure virtual

Enable or disable automatic code completion invocation.

virtual void KTextEditor::CodeCompletionInterface::startCompletion ( const Range word,
CodeCompletionModel model 
)
pure virtual

Invoke code completion over a given range, with a specific model.

virtual void KTextEditor::CodeCompletionInterface::unregisterCompletionModel ( CodeCompletionModel model)
pure virtual

Unregister a code completion model.

Parameters
modelthe model that should be unregistered
See also
registerCompletionModel()

The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 4 2020 22:58:06 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.