## GtefBuffer GtefBuffer — Stores the text for display in a GtefView |

## Functions

GtefBuffer * | gtef_buffer_new ()
GtefFile * | gtef_buffer_get_file ()
gboolean | gtef_buffer_is_untouched ()
gchar * | gtef_buffer_get_title ()
gchar * | gtef_buffer_get_style_scheme_id ()
void | gtef_buffer_set_style_scheme_id ()
GtefSelectionType | gtef_buffer_get_selection_type ()

## Properties

gchar * | gtef-style-scheme-id | Read / Write
gchar * | gtef-title | Read

## Signals

void | gtef-cursor-moved | Run First

## Types and Values

| GtefBuffer
enum | GtefSelectionType

## Object Hierarchy

        GEnum
        ╰── GtefSelectionType
        GObject
        ╰── GtkTextBuffer
            ╰── GtkSourceBuffer
                ╰── GtefBuffer

## Includes

    #include <gtef/gtef.h>

## Description

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

It also adds an association to a GtefFile that can be retrieved with `gtef_buffer_get_file()`. The association cannot change.

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

## Functions

### gtef_buffer_new ()

    GtefBuffer *
    gtef_buffer_new (void);

#### Returns

a new GtefBuffer.

Since: 1.0

### gtef_buffer_get_file ()

    GtefFile *
    gtef_buffer_get_file (GtefBuffer *buffer);

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

#### Parameters

buffer | a GtefBuffer. |

#### Returns

the associated GtefFile.

[transfer none]

Since: 1.0

### gtef_buffer_is_untouched ()

    gboolean
    gtef_buffer_is_untouched (GtefBuffer *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 GtefBuffer. |

#### Returns

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

Since: 1.0

### gtef_buffer_get_title ()

    gchar *
    gtef_buffer_get_title (GtefBuffer *buffer);

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

- '*' if the buffer is modified;

- the “short-name”;

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

#### Parameters

buffer | a GtefBuffer. |

#### Returns

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

Since: 1.0

### gtef_buffer_get_style_scheme_id ()

    gchar *
    gtef_buffer_get_style_scheme_id (GtefBuffer *buffer);

#### Parameters

buffer | a GtefBuffer. |

#### Returns

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

Since: 2.0

### gtef_buffer_set_style_scheme_id ()

    void
    gtef_buffer_set_style_scheme_id (GtefBuffer *buffer,
                                     const gchar *style_scheme_id);

Sets the “gtef-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 GtefBuffer. |
style_scheme_id | the new value. |

Since: 2.0

### gtef_buffer_get_selection_type ()

    GtefSelectionType
    gtef_buffer_get_selection_type (GtefBuffer *buffer);

#### Parameters

buffer | a GtefBuffer. |

#### Returns

the current GtefSelectionType.

Since: 1.0

## Types and Values

### GtefBuffer

    typedef struct _GtefBuffer GtefBuffer;

### enum GtefSelectionType

#### Members

GTEF_SELECTION_TYPE_NO_SELECTION | No selection. |
GTEF_SELECTION_TYPE_ON_SAME_LINE | The start and end selection bounds are on the same line. |
GTEF_SELECTION_TYPE_MULTIPLE_LINES | The selection spans multiple lines. |

Since: 1.0

## Property Details

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

      “gtef-style-scheme-id”     gchar *

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

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

Flags: Read / Write

Default value: ""

Since: 2.0

### The `“gtef-title”` property

      “gtef-title”               gchar *

The buffer title. See `gtef_buffer_get_title()`.

Flags: Read

Default value: NULL

Since: 2.0

## Signal Details

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

    void
    user_function (GtefBuffer *buffer,
                   gpointer    user_data)

The ::gtef-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 GtefBuffer emitting the signal. |
user_data | user data set when the signal handler was connected. |

Flags: Run First

Since: 2.0