Class CompletionContext<T extends GObject>
- All Implemented Interfaces:
Iterable<T>, Collection<T>, List<T>, SequencedCollection<T>, ListModel<T>, Proxy, ListModelJavaList<T>
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCompletionContext.Builder<B extends CompletionContext.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classstatic interfaceFunctional interface declaration of theProviderModelChangedCallbackcallback.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface ListModelJavaList
ListModelJavaList.SubList<E,List> -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new CompletionContext.CompletionContext(MemorySegment address) Create a CompletionContext instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletionContextasParent()Return this instance as if it were its parent type.static CompletionContext.Builder<? extends CompletionContext.Builder> builder()ACompletionContext.Builderobject constructs aCompletionContextwith the specified properties.voidemitProviderModelChanged(@Nullable CompletionProvider provider, @Nullable ListModel model) Emits the "provider-model-changed" signal.Gets the mode for which the context was activated.booleanGets the bounds for the completion, which is the beginning of the current word (taking break characters into account) to the current insertion cursor.@Nullable BufferGets the underlying buffer used by the context.booleangetBusy()Gets the "busy" property.@Nullable CompletionGets theGtkSourceCompletionthat created the context.booleangetEmpty()Checks if any proposals have been provided to the context.@Nullable LanguageGets the language of the underlying buffer, if any.static MemoryLayoutThe memory layout of the native struct.@Nullable ListModelgetProposalsForProvider(CompletionProvider provider) Gets theGListModelassociated with the provider.static @Nullable TypegetType()Get the GType of the CompletionContext class.@Nullable ViewgetView()Gets the text view for the context.getWord()Gets the word that is being completed up to the position of the insert mark.Gets the providers that are associated with the context.Emitted when a provider changes a model.voidsetProposalsForProvider(CompletionProvider provider, @Nullable ListModel results) This function allows providers to update their results for a context outside of a call toCompletionProvider.populateAsync(CompletionContext, Cancellable, AsyncReadyCallback).Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
-
Constructor Details
-
CompletionContext
Create a CompletionContext instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
CompletionContext
public CompletionContext()Create a new CompletionContext.
-
-
Method Details
-
getType
Get the GType of the CompletionContext class.- Returns:
- the GType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Return this instance as if it were its parent type. Comparable to the Javasuperkeyword, but ensures the parent typeclass is also used in native code. -
getActivation
Gets the mode for which the context was activated. -
getBounds
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
beginis non-null, it will be set to the start position of the current word being completed.If
endis non-null, it will be set to the insertion cursor for the current word being completed.- Parameters:
begin- aGtkTextIterend- aGtkTextIter- Returns:
trueif the marks are still valid andbeginorendwas set.
-
getBuffer
Gets the underlying buffer used by the context.
This is a convenience function to get the buffer via the
GtkSourceCompletionproperty.- Returns:
- a
GtkTextBufferornull
-
getBusy
public boolean getBusy()Gets the "busy" property. This is set totruewhile the completion context is actively fetching proposals from registeredGtkSourceCompletionProvider's.- Returns:
trueif the context is busy
-
getCompletion
Gets theGtkSourceCompletionthat created the context.- Returns:
- an
GtkSourceCompletionornull
-
getEmpty
public boolean getEmpty()Checks if any proposals have been provided to the context.
Out of convenience, this function will return
trueif this CompletionContext isnull.- Returns:
trueif there are no proposals in the context
-
getLanguage
Gets the language of the underlying buffer, if any.- Returns:
- a
GtkSourceLanguageornull
-
getProposalsForProvider
Gets the
GListModelassociated with the provider.You can connect to
GtkSourceCompletionContext::model-changed to receive notifications about when the model has been replaced by a new model.- Parameters:
provider- aGtkSourceCompletionProvider- Returns:
- a
GListModelornull - Since:
- 5.6
-
getView
Gets the text view for the context.- Returns:
- a
GtkSourceViewornull
-
getWord
Gets the word that is being completed up to the position of the insert mark.- Returns:
- a string containing the current word
-
listProviders
Gets the providers that are associated with the context.- Returns:
- a
GListModelofGtkSourceCompletionProvider - Since:
- 5.6
-
setProposalsForProvider
This function allows providers to update their results for a context outside of a call to
CompletionProvider.populateAsync(CompletionContext, Cancellable, AsyncReadyCallback).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:
provider- anGtkSourceCompletionProviderresults- aGListModelornull
-
onProviderModelChanged
public SignalConnection<CompletionContext.ProviderModelChangedCallback> onProviderModelChanged(CompletionContext.ProviderModelChangedCallback handler) Emitted when a provider changes a model.
This signal is primarily useful for
GtkSourceCompletionProvider's that want to track other providers in context. For example, it can be used to create a "top results" provider.- Parameters:
handler- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- Since:
- 5.6
- See Also:
-
emitProviderModelChanged
public void emitProviderModelChanged(@Nullable CompletionProvider provider, @Nullable ListModel model) Emits the "provider-model-changed" signal. SeeonProviderModelChanged(CompletionContext.ProviderModelChangedCallback). -
builder
ACompletionContext.Builderobject constructs aCompletionContextwith the specified properties. Use the variousset...()methods to set properties, and finish construction withCompletionContext.Builder.build().- Returns:
- the builder object
-