Snippet

class Snippet(**properties: Any)

Superclasses: Object

Constructors:

Snippet(**properties)
new(trigger:str=None, language_id:str=None) -> GtkSource.Snippet
new_parsed(text:str) -> GtkSource.Snippet

Constructors

class Snippet
classmethod new(trigger: str | None = None, language_id: str | None = None) Snippet

Creates a new Snippet

Parameters:
  • trigger – the trigger word

  • language_id – the source language

classmethod new_parsed(text: str) Snippet

Parses the snippet formatted text into a series of chunks and adds them to a new Snippet.

Added in version 5.6.

Parameters:

text – the formatted snippet text to parse

Methods

class Snippet
add_chunk(chunk: SnippetChunk) None

Appends chunk to the snippet.

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_description() str

Gets the description for 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_name() str

Gets the name for the snippet.

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

set_language_id(language_id: str) None

Sets the language identifier for the snippet.

This should match the id identifier.

Parameters:

language_id – the language identifier for the snippet

set_name(name: str) None

Sets the name for the snippet.

Parameters:

name – the snippet name

set_trigger(trigger: str) None

Sets the trigger for the snippet.

Parameters:

trigger – the trigger word

Properties

class Snippet
props.buffer: TextBuffer
props.description: str
props.focus_position: int
props.language_id: str
props.name: str
props.trigger: str