Class CompletionContext<T extends GObject>
- All Implemented Interfaces:
Proxy
,ListModelJavaList<T>
,Iterable<T>
,Collection<T>
,List<T>
,SequencedCollection<T>
,ListModel<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
Modifier and TypeClassDescriptionstatic class
CompletionContext.Builder<B extends CompletionContext.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static interface
Functional interface declaration of theProviderModelChangedCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gio.ListModel
ListModel.ItemsChangedCallback, ListModel.ListModelImpl, ListModel.ListModelInterface
-
Constructor Summary
ConstructorDescriptionCompletionContext
(MemorySegment address) Create a CompletionContext proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected CompletionContext
asParent()
Returns this instance as if it were its parent type.static CompletionContext.Builder
<? extends CompletionContext.Builder> builder()
ACompletionContext.Builder
object constructs aCompletionContext
with the specified properties.void
emitProviderModelChanged
(CompletionProvider provider, @Nullable ListModel model) Emits the "provider-model-changed" signal.Gets the mode for which the context was activated.boolean
Gets the bounds for the completion, which is the beginning of the current word (taking break characters into account) to the current insertion cursor.Gets the underlying buffer used by the context.boolean
getBusy()
Gets the "busy" property.Gets theGtkSourceCompletion
that created the context.boolean
getEmpty()
Checks if any proposals have been provided to the context.Gets the language of the underlying buffer, if any.getProposalsForProvider
(CompletionProvider provider) Gets theGListModel
associated with the provider.static Type
getType()
Get the GType of the CompletionContext classgetView()
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.void
setProposalsForProvider
(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, 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, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliterator
Methods inherited from interface org.gnome.gio.ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChanged
Methods inherited from interface io.github.jwharm.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
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, 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
begin
is non-null
, it will be set to the start position of the current word being completed.If
end
is non-null
, it will be set to the insertion cursor for the current word being completed.- Parameters:
begin
- aGtkTextIter
end
- aGtkTextIter
- Returns:
true
if the marks are still valid andbegin
orend
was set.
-
getBuffer
Gets the underlying buffer used by the context.This is a convenience function to get the buffer via the
GtkSourceCompletion
property.- Returns:
- a
GtkTextBuffer
ornull
-
getBusy
public boolean getBusy()Gets the "busy" property. This is set totrue
while the completion context is actively fetching proposals from registeredGtkSourceCompletionProvider
's.- Returns:
true
if the context is busy
-
getCompletion
Gets theGtkSourceCompletion
that created the context.- Returns:
- an
GtkSourceCompletion
ornull
-
getEmpty
public boolean getEmpty()Checks if any proposals have been provided to the context.Out of convenience, this function will return
true
if this CompletionContext isnull
.- Returns:
true
if there are no proposals in the context
-
getLanguage
Gets the language of the underlying buffer, if any.- Returns:
- a
GtkSourceLanguage
ornull
-
getProposalsForProvider
Gets theGListModel
associated 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
GListModel
ornull
-
getView
-
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
GListModel
ofGtkSourceCompletionProvider
-
setProposalsForProvider
public void setProposalsForProvider(CompletionProvider provider, @Nullable @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)
.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
- anGtkSourceCompletionProvider
results
- aGListModel
ornull
-
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
- See Also:
-
emitProviderModelChanged
public void emitProviderModelChanged(CompletionProvider provider, @Nullable @Nullable ListModel model) Emits the "provider-model-changed" signal. SeeonProviderModelChanged(org.gnome.gtksourceview.CompletionContext.ProviderModelChangedCallback)
. -
builder
ACompletionContext.Builder
object constructs aCompletionContext
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withCompletionContext.Builder.build()
.
-