CompletionContext#

class CompletionContext(**properties: Any)#

Superclasses: Object

Implemented Interfaces: ListModel

The context of a completion.

GtkSourceCompletionContext contains information about an attept to display completion proposals to the user based on typed text in the View.

When typing, Completion may use registered CompletionProvider to determine if there may be results which could be displayed. If so, a GtkSourceCompletionContext is created with information that is provided to the CompletionProvider to populate results which might be useful to the user.

CompletionProvider are expected to provide ListModel with CompletionProposal which may be joined together in a list of results for the user. They are also responsible for how the contents are displayed using CompletionCell which allows for some level of customization.

Methods#

class CompletionContext
get_activation() CompletionActivation#

Gets the mode for which the context was activated.

get_bounds() Tuple[bool, TextIter, TextIter]#

Gets the bounds for the completion, which is the beginning of the current word (taking break characters into account) to the current insertion cursor.

If begin is non-None, it will be set to the start position of the current word being completed.

If end is non-None, it will be set to the insertion cursor for the current word being completed.

get_buffer() Buffer | None#

Gets the underlying buffer used by the context.

This is a convenience function to get the buffer via the Completion property.

get_busy() bool#

Gets the “busy” property. This is set to True while the completion context is actively fetching proposals from registered CompletionProvider's.

get_completion() Completion | None#

Gets the Completion that created the context.

get_empty() bool#

Checks if any proposals have been provided to the context.

Out of convenience, this function will return True if self is None.

get_language() Language | None#

Gets the language of the underlying buffer, if any.

get_proposals_for_provider(provider: CompletionProvider) ListModel | None#

Gets the ListModel associated with the provider.

You can connect to CompletionContext::model-changed to receive notifications about when the model has been replaced by a new model.

Added in version 5.6.

Parameters:

provider – a CompletionProvider

get_view() View | None#

Gets the text view for the context.

get_word() str#

Gets the word that is being completed up to the position of the insert mark.

list_providers() ListModel#

Gets the providers that are associated with the context.

Added in version 5.6.

set_proposals_for_provider(provider: CompletionProvider, results: ListModel | None = None) None#

This function allows providers to update their results for a context outside of a call to populate_async.

This can be used to immediately return results for a provider while it does additional asynchronous work. Doing so will allow the completions to update while the operation is in progress.

Parameters:

Properties#

class CompletionContext
props.busy: bool#

The type of the None singleton.

props.completion: Completion#

The type of the None singleton.

props.empty: bool#

The type of the None singleton.

Signals#

class CompletionContext.signals
provider_model_changed(provider: CompletionProvider, model: ListModel | None = None) None#

The type of the None singleton.

Added in version 5.6.

Parameters: