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
Nested ClassesModifier and TypeClassDescriptionstatic classSnippet.Builder<B extends Snippet.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChunk(SnippetChunk chunk) Appendschunkto thesnippet.protected SnippetasParent()Returns this instance as if it were its parent type.static Snippet.Builder<? extends Snippet.Builder> builder()ASnippet.Builderobject constructs aSnippetwith the specified properties.copy()Does a deep copy of the snippet.@Nullable SnippetContextGets the context used for expanding the snippet.Gets the description for the snippet.intGets the current focus for the snippet.Gets the language-id used for the source snippet.getName()Gets the name for the snippet.intGets the number of chunks in the snippet.getNthChunk(int nth) Gets the chunk atnth.@Nullable StringGets the trigger for the source snippet.static @Nullable TypegetType()Get the GType of the Snippet classstatic SnippetParses the snippet formattedtextinto a series of chunks and adds them to a newGtkSourceSnippet.voidsetDescription(String description) Sets the description for the snippet.voidsetLanguageId(String languageId) Sets the language identifier for the snippet.voidSets the name for the snippet.voidsetTrigger(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, 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, hashCode
-
Constructor Details
-
Snippet
Create a Snippet proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Snippet
-
Snippet
public Snippet()Creates a new Snippet.
-
-
Method Details
-
getType
-
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. -
parsed
Parses the snippet formattedtextinto a series of chunks and adds them to a newGtkSourceSnippet.- Parameters:
text- the formatted snippet text to parse- Returns:
- the newly parsed
GtkSourceSnippet, ornullupon failure anderroris set. - Throws:
GErrorException- seeGError- Since:
- 5.6
-
addChunk
Appendschunkto thesnippet.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:idproperty.- 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:ididentifier.- Parameters:
languageId- the language identifier for the snippet
-
setName
-
setTrigger
Sets the trigger for the snippet.- Parameters:
trigger- the trigger word
-
builder
ASnippet.Builderobject constructs aSnippetwith the specified properties. Use the variousset...()methods to set properties, and finish construction withSnippet.Builder.build().- Returns:
- the builder object
-