Module: GtkSource::CompletionProvider

Defined in:
(unknown)

Overview

Completion provider interface.

You must implement this interface to provide proposals to [classCompletion].

In most cases, implementations of this interface will want to use [vfuncCompletionProvider.populate_async] to asynchronously populate the results to avoid blocking the main loop.

Instance Method Summary collapse

Instance Method Details

#activate(context, proposal) ⇒ nil

This function requests proposal to be activated by the Gtk::SourceCompletionProvider.

What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a Gtk::SourceSnippet with edit points the user may cycle through.

See also: [classSnippet], [classSnippetChunk], [methodView.push_snippet]

Parameters:

Returns:

  • (nil)

#display(context, proposal, cell) ⇒ nil

This function requests that the Gtk::SourceCompletionProvider prepares cell to display the contents of proposal.

Based on cells column type, you may want to display different information.

This allows for columns of information among completion proposals resulting in better alignment of similar content (icons, return types, method names, and parameter lists).

Parameters:

Returns:

  • (nil)

#get_priority(context) ⇒ Integer

This function should return the priority of self in context.

The priority is used to sort groups of completion proposals by provider so that higher priority providers results are shown above lower priority providers.

Higher value indicates higher priority.

Parameters:

Returns:

  • (Integer)

#is_trigger(iter, ch) ⇒ Boolean

This function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.

An example would be period '.' which might indicate that the user wants to complete method or field names of an object.

This method will only trigger when text is inserted into the Gtk::TextBuffer while the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.

Parameters:

  • iter (Gtk::TextIter)

    a Gtk::TextIter

  • ch (String)

    a #gunichar of the character inserted

Returns:

  • (Boolean)

#key_activates(context, proposal, keyval, state) ⇒ Boolean

This function is used to determine if a key typed by the user should activate proposal (resulting in committing the text to the editor).

This is useful when using languages where convention may lead to less typing by the user. One example may be the use of "." or "-" to expand a field access in the C programming language.

Parameters:

Returns:

  • (Boolean)

#list_alternates(context, proposal) ⇒ Array<GtkSource::CompletionProposal>

Providers should return a list of alternates to proposal or nil if there are no alternates available.

This can be used by the completion view to allow the user to move laterally through similar proposals, such as overrides of methods by the same name.

Parameters:

Returns:

#populate(context) ⇒ Gio::ListModel

Parameters:

Returns:

  • (Gio::ListModel)

#populate_async(context, cancellable, callback, user_data) ⇒ nil

Asynchronously requests that the provider populates the completion results for context.

For providers that would like to populate a [ifaceGio.ListModel] while those results are displayed to the user, [methodCompletionContext.set_proposals_for_provider] may be used to reduce latency until the user sees results.

Parameters:

  • context (GtkSource::CompletionContext)

    a Gtk::SourceCompletionContext

  • cancellable (Gio::Cancellable)

    a #GCancellable or nil

  • callback (Gio::AsyncReadyCallback)

    a callback to execute upon completion

  • user_data (GObject)

    closure data for callback

Returns:

  • (nil)

#populate_finish(result) ⇒ Gio::ListModel

Completes an asynchronous operation to populate a completion provider.

Parameters:

  • result (Gio::AsyncResult)

    a GAsync::Result provided to callback

Returns:

  • (Gio::ListModel)

    a GList::Model of #GtkSourceCompletionProposal

#refilter(context, model) ⇒ nil

This function can be used to filter results previously provided to the [classCompletionContext] by the Gtk::SourceCompletionProvider.

This can happen as the user types additional text onto the word so that previously matched items may be removed from the list instead of generating new [ifaceGio.ListModel] of results.

Parameters:

Returns:

  • (nil)

#titleString

Gets the title of the completion provider, if any.

Currently, titles are not displayed in the completion results, but may be at some point in the future when non-nil.

Returns:

  • (String)

    a title for the provider or nil