Interface CompletionProvider
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
CompletionProvider.CompletionProviderImpl
,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
Modifier and TypeInterfaceDescriptionstatic class
The CompletionProviderImpl type represents a native instance of the CompletionProvider interface.static class
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
activate
(CompletionContext context, CompletionProposal proposal) This function requestsproposal
to be activated by theGtkSourceCompletionProvider
.default void
display
(CompletionContext context, CompletionProposal proposal, CompletionCell cell) This function requests that theGtkSourceCompletionProvider
preparescell
to display the contents ofproposal
.default int
getPriority
(CompletionContext context) This function should return the priority of this CompletionProvider incontext
.default String
getTitle()
Gets the title of the completion provider, if any.static Type
getType()
Get the GType of the CompletionProvider classdefault boolean
This function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.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).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).default CompletionProposal[]
listAlternates
(CompletionContext context, CompletionProposal proposal) Providers should return a list of alternates toproposal
ornull
if there are no alternates available.default void
populateAsync
(CompletionContext context, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously requests that the provider populates the completion results forcontext
.default ListModel
populateFinish
(AsyncResult result) Completes an asynchronous operation to populate a completion provider.default void
refilter
(CompletionContext context, ListModel model) This function can be used to filter results previously provided to theCompletionContext
by theGtkSourceCompletionProvider
.
-
Method Details
-
getType
-
activate
This function requestsproposal
to be activated by theGtkSourceCompletionProvider
.What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a
GtkSourceSnippet
with edit points the user may cycle through.See also:
Snippet
,SnippetChunk
,View.pushSnippet(org.gnome.gtksourceview.Snippet, org.gnome.gtk.TextIter)
- Parameters:
context
- aGtkSourceCompletionContext
proposal
- aGtkSourceCompletionProposal
-
display
This function requests that theGtkSourceCompletionProvider
preparescell
to display the contents ofproposal
.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:
context
- aGtkSourceCompletionContext
proposal
- aGtkSourceCompletionProposal
cell
- 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
GtkTextBuffer
while the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.- Parameters:
iter
- aGtkTextIter
ch
- agunichar
of 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
- aGtkSourceCompletionContext
proposal
- aGtkSourceCompletionProposal
keyval
- a keyval such asGdk.KEY_period
state
- aGdkModifierType
or 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
- aGtkSourceCompletionContext
proposal
- aGtkSourceCompletionProposal
keyval
- a keyval such asGdk.KEY_period
state
- aGdkModifierType
or 0
-
listAlternates
Providers should return a list of alternates toproposal
ornull
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:
context
- aGtkSourceCompletionContext
proposal
- aGtkSourceCompletionProposal
- Returns:
- a
GPtrArray
ofGtkSourceCompletionProposal
ornull
.
-
populateAsync
default void populateAsync(CompletionContext context, @Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously requests that the provider populates the completion results forcontext
.For providers that would like to populate a
ListModel
while 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
- aGtkSourceCompletionContext
cancellable
- aGCancellable
ornull
callback
- a callback to execute upon completion
-
populateFinish
Completes an asynchronous operation to populate a completion provider.- Parameters:
result
- aGAsyncResult
provided to callback- Returns:
- a
GListModel
ofGtkSourceCompletionProposal
- Throws:
GErrorException
- seeGError
-
refilter
This function can be used to filter results previously provided to theCompletionContext
by 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
ListModel
of results.- Parameters:
context
- aGtkSourceCompletionContext
model
- aGListModel
-