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

KTextEditor

  • KTextEditor
  • CodeCompletionInterface
Public Member Functions | List of all members
KTextEditor::CodeCompletionInterface Class Referenceabstract
View Extension Interfaces

#include <codecompletioninterface.h>

Public Member Functions

virtual ~CodeCompletionInterface ()
 
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*
KTextEditor::CodeCompletionInterface *iface =
qobject_cast<KTextEditor::CodeCompletionInterface*>( view );
if( iface ) {
// the implementation supports the interface
// do stuff
}

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 92 of file codecompletioninterface.h.

Constructor & Destructor Documentation

CodeCompletionInterface::~CodeCompletionInterface ( )
virtual

Definition at line 23 of file codecompletioninterface.cpp.

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:
  • codecompletioninterface.h
  • codecompletioninterface.cpp
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