Class Snippet
- All Implemented Interfaces:
Proxy
The GtkSourceSnippet
represents a series of chunks that can quickly be
inserted into the View
.
Snippets are defined in XML files which are loaded by the
SnippetManager
. Alternatively, applications can create snippets
on demand and insert them into the View
using
View.pushSnippet(org.gnome.gtksourceview.Snippet, org.gnome.gtk.TextIter)
.
Snippet chunks can reference other snippet chunks as well as post-process the values from other chunks such as capitalization.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Snippet.Builder<B extends Snippet.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionCreates a newGtkSourceSnippet
Snippet
(MemorySegment address) Create a Snippet proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChunk
(SnippetChunk chunk) Appendschunk
to the this Snippet.protected Snippet
asParent()
Returns this instance as if it were its parent type.static Snippet.Builder
<? extends Snippet.Builder> builder()
ASnippet.Builder
object constructs aSnippet
with the specified properties.copy()
Does a deep copy of the snippet.Gets the context used for expanding the snippet.Gets the description for the snippet.int
Gets the current focus for the snippet.Gets the language-id used for the source snippet.getName()
Gets the name for the snippet.int
Gets the number of chunks in the snippet.getNthChunk
(int nth) Gets the chunk atnth
.Gets the trigger for the source snippet.static Type
getType()
Get the GType of the Snippet classstatic Snippet
Parses the snippet formattedtext
into a series of chunks and adds them to a newGtkSourceSnippet
.void
setDescription
(String description) Sets the description for the snippet.void
setLanguageId
(String languageId) Sets the language identifier for the snippet.void
Sets the name for the snippet.void
setTrigger
(String trigger) Sets the trigger for the snippet.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
-
Snippet
Create a Snippet proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Snippet
-
-
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. -
parsed
Parses the snippet formattedtext
into a series of chunks and adds them to a newGtkSourceSnippet
.- Parameters:
text
- the formatted snippet text to parse- Returns:
- the newly parsed
GtkSourceSnippet
, ornull
upon failure anderror
is set. - Throws:
GErrorException
- seeGError
-
addChunk
Appendschunk
to the this Snippet.This may only be called before the snippet has been expanded.
- Parameters:
chunk
- aGtkSourceSnippetChunk
-
copy
-
getContext
Gets the context used for expanding the snippet.- Returns:
- an
GtkSourceSnippetContext
-
getDescription
Gets the description for the snippet. -
getFocusPosition
public int getFocusPosition()Gets the current focus for the snippet.This is changed as the user tabs through focus locations.
- Returns:
- The focus position, or -1 if unset.
-
getLanguageId
Gets the language-id used for the source snippet.The language identifier should be one that matches a source language
Language:id
property.- Returns:
- the language identifier
-
getNChunks
public int getNChunks()Gets the number of chunks in the snippet.Note that not all chunks are editable.
- Returns:
- The number of chunks.
-
getName
Gets the name for the snippet. -
getNthChunk
Gets the chunk atnth
.- Parameters:
nth
- the nth chunk to get- Returns:
- an
GtkSourceSnippetChunk
-
getTrigger
Gets the trigger for the source snippet.A trigger is a word that can be expanded into the full snippet when the user presses Tab.
- Returns:
- A string or
null
-
setDescription
Sets the description for the snippet.- Parameters:
description
- the snippet description
-
setLanguageId
Sets the language identifier for the snippet.This should match the
Language:id
identifier.- Parameters:
languageId
- the language identifier for the snippet
-
setName
-
setTrigger
Sets the trigger for the snippet.- Parameters:
trigger
- the trigger word
-
builder
ASnippet.Builder
object constructs aSnippet
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withSnippet.Builder.build()
.
-