SnippetChunk

class SnippetChunk(**properties: Any)

Superclasses: InitiallyUnowned, Object

A chunk of text within the source snippet.

The GtkSourceSnippetChunk represents a single chunk of text that may or may not be an edit point within the snippet. Chunks that are an edit point (also called a tab stop) have the focus_position property set.

Constructors

class SnippetChunk
classmethod new() SnippetChunk

Create a new GtkSourceSnippetChunk that can be added to a Snippet.

Methods

class SnippetChunk
get_context() SnippetContext

Gets the context for the snippet insertion.

get_focus_position() int

Gets the focus_position.

The focus-position is used to determine how many tabs it takes for the snippet to advanced to this chunk.

A focus-position of zero will be the last focus position of the snippet and snippet editing ends when it has been reached.

A focus-position of -1 means the chunk cannot be focused by the user.

get_spec() str | None

Gets the specification for the chunk.

The specification is evaluated for variables when other chunks are edited within the snippet context. If the user has changed the text, the text and text_set properties are updated.

get_text() str

Gets the text property.

The text property is updated when the user edits the text of the chunk. If it has not been edited, the spec property is returned.

get_text_set() bool

Gets the text_set property.

This is typically set when the user has edited a snippet chunk.

get_tooltip_text() str
set_context(context: SnippetContext) None
Parameters:

context

set_focus_position(focus_position: int) None

Sets the focus_position property.

The focus-position is used to determine how many tabs it takes for the snippet to advanced to this chunk.

A focus-position of zero will be the last focus position of the snippet and snippet editing ends when it has been reached.

A focus-position of -1 means the chunk cannot be focused by the user.

Parameters:

focus_position – the focus-position

set_spec(spec: str) None

Sets the specification for the chunk.

The specification is evaluated for variables when other chunks are edited within the snippet context. If the user has changed the text, the text and text_set properties are updated.

Parameters:

spec – the new specification for the chunk

set_text(text: str) None

Sets the text for the snippet chunk.

This is usually used by the snippet engine to update the text, but may be useful when creating custom snippets to avoid expansion of any specification.

Parameters:

text – the text of the property

set_text_set(text_set: bool) None

Sets the text_set property.

This is typically set when the user has edited a snippet chunk by the snippet engine.

Parameters:

text_set – the property value

set_tooltip_text(tooltip_text: str) None
Parameters:

tooltip_text

Properties

class SnippetChunk
props.context: SnippetContext
props.focus_position: int
props.spec: str
props.text: str
props.text_set: bool
props.tooltip_text: str