GtkSource.CompletionProvider¶
- Implementations:
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
- class GtkSource.CompletionProvider¶
- Bases:
- Structure:
Completion provider interface.
You must implement this interface to provide proposals to [class`Completion`].
In most cases, implementations of this interface will want to use [vfunc`CompletionProvider`.populate_async] to asynchronously populate the results to avoid blocking the main loop.
- activate(context, proposal)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
This function requests proposal to be activated by the
GtkSource.CompletionProvider
.What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a
GtkSource.Snippet
with edit points the user may cycle through.See also: [class`Snippet`], [class`SnippetChunk`], [method`View`.push_snippet]
- display(context, proposal, cell)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
cell (
GtkSource.CompletionCell
) – aGtkSource.CompletionCell
This function requests that the
GtkSource.CompletionProvider
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).
- get_priority(context)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
- Return type:
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.
- get_title()¶
-
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-
None
.
- is_trigger(iter, ch)¶
- Parameters:
iter (
Gtk.TextIter
) – aGtk.TextIter
ch (
str
) – a #gunichar of the character inserted
- Return type:
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.
- key_activates(context, proposal, keyval, state)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
keyval (
int
) – a keyval such as [const`Gdk`.KEY_period]state (
Gdk.ModifierType
) – aGdk.ModifierType
or 0
- Return type:
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.
- list_alternates(context, proposal)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
- Returns:
- Return type:
Providers should return a list of alternates to proposal or
None
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.
- populate_async(context, cancellable, callback, *user_data)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
orNone
callback (
Gio.AsyncReadyCallback
orNone
) – a callback to execute upon completion
Asynchronously requests that the provider populates the completion results for context.
For providers that would like to populate a [iface`Gio`.ListModel] while those results are displayed to the user, [method`CompletionContext`.set_proposals_for_provider] may be used to reduce latency until the user sees results.
- populate_finish(result)¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
provided to callback- Raises:
- Returns:
- Return type:
Completes an asynchronous operation to populate a completion provider.
- refilter(context, model)¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
model (
Gio.ListModel
) – aGio.ListModel
This function can be used to filter results previously provided to the [class`CompletionContext`] by the
GtkSource.CompletionProvider
.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 [iface`Gio`.ListModel] of results.
- do_activate(context, proposal) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
This function requests proposal to be activated by the
GtkSource.CompletionProvider
.What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a
GtkSource.Snippet
with edit points the user may cycle through.See also: [class`Snippet`], [class`SnippetChunk`], [method`View`.push_snippet]
- do_display(context, proposal, cell) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
cell (
GtkSource.CompletionCell
) – aGtkSource.CompletionCell
This function requests that the
GtkSource.CompletionProvider
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).
- do_get_priority(context) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
- Return type:
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.
- do_get_title() virtual¶
-
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-
None
.
- do_is_trigger(iter, ch) virtual¶
- Parameters:
iter (
Gtk.TextIter
) – aGtk.TextIter
ch (
str
) – a #gunichar of the character inserted
- Return type:
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.
- do_key_activates(context, proposal, keyval, state) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
keyval (
int
) – a keyval such as [const`Gdk`.KEY_period]state (
Gdk.ModifierType
) – aGdk.ModifierType
or 0
- Return type:
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.
- do_list_alternates(context, proposal) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
proposal (
GtkSource.CompletionProposal
) – aGtkSource.CompletionProposal
- Returns:
- Return type:
Providers should return a list of alternates to proposal or
None
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.
- do_populate_async(context, cancellable, callback, *user_data) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
cancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
orNone
callback (
Gio.AsyncReadyCallback
orNone
) – a callback to execute upon completion
Asynchronously requests that the provider populates the completion results for context.
For providers that would like to populate a [iface`Gio`.ListModel] while those results are displayed to the user, [method`CompletionContext`.set_proposals_for_provider] may be used to reduce latency until the user sees results.
- do_populate_finish(result) virtual¶
- Parameters:
result (
Gio.AsyncResult
) – aGio.AsyncResult
provided to callback- Returns:
- Return type:
Completes an asynchronous operation to populate a completion provider.
- do_refilter(context, model) virtual¶
- Parameters:
context (
GtkSource.CompletionContext
) – aGtkSource.CompletionContext
model (
Gio.ListModel
) – aGio.ListModel
This function can be used to filter results previously provided to the [class`CompletionContext`] by the
GtkSource.CompletionProvider
.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 [iface`Gio`.ListModel] of results.