Snippet#
Superclasses: Object
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
push_snippet
.
Snippet chunks can reference other snippet chunks as well as post-process the values from other chunks such as capitalization.
Constructors#
Methods#
- class Snippet
- add_chunk(chunk: SnippetChunk) None #
Appends
chunk
to thesnippet
.This may only be called before the snippet has been expanded.
- Parameters:
chunk – a
SnippetChunk
- get_context() SnippetContext | None #
Gets the context used for expanding the snippet.
- get_focus_position() int #
Gets the current focus for the snippet.
This is changed as the user tabs through focus locations.
- get_language_id() str #
Gets the language-id used for the source snippet.
The language identifier should be one that matches a source language
id
property.
- get_n_chunks() int #
Gets the number of chunks in the snippet.
Note that not all chunks are editable.
- get_nth_chunk(nth: int) SnippetChunk #
Gets the chunk at
nth
.- Parameters:
nth – the nth chunk to get
- get_trigger() str | None #
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.
- set_description(description: str) None #
Sets the description for the snippet.
- Parameters:
description – the snippet description
Properties#
- class Snippet
- props.buffer: TextBuffer#
The type of the None singleton.