TeplBuffer: Tepl 6 Reference Manual

## TeplBuffer TeplBuffer — Subclass of GtkSourceBuffer |

## Functions

TeplBuffer * | tepl_buffer_new ()
TeplFile * | tepl_buffer_get_file ()
TeplMetadata * | tepl_buffer_get_metadata ()
void | tepl_buffer_load_metadata_from_metadata_manager ()
void | tepl_buffer_save_metadata_into_metadata_manager ()
gboolean | tepl_buffer_is_untouched ()
gchar * | tepl_buffer_get_short_title ()
gchar * | tepl_buffer_get_full_title ()
gchar * | tepl_buffer_get_style_scheme_id ()
void | tepl_buffer_set_style_scheme_id ()
TeplSelectionType | tepl_buffer_get_selection_type ()

## Properties

char * | tepl-full-title | Read
char * | tepl-short-title | Read
char * | tepl-style-scheme-id | Read / Write

## Signals

void | tepl-cursor-moved | Run First

## Types and Values

| TeplBuffer
enum | TeplSelectionType

## Object Hierarchy

        GEnum
        ╰── TeplSelectionType
        GObject
        ╰── GtkTextBuffer
            ╰── GtkSourceBuffer
                ╰── TeplBuffer

## Includes

    #include <tepl/tepl.h>

## Description

TeplBuffer is a subclass of GtkSourceBuffer, to add more features useful for a text editor.

It also adds an association to a TeplFile that can be retrieved with `tepl_buffer_get_file()`. The association cannot change. The same for TeplMetadata with `tepl_buffer_get_metadata()`.

The properties and signals have the tepl namespace, to avoid potential conflicts in the future if the property or signal is moved to GtkSourceBuffer.

## Functions

### tepl_buffer_new ()

    TeplBuffer *
    tepl_buffer_new (void);

#### Returns

a new TeplBuffer.

Since: 1.0

### tepl_buffer_get_file ()

    TeplFile *
    tepl_buffer_get_file (TeplBuffer *buffer);

Returns the TeplFile of `buffer` . The returned object is guaranteed to be the same for the lifetime of `buffer` .

TeplBuffer creates the TeplFile with `tepl_abstract_factory_create_file()`.

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the associated TeplFile.

[transfer none]

Since: 1.0

### tepl_buffer_get_metadata ()

    TeplMetadata *
    tepl_buffer_get_metadata (TeplBuffer *buffer);

Returns the TeplMetadata of `buffer` . The returned object is guaranteed to be the same for the lifetime of `buffer` .

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the associated TeplMetadata.

[transfer none]

Since: 5.0

### tepl_buffer_load_metadata_from_metadata_manager ()

    void
    tepl_buffer_load_metadata_from_metadata_manager
                                   (TeplBuffer *buffer);

Calls `tepl_metadata_manager_copy_from()` for “location” (if not `NULL`) to the associated TeplMetadata of `buffer` .

#### Parameters

buffer | a TeplBuffer. |

Since: 5.0

### tepl_buffer_save_metadata_into_metadata_manager ()

    void
    tepl_buffer_save_metadata_into_metadata_manager
                                   (TeplBuffer *buffer);

Calls `tepl_metadata_manager_merge_into()` for “location” (if not `NULL`) from the associated TeplMetadata of `buffer` .

#### Parameters

buffer | a TeplBuffer. |

Since: 5.0

### tepl_buffer_is_untouched ()

    gboolean
    tepl_buffer_is_untouched (TeplBuffer *buffer);

Returns whether `buffer` is untouched.

This function is for example useful to know if we can re-use this buffer to load a file, instead of opening a new tab or window.

For this function to return `TRUE`, the `buffer` must be empty, non-modified, the undo/redo GtkSourceBuffer history must be empty, and the “location” must be `NULL`.

#### Parameters

buffer | a TeplBuffer. |

#### Returns

`TRUE` if `buffer` has not been touched, `FALSE` otherwise.

Since: 1.0

### tepl_buffer_get_short_title ()

    gchar *
    tepl_buffer_get_short_title (TeplBuffer *buffer);

Returns a title suitable for a tab label. It contains (in that order):

- '*' if the buffer is modified;

- the “short-name”.

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the `buffer` short title. Free the return value with `g_free()` when no longer needed.

Since: 3.0

### tepl_buffer_get_full_title ()

    gchar *
    tepl_buffer_get_full_title (TeplBuffer *buffer);

Returns a title suitable for a GtkWindow title. It contains (in that order):

- the “tepl-short-title”;

- the directory path in parenthesis if the “location” isn't `NULL`.

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the `buffer` full title. Free the return value with `g_free()` when no longer needed.

Since: 3.0

### tepl_buffer_get_style_scheme_id ()

    gchar *
    tepl_buffer_get_style_scheme_id (TeplBuffer *buffer);

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the “tepl-style-scheme-id”. Free with `g_free()`.

Since: 2.0

### tepl_buffer_set_style_scheme_id ()

    void
    tepl_buffer_set_style_scheme_id (TeplBuffer *buffer,
                                     const gchar *style_scheme_id);

Sets the “tepl-style-scheme-id” property.

The GtkSourceStyleScheme is taken from the default GtkSourceStyleSchemeManager as returned by `gtk_source_style_scheme_manager_get_default()`.

#### Parameters

buffer | a TeplBuffer. |
style_scheme_id | the new value. |

Since: 2.0

### tepl_buffer_get_selection_type ()

    TeplSelectionType
    tepl_buffer_get_selection_type (TeplBuffer *buffer);

#### Parameters

buffer | a TeplBuffer. |

#### Returns

the current TeplSelectionType.

Since: 1.0

## Types and Values

### TeplBuffer

    typedef struct _TeplBuffer TeplBuffer;

### enum TeplSelectionType

#### Members

TEPL_SELECTION_TYPE_NO_SELECTION | No selection. |
TEPL_SELECTION_TYPE_ON_SAME_LINE | The start and end selection bounds are on the same line. |
TEPL_SELECTION_TYPE_MULTIPLE_LINES | The selection spans multiple lines. |

Since: 1.0

## Property Details

### The `“tepl-full-title”` property

      “tepl-full-title”          char *

The full title. See `tepl_buffer_get_full_title()`.

Owner: TeplBuffer

Flags: Read

Default value: NULL

Since: 3.0

### The `“tepl-short-title”` property

      “tepl-short-title”         char *

The short title. See `tepl_buffer_get_short_title()`.

Owner: TeplBuffer

Flags: Read

Default value: NULL

Since: 3.0

### The `“tepl-style-scheme-id”` property

      “tepl-style-scheme-id”     char *

The “style-scheme” ID, as a string. This property is useful for binding it to a GSettings key.

When the “style-scheme” is `NULL`, “tepl-style-scheme-id” contains the empty string.

Owner: TeplBuffer

Flags: Read / Write

Default value: ""

Since: 2.0

## Signal Details

### The `“tepl-cursor-moved”` signal

    void
    user_function (TeplBuffer *buffer,
                   gpointer    user_data)

The ::tepl-cursor-moved signal is emitted when the insert mark is moved explicitely or when the buffer changes (insert/delete).

A typical use-case for this signal is to update the cursor position in a statusbar.

#### Parameters

buffer | the TeplBuffer emitting the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 2.0