Class Snippet
- All Implemented Interfaces:
Proxy
Quick insertion code snippets.
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(Snippet, 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 GObject
GObject.NotifyCallback, GObject.ObjectClass -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChunk(SnippetChunk chunk) Appendschunkto thesnippet.protected SnippetasParent()Return 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.static MemoryLayoutThe memory layout of the native struct.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 class.static 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 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, 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 TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Snippet
Create a Snippet instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Snippet
-
Snippet
public Snippet()Create a new Snippet.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
-
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
Appends
chunkto 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
-