Interface CompletionProvider
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
CompletionProvider.CompletionProvider$Impl,CompletionSnippets,CompletionWords
You must implement this interface to provide proposals to Completion.
In most cases, implementations of this interface will want to use
populateAsync(org.gnome.gtksourceview.CompletionContext, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback) to asynchronously populate the results
to avoid blocking the main loop.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classThe CompletionProvider$Impl type represents a native instance of the CompletionProvider interface.static class -
Method Summary
Modifier and TypeMethodDescriptiondefault voidactivate(CompletionContext context, CompletionProposal proposal) This function requestsproposalto be activated by theGtkSourceCompletionProvider.default voiddisplay(CompletionContext context, CompletionProposal proposal, CompletionCell cell) This function requests that theGtkSourceCompletionProviderpreparescellto display the contents ofproposal.default intgetPriority(CompletionContext context) This function should return the priority of this CompletionProvider incontext.default @Nullable StringgetTitle()Gets the title of the completion provider, if any.static @Nullable TypegetType()Get the GType of the CompletionProvider classdefault booleanThis function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.default booleankeyActivates(CompletionContext context, CompletionProposal proposal, int keyval, Set<ModifierType> state) This function is used to determine if a key typed by the user should activateproposal(resulting in committing the text to the editor).default booleankeyActivates(CompletionContext context, CompletionProposal proposal, int keyval, ModifierType... state) This function is used to determine if a key typed by the user should activateproposal(resulting in committing the text to the editor).default @Nullable CompletionProposal @Nullable []listAlternates(CompletionContext context, CompletionProposal proposal) Providers should return a list of alternates toproposalornullif there are no alternates available.default voidpopulateAsync(CompletionContext context, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously requests that the provider populates the completion results forcontext.default ListModelpopulateFinish(AsyncResult result) Completes an asynchronous operation to populate a completion provider.default voidrefilter(CompletionContext context, ListModel model) This function can be used to filter results previously provided to theCompletionContextby theGtkSourceCompletionProvider.
-
Method Details
-
getType
-
activate
This function requestsproposalto be activated by theGtkSourceCompletionProvider.What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a
GtkSourceSnippetwith edit points the user may cycle through.See also:
Snippet,SnippetChunk,View.pushSnippet(org.gnome.gtksourceview.Snippet, org.gnome.gtk.TextIter)- Parameters:
context- aGtkSourceCompletionContextproposal- aGtkSourceCompletionProposal
-
display
This function requests that theGtkSourceCompletionProviderpreparescellto display the contents ofproposal.Based on
cellscolumn 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:
context- aGtkSourceCompletionContextproposal- aGtkSourceCompletionProposalcell- aGtkSourceCompletionCell
-
getPriority
This function should return the priority of this CompletionProvider incontext.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:
context- aGtkSourceCompletionContext
-
getTitle
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-
null.- Returns:
- a title for the provider or
null
-
isTrigger
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
GtkTextBufferwhile the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.- Parameters:
iter- aGtkTextIterch- agunicharof the character inserted
-
keyActivates
default boolean keyActivates(CompletionContext context, CompletionProposal proposal, int keyval, Set<ModifierType> state) This function is used to determine if a key typed by the user should activateproposal(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:
context- aGtkSourceCompletionContextproposal- aGtkSourceCompletionProposalkeyval- a keyval such asGdk.KEY_periodstate- aGdkModifierTypeor 0
-
keyActivates
default boolean keyActivates(CompletionContext context, CompletionProposal proposal, int keyval, ModifierType... state) This function is used to determine if a key typed by the user should activateproposal(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:
context- aGtkSourceCompletionContextproposal- aGtkSourceCompletionProposalkeyval- a keyval such asGdk.KEY_periodstate- aGdkModifierTypeor 0
-
listAlternates
default @Nullable CompletionProposal @Nullable [] listAlternates(CompletionContext context, CompletionProposal proposal) Providers should return a list of alternates toproposalornullif 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:
context- aGtkSourceCompletionContextproposal- aGtkSourceCompletionProposal- Returns:
- a
GPtrArrayofGtkSourceCompletionProposalornull.
-
populateAsync
default void populateAsync(CompletionContext context, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously requests that the provider populates the completion results forcontext.For providers that would like to populate a
ListModelwhile those results are displayed to the user,CompletionContext.setProposalsForProvider(org.gnome.gtksourceview.CompletionProvider, org.gnome.gio.ListModel)may be used to reduce latency until the user sees results.- Parameters:
context- aGtkSourceCompletionContextcancellable- aGCancellableornullcallback- a callback to execute upon completion
-
populateFinish
Completes an asynchronous operation to populate a completion provider.- Parameters:
result- aGAsyncResultprovided to callback- Returns:
- a
GListModelofGtkSourceCompletionProposal - Throws:
GErrorException- seeGError
-
refilter
This function can be used to filter results previously provided to theCompletionContextby theGtkSourceCompletionProvider.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
ListModelof results.- Parameters:
context- aGtkSourceCompletionContextmodel- aGListModel
-