## IdeSnippet IdeSnippet — A snippet to be inserted into a file |

## Functions

IdeSnippet * | ide_snippet_new ()
IdeSnippet * | ide_snippet_copy ()
const gchar * | ide_snippet_get_trigger ()
void | ide_snippet_set_trigger ()
const gchar * | ide_snippet_get_language ()
void | ide_snippet_set_language ()
const gchar * | ide_snippet_get_description ()
void | ide_snippet_set_description ()
void | ide_snippet_add_chunk ()
guint | ide_snippet_get_n_chunks ()
gint | ide_snippet_get_tab_stop ()
IdeSnippetChunk * | ide_snippet_get_nth_chunk ()
void | ide_snippet_get_chunk_range ()
IdeSnippetContext * | ide_snippet_get_context ()
gchar * | ide_snippet_get_full_text ()
void | ide_snippet_replace_current_chunk_text ()

## Properties

GtkTextBuffer * | buffer | Read
gchar * | description | Read / Write
gchar * | language | Read / Write
GtkTextMark * | mark-begin | Read
GtkTextMark * | mark-end | Read
gint | tab-stop | Read
gchar * | trigger | Read / Write

## Types and Values

#define | IDE_TYPE_SNIPPET
| IdeSnippet

## Object Hierarchy

        GObject
        ╰── IdeSnippet

## Description

The IdeSnippet represents a single snippet that may be inserted into the IdeSourceView.

## Functions

### ide_snippet_new ()

    IdeSnippet *
    ide_snippet_new (const gchar *trigger,
                     const gchar *language);

Creates a new IdeSnippet

#### Parameters

trigger | the trigger word. | [nullable]
language | the source language. | [nullable]

#### Returns

A new IdeSnippet.

[transfer full]

Since: 3.32

### ide_snippet_copy ()

    IdeSnippet *
    ide_snippet_copy (IdeSnippet *self);

Does a deep copy of the snippet.

#### Parameters

self | an IdeSnippet |

#### Returns

An IdeSnippet.

[transfer full]

Since: 3.32

### ide_snippet_get_trigger ()

    const gchar *
    ide_snippet_get_trigger (IdeSnippet *self);

Gets the trigger for the source snippet

#### Parameters

self | a IdeSnippet |

#### Returns

A trigger if specified.

[nullable]

Since: 3.32

### ide_snippet_set_trigger ()

    void
    ide_snippet_set_trigger (IdeSnippet *self,
                             const gchar *trigger);

Sets the trigger for the snippet.

#### Parameters

self | a IdeSnippet |
trigger | the trigger word |

Since: 3.32

### ide_snippet_get_language ()

    const gchar *
    ide_snippet_get_language (IdeSnippet *self);

Gets the language used for the source snippet.

The language identifier matches the “id” property.

#### Parameters

self | a IdeSnippet |

#### Returns

the language identifier

Since: 3.32

### ide_snippet_set_language ()

    void
    ide_snippet_set_language (IdeSnippet *self,
                              const gchar *language);

Sets the language identifier for the snippet.

This should match the “id” identifier.

#### Parameters

self | a IdeSnippet |

Since: 3.32

### ide_snippet_get_description ()

    const gchar *
    ide_snippet_get_description (IdeSnippet *self);

Gets the description for the snippet.

#### Parameters

self | a IdeSnippet |

Since: 3.32

### ide_snippet_set_description ()

    void
    ide_snippet_set_description (IdeSnippet *self,
                                 const gchar *description);

Sets the description for the snippet.

#### Parameters

self | a IdeSnippet |
description | the snippet description |

Since: 3.32

### ide_snippet_add_chunk ()

    void
    ide_snippet_add_chunk (IdeSnippet *self,
                           IdeSnippetChunk *chunk);

### ide_snippet_get_n_chunks ()

    guint
    ide_snippet_get_n_chunks (IdeSnippet *self);

Gets the number of chunks in the snippet. Not all chunks are editable.

#### Parameters

self | a IdeSnippet |

#### Returns

The number of chunks.

Since: 3.32

### ide_snippet_get_tab_stop ()

    gint
    ide_snippet_get_tab_stop (IdeSnippet *self);

Gets the current tab stop for the snippet. This is changed as the user Tab's through the edit points.

#### Parameters

self | a IdeSnippet |

#### Returns

The tab stop, or -1 if unset.

Since: 3.32

### ide_snippet_get_nth_chunk ()

    IdeSnippetChunk *
    ide_snippet_get_nth_chunk (IdeSnippet *self,
                               guint n);

Gets the chunk at `n` .

#### Parameters

self | an IdeSnippet |
n | the nth chunk to get |

#### Returns

an IdeSnippetChunk.

[transfer none]

Since: 3.32

### ide_snippet_get_chunk_range ()

    void
    ide_snippet_get_chunk_range (IdeSnippet *self,
                                 IdeSnippetChunk *chunk,
                                 GtkTextIter *begin,
                                 GtkTextIter *end);

### ide_snippet_get_context ()

    IdeSnippetContext *
    ide_snippet_get_context (IdeSnippet *self);

Get's the context used for expanding the snippet.

#### Parameters

self | an IdeSnippet |

#### Returns

an IdeSnippetContext.

[nullable][transfer none]

Since: 3.32

### ide_snippet_get_full_text ()

    gchar *
    ide_snippet_get_full_text (IdeSnippet *self);

Gets the contents of the snippet as currently edited by the user.

#### Parameters

self | a IdeSnippet |

#### Returns

a newly allocated string containing the full contents of all the snippet chunks.

[transfer full]

Since: 3.32

### ide_snippet_replace_current_chunk_text ()

    void
    ide_snippet_replace_current_chunk_text
                                   (IdeSnippet *self,
                                    const gchar *new_text);

This replaces the current chunk (if any) to contain the contents of `new_text` .

This function is primarily useful to the IdeSourceView as it updates content as the user types.

#### Parameters

self | a IdeSnippet |
new_text | the text to use as the replacement |

Since: 3.32

## Types and Values

### IDE_TYPE_SNIPPET

    #define IDE_TYPE_SNIPPET (ide_snippet_get_type())

### IdeSnippet

    typedef struct _IdeSnippet IdeSnippet;

## Property Details

### The `“buffer”` property

      “buffer”                   GtkTextBuffer *

The GtkTextBuffer for the snippet.

Owner: IdeSnippet

Flags: Read

### The `“description”` property

      “description”              gchar *

The description for the snippet.

Owner: IdeSnippet

Flags: Read / Write

Default value: NULL

### The `“language”` property

      “language”                 gchar *

The language for the snippet.

Owner: IdeSnippet

Flags: Read / Write

Default value: NULL

### The `“mark-begin”` property

      “mark-begin”               GtkTextMark *

The beginning text mark.

Owner: IdeSnippet

Flags: Read

### The `“mark-end”` property

      “mark-end”                 GtkTextMark *

The ending text mark.

Owner: IdeSnippet

Flags: Read

### The `“tab-stop”` property

      “tab-stop”                 gint

The current tab stop.

Owner: IdeSnippet

Flags: Read

Allowed values: >= -1

Default value: -1

### The `“trigger”` property

      “trigger”                  gchar *

The trigger for the snippet.

Owner: IdeSnippet

Flags: Read / Write

Default value: NULL