Class CompletionContext<T extends GObject>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,List<T>,SequencedCollection<T>,ListModel<T>,Proxy,ListModelJavaList<T>
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 org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface org.javagi.gio.ListModelJavaList
ListModelJavaList.SubList<E extends @Nullable GObject,List extends ListModelJavaList<E>> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new CompletionContext.CompletionContext(MemorySegment address) Create a CompletionContext proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletionContextasParent()Returns 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.@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(org.gnome.gtksourceview.CompletionContext, org.gnome.gio.Cancellable, org.gnome.gio.AsyncReadyCallback).Methods inherited from class org.gnome.gobject.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, getMemoryLayout, 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 org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCodeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface org.javagi.gio.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 proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
CompletionContext
public CompletionContext()Creates a new CompletionContext.
-
-
Method Details
-
getType
Get the GType of the CompletionContext class- Returns:
- the GType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuperkeyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName(). This will call the native function pointer of this virtual method in the typeclass of the parent type. -
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 theGListModelassociated 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 toCompletionProvider.populateAsync(org.gnome.gtksourceview.CompletionContext, org.gnome.gio.Cancellable, org.gnome.gio.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(org.gnome.gtksourceview.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
-