GtkSourceSnippetContext

GtkSourceSnippetContext — Context for expanding GtkSourceSnippetChunk

Functions

Signals

void changed Run First

Types and Values

Object Hierarchy

    GObject
    ╰── GtkSourceSnippetContext

Includes

#include <gtksourceview/gtksource.h>

Description

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 GtkSourceSnippetChunk can expand themselves by executing script within the context.

The GtkSourceSnippet will build the context and then expand each of the chunks during the insertion/edit phase.

Functions

gtk_source_snippet_context_clear_variables ()

void
gtk_source_snippet_context_clear_variables
                               (GtkSourceSnippetContext *self);

Removes all variables from the context.

Parameters

Since: 5.0


gtk_source_snippet_context_expand ()

gchar *
gtk_source_snippet_context_expand (GtkSourceSnippetContext *self,
                                   const gchar *input);

gtk_source_snippet_context_get_variable ()

const gchar *
gtk_source_snippet_context_get_variable
                               (GtkSourceSnippetContext *self,
                                const gchar *key);

Gets the current value for a variable named key .

Parameters

self

a GtkSourceSnippetContext

 

key

the name of the variable

 

Returns

the value for the variable, or NULL.

[transfer none][nullable]

Since: 5.0


gtk_source_snippet_context_new ()

GtkSourceSnippetContext *
gtk_source_snippet_context_new (void);

Creates a new GtkSourceSnippetContext.

Generally, this isn't needed unless you are controlling the expansion of snippets manually.

Returns

a GtkSourceSnippetContext.

[transfer full]

Since: 5.0


gtk_source_snippet_context_set_constant ()

void
gtk_source_snippet_context_set_constant
                               (GtkSourceSnippetContext *self,
                                const gchar *key,
                                const gchar *value);

Sets a constatnt within the context. This is similar to a variable set with gtk_source_snippet_context_set_variable() but is expected to not change during use of the snippet.

Examples would be the date or users name.

Parameters

self

a GtkSourceSnippetContext

 

key

the constant name

 

value

the value of the constant

 

Since: 5.0


gtk_source_snippet_context_set_line_prefix ()

void
gtk_source_snippet_context_set_line_prefix
                               (GtkSourceSnippetContext *self,
                                const gchar *line_prefix);

gtk_source_snippet_context_set_tab_width ()

void
gtk_source_snippet_context_set_tab_width
                               (GtkSourceSnippetContext *self,
                                gint tab_width);

gtk_source_snippet_context_set_use_spaces ()

void
gtk_source_snippet_context_set_use_spaces
                               (GtkSourceSnippetContext *self,
                                gboolean use_spaces);

gtk_source_snippet_context_set_variable ()

void
gtk_source_snippet_context_set_variable
                               (GtkSourceSnippetContext *self,
                                const gchar *key,
                                const gchar *value);

Sets a variable within the context.

This variable may be overridden by future updates to the context.

Parameters

self

a GtkSourceSnippetContext

 

key

the variable name

 

value

the value for the variable

 

Since: 5.0

Types and Values

GtkSourceSnippetContext

typedef struct _GtkSourceSnippetContext GtkSourceSnippetContext;

Signal Details

The “changed” signal

void
user_function (GtkSourceSnippetContext *sourcesnippetcontext,
               gpointer                 user_data)

The "changed" signal is emitted when a change has been discovered in one of the chunks of the snippet which has caused a variable or other dynamic data within the context to have changed.

Parameters

user_data

user data set when the signal handler was connected.

 

Flags: Run First

Since: 5.0