:right-sidebar: True SnippetContext =================================================================== .. currentmodule:: gi.repository.GtkSource .. class:: SnippetContext(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Context for expanding :obj:`~gi.repository.GtkSource.SnippetChunk`\. This class is currently used primary as a hashtable. However, the longer term goal is to have it hold onto a ``GjsContext`` as well as other languages so that :obj:`~gi.repository.GtkSource.SnippetChunk` can expand themselves by executing script within the context. The :obj:`~gi.repository.GtkSource.Snippet` will build the context and then expand each of the chunks during the insertion/edit phase. Constructors ------------ .. rst-class:: interim-class .. class:: SnippetContext :no-index: .. classmethod:: new() -> ~gi.repository.GtkSource.SnippetContext Creates a new :obj:`~gi.repository.GtkSource.SnippetContext`\. Generally, this isn't needed unless you are controlling the expansion of snippets manually. Methods ------- .. rst-class:: interim-class .. class:: SnippetContext :no-index: .. method:: clear_variables() -> None Removes all variables from the context. .. method:: expand(input: str) -> str :param input: .. method:: get_variable(key: str) -> str | None Gets the current value for a variable named ``key``\. :param key: the name of the variable .. method:: set_constant(key: str, value: str) -> None Sets a constatnt within the context. This is similar to a variable set with :obj:`~gi.repository.SnippetContext.set_variable` but is expected to not change during use of the snippet. Examples would be the date or users name. :param key: the constant name :param value: the value of the constant .. method:: set_line_prefix(line_prefix: str) -> None :param line_prefix: .. method:: set_tab_width(tab_width: int) -> None :param tab_width: .. method:: set_use_spaces(use_spaces: bool) -> None :param use_spaces: .. method:: set_variable(key: str, value: str) -> None Sets a variable within the context. This variable may be overridden by future updates to the context. :param key: the variable name :param value: the value for the variable Signals ------- .. rst-class:: interim-class .. class:: SnippetContext.signals :no-index: .. method:: changed() -> None The type of the None singleton.