:right-sidebar: True Snippet =================================================================== .. currentmodule:: gi.repository.GtkSource .. class:: Snippet(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` :Constructors: :: Snippet(**properties) new(trigger:str=None, language_id:str=None) -> GtkSource.Snippet new_parsed(text:str) -> GtkSource.Snippet Constructors ------------ .. rst-class:: interim-class .. class:: Snippet :no-index: .. classmethod:: new(trigger: str | None = None, language_id: str | None = None) -> ~gi.repository.GtkSource.Snippet Creates a new :obj:`~gi.repository.GtkSource.Snippet` :param trigger: the trigger word :param language_id: the source language .. classmethod:: new_parsed(text: str) -> ~gi.repository.GtkSource.Snippet Parses the snippet formatted ``text`` into a series of chunks and adds them to a new :obj:`~gi.repository.GtkSource.Snippet`. .. versionadded:: 5.6 :param text: the formatted snippet text to parse Methods ------- .. rst-class:: interim-class .. class:: Snippet :no-index: .. method:: add_chunk(chunk: ~gi.repository.GtkSource.SnippetChunk) -> None Appends ``chunk`` to the ``snippet``. This may only be called before the snippet has been expanded. :param chunk: a :obj:`~gi.repository.GtkSource.SnippetChunk` .. method:: get_context() -> ~gi.repository.GtkSource.SnippetContext | None Gets the context used for expanding the snippet. .. method:: get_description() -> str Gets the description for the snippet. .. method:: get_focus_position() -> int Gets the current focus for the snippet. This is changed as the user tabs through focus locations. .. method:: get_language_id() -> str Gets the language-id used for the source snippet. The language identifier should be one that matches a source language :obj:`~gi.repository.GtkSource.Language.props.id` property. .. method:: get_n_chunks() -> int Gets the number of chunks in the snippet. Note that not all chunks are editable. .. method:: get_name() -> str Gets the name for the snippet. .. method:: get_nth_chunk(nth: int) -> ~gi.repository.GtkSource.SnippetChunk Gets the chunk at ``nth``. :param nth: the nth chunk to get .. method:: 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. .. method:: set_description(description: str) -> None Sets the description for the snippet. :param description: the snippet description .. method:: set_language_id(language_id: str) -> None Sets the language identifier for the snippet. This should match the :obj:`~gi.repository.GtkSource.Language.props.id` identifier. :param language_id: the language identifier for the snippet .. method:: set_name(name: str) -> None Sets the name for the snippet. :param name: the snippet name .. method:: set_trigger(trigger: str) -> None Sets the trigger for the snippet. :param trigger: the trigger word Properties ---------- .. rst-class:: interim-class .. class:: Snippet :no-index: .. attribute:: props.buffer :type: ~gi.repository.Gtk.TextBuffer .. attribute:: props.description :type: str .. attribute:: props.focus_position :type: int .. attribute:: props.language_id :type: str .. attribute:: props.name :type: str .. attribute:: props.trigger :type: str