Class Completion
- All Implemented Interfaces:
Proxy
The completion system helps the user when they writes some text, such as words, command names, functions, and suchlike. Proposals can be shown, to complete the text the user is writing. Each proposal can contain an additional piece of information (for example documentation), that is displayed when the "Details" button is clicked.
Proposals are created via a CompletionProvider
. There can
be for example a provider to complete words (see CompletionWords
),
another provider for the completion of
function names, etc. To add a provider, call
addProvider(org.gnome.gtksourceview.CompletionProvider)
.
The CompletionProposal
interface represents a proposal.
If a proposal contains extra information (see
CompletionColumn.DETAILS
), it will be
displayed in a supplemental details window, which appears when
the "Details" button is clicked.
Each View
object is associated with a Completion
instance. This instance can be obtained with
View.getCompletion()
. The View
class contains also the
View::show-completion
signal.
A same CompletionProvider
object can be used for several
GtkSourceCompletion
's.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Completion.Builder<B extends Completion.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
static interface
Functional interface declaration of theHideCallback
callback.static interface
Functional interface declaration of theProviderAddedCallback
callback.static interface
Functional interface declaration of theProviderRemovedCallback
callback.static interface
Functional interface declaration of theShowCallback
callback.Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCompletion
(MemorySegment address) Create a Completion proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addProvider
(CompletionProvider provider) Adds aCompletionProvider
to the list of providers to be queried for completion results.protected Completion
asParent()
Returns this instance as if it were its parent type.void
static Completion.Builder
<? extends Completion.Builder> builder()
ACompletion.Builder
object constructs aCompletion
with the specified properties.void
emitHide()
Emits the "hide" signal.void
emitProviderAdded
(CompletionProvider provider) Emits the "provider-added" signal.void
emitProviderRemoved
(CompletionProvider provider) Emits the "provider-removed" signal.void
emitShow()
Emits the "show" signal.static AttrList
fuzzyHighlight
(String haystack, String casefoldQuery) This will add<b>
tags around matched characters inhaystack
based oncasefoldQuery
.static boolean
fuzzyMatch
(@Nullable String haystack, String casefoldNeedle, @Nullable Out<Integer> priority) This helper function can do a fuzzy match for you giving a haystack and casefolded needle.int
static Type
getType()
Get the GType of the Completion classgetView()
Gets theView
that owns theCompletion
.void
hide()
Emits the "hide" signal.onHide
(Completion.HideCallback handler) The "hide" signal is emitted when the completion window should be hidden.The "provided-added" signal is emitted when a new provider is added to the completion.The "provided-removed" signal is emitted when a provider has been removed from the completion.onShow
(Completion.ShowCallback handler) The "show" signal is emitted when the completion window should be shown.void
removeProvider
(CompletionProvider provider) Removes aCompletionProvider
previously added withaddProvider(org.gnome.gtksourceview.CompletionProvider)
.void
setPageSize
(int pageSize) void
show()
Emits the "show" signal.void
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
-
Constructor Details
-
Completion
Create a Completion 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. -
fuzzyHighlight
This will add<b>
tags around matched characters inhaystack
based oncasefoldQuery
.- Parameters:
haystack
- the string to be highlightedcasefoldQuery
- the typed-text used to highlighthaystack
- Returns:
- a
PangoAttrList
ornull
-
fuzzyMatch
public static boolean fuzzyMatch(@Nullable @Nullable String haystack, String casefoldNeedle, @Nullable @Nullable Out<Integer> priority) This helper function can do a fuzzy match for you giving a haystack and casefolded needle.Casefold your needle using
GLib.utf8Casefold(java.lang.String, long)
before running the query.Score will be set with the score of the match upon success. Otherwise, it will be set to zero.
- Parameters:
haystack
- the string to be searched.casefoldNeedle
- A g_utf8_casefold() version of the needle.priority
- An optional location for the score of the match- Returns:
true
ifhaystack
matchedcasefoldNeedle
, otherwisefalse
.
-
addProvider
Adds aCompletionProvider
to the list of providers to be queried for completion results.- Parameters:
provider
- aGtkSourceCompletionProvider
-
blockInteractive
public void blockInteractive() -
getBuffer
-
getPageSize
public int getPageSize() -
getView
-
hide
public void hide()Emits the "hide" signal.When the "hide" signal is emitted, the completion window will be dismissed.
-
removeProvider
Removes aCompletionProvider
previously added withaddProvider(org.gnome.gtksourceview.CompletionProvider)
.- Parameters:
provider
- aGtkSourceCompletionProvider
-
setPageSize
public void setPageSize(int pageSize) -
show
public void show()Emits the "show" signal.When the "show" signal is emitted, the completion window will be displayed if there are any results available.
-
unblockInteractive
public void unblockInteractive() -
onHide
The "hide" signal is emitted when the completion window should be hidden.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitHide
public void emitHide()Emits the "hide" signal. SeeonHide(org.gnome.gtksourceview.Completion.HideCallback)
. -
onProviderAdded
public SignalConnection<Completion.ProviderAddedCallback> onProviderAdded(Completion.ProviderAddedCallback handler) The "provided-added" signal is emitted when a new provider is added to the completion.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitProviderAdded
Emits the "provider-added" signal. SeeonProviderAdded(org.gnome.gtksourceview.Completion.ProviderAddedCallback)
. -
onProviderRemoved
public SignalConnection<Completion.ProviderRemovedCallback> onProviderRemoved(Completion.ProviderRemovedCallback handler) The "provided-removed" signal is emitted when a provider has been removed from the completion.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitProviderRemoved
Emits the "provider-removed" signal. SeeonProviderRemoved(org.gnome.gtksourceview.Completion.ProviderRemovedCallback)
. -
onShow
The "show" signal is emitted when the completion window should be shown.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitShow
public void emitShow()Emits the "show" signal. SeeonShow(org.gnome.gtksourceview.Completion.ShowCallback)
. -
builder
ACompletion.Builder
object constructs aCompletion
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withCompletion.Builder.build()
.
-