GtkSource.Snippet¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/en |
The |
||
r/w/en |
The description for the snippet |
||
r |
The currently focused chunk |
||
r/w/en |
The language-id for the snippet |
||
r/w/en |
The name for the snippet |
||
r/w/en |
The trigger for the snippet |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class GtkSource.Snippet(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Quick insertion code snippets.
The
GtkSourceSnippet
represents a series of chunks that can quickly be inserted into the [class`View`].Snippets are defined in XML files which are loaded by the [class`SnippetManager`]. Alternatively, applications can create snippets on demand and insert them into the [class`View`] using [method`View`.push_snippet].
Snippet chunks can reference other snippet chunks as well as post-process the values from other chunks such as capitalization.
- classmethod new(trigger, language_id)¶
- Parameters:
- Returns:
A new
GtkSource.Snippet
- Return type:
Creates a new
GtkSource.Snippet
- classmethod new_parsed(text)¶
- Parameters:
text (
str
) – the formatted snippet text to parse- Raises:
- Returns:
the newly parsed
GtkSource.Snippet
, orNone
upon failure and error is set.- Return type:
Parses the snippet formatted text into a series of chunks and adds them to a new
GtkSource.Snippet
.New in version 5.6.
- add_chunk(chunk)¶
- Parameters:
chunk (
GtkSource.SnippetChunk
) – aGtkSource.SnippetChunk
Appends chunk to the self.
This may only be called before the snippet has been expanded.
- copy()¶
- Returns:
A new
GtkSource.Snippet
- Return type:
Does a deep copy of the snippet.
- get_context()¶
- Returns:
- Return type:
Gets the context used for expanding the snippet.
- get_focus_position()¶
- Returns:
The focus position, or -1 if unset.
- Return type:
Gets the current focus for the snippet.
This is changed as the user tabs through focus locations.
- get_language_id()¶
- Returns:
the language identifier
- Return type:
Gets the language-id used for the source snippet.
The language identifier should be one that matches a source language [property`Language`:py:data::id<GtkSource.Snippet.props.id>] property.
- get_n_chunks()¶
- Returns:
The number of chunks.
- Return type:
Gets the number of chunks in the snippet.
Note that not all chunks are editable.
- get_nth_chunk(nth)¶
- Parameters:
nth (
int
) – the nth chunk to get- Returns:
- Return type:
Gets the chunk at nth.
- get_trigger()¶
-
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)¶
- Parameters:
description (
str
) – the snippet description
Sets the description for the snippet.
Property Details¶
- GtkSource.Snippet.props.buffer¶
- Name:
buffer
- Type:
- Default Value:
- Flags:
The
Gtk.TextBuffer
for the snippet
- GtkSource.Snippet.props.description¶
- Name:
description
- Type:
- Default Value:
- Flags:
The description for the snippet
- GtkSource.Snippet.props.focus_position¶
-
The currently focused chunk
- GtkSource.Snippet.props.language_id¶
- Name:
language-id
- Type:
- Default Value:
- Flags:
The language-id for the snippet
- GtkSource.Snippet.props.name¶
- Name:
name
- Type:
- Default Value:
- Flags:
The name for the snippet