IdeBuffer: LibIDE Reference Manual

## IdeBuffer IdeBuffer |

## Functions

#define | IDE_BUFFER_CONST()
gboolean | ide_buffer_get_changed_on_volume ()
GBytes * | ide_buffer_get_content ()
IdeContext * | ide_buffer_get_context ()
IdeDiagnostic * | ide_buffer_get_diagnostic_at_iter ()
IdeFile * | ide_buffer_get_file ()
IdeBufferLineFlags | ide_buffer_get_line_flags ()
gboolean | ide_buffer_get_read_only ()
gboolean | ide_buffer_get_highlight_diagnostics ()
const gchar * | ide_buffer_get_style_scheme_name ()
const gchar * | ide_buffer_get_title ()
void | ide_buffer_set_file ()
void | ide_buffer_set_highlight_diagnostics ()
void | ide_buffer_set_style_scheme_name ()
void | ide_buffer_trim_trailing_whitespace ()
void | ide_buffer_check_for_volume_change ()
void | ide_buffer_get_iter_at_source_location ()
void | ide_buffer_rehighlight ()
void | ide_buffer_get_selection_bounds ()
void | ide_buffer_get_symbol_at_location_async ()
IdeSymbol * | ide_buffer_get_symbol_at_location_finish ()
void | ide_buffer_get_symbols_async ()
GPtrArray * | ide_buffer_get_symbols_finish ()
void | ide_buffer_hold ()
void | ide_buffer_release ()

## Properties

gboolean | busy | Read
gboolean | changed-on-volume | Read
IdeContext * | context | Read / Write / Construct Only
IdeFile * | file | Read / Write
gboolean | highlight-diagnostics | Read / Write
gboolean | read-only | Read
gchar * | style-scheme-name | Read / Write
gchar * | title | Read / Write

## Signals

void | cursor-moved | Run Last
void | line-flags-changed | Run Last
void | loaded | Run Last
void | saved | Run Last

## Types and Values

#define | IDE_BUFFER_LINE_FLAGS_DIAGNOSTICS_MASK
enum | IdeBufferLineFlags

## Object Hierarchy

        GFlags
        ╰── IdeBufferLineFlags
        GObject
        ╰── GtkTextBuffer
            ╰── GtkSourceBuffer
                ╰── IdeBuffer

## Description

## Functions

### IDE_BUFFER_CONST()

    #define IDE_BUFFER_CONST(obj)       (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_BUFFER, IdeBuffer const))

### ide_buffer_get_changed_on_volume ()

    gboolean
    ide_buffer_get_changed_on_volume (IdeBuffer *self);

Gets if the file backing the buffer has changed on the underlying storage.

Use `ide_buffer_manager_load_file_async()` to reload the buffer.

#### Parameters

self | A IdeBuffer. |

#### Returns

`TRUE` if the file has changed.

### ide_buffer_get_content ()

    GBytes *
    ide_buffer_get_content (IdeBuffer *self);

Gets the contents of the buffer as GBytes.

By using this function to get the bytes, you allow IdeBuffer to avoid calculating the buffer text unnecessarily, potentially saving on allocations.

Additionally, this allows the buffer to update the state in IdeUnsavedFiles if the content is out of sync.

#### Returns

A GBytes containing the buffer content.

[transfer full]

### ide_buffer_get_context ()

    IdeContext *
    ide_buffer_get_context (IdeBuffer *self);

Gets the “context” property. This is the IdeContext that owns the buffer.

#### Returns

An IdeContext.

[transfer none]

### ide_buffer_get_diagnostic_at_iter ()

    IdeDiagnostic *
    ide_buffer_get_diagnostic_at_iter (IdeBuffer *self,
                                       const GtkTextIter *iter);

Gets the first diagnostic that overlaps the position

#### Returns

An IdeDiagnostic or `NULL`.

[transfer none][nullable]

### ide_buffer_get_file ()

    IdeFile *
    ide_buffer_get_file (IdeBuffer *self);

Gets the underlying file behind the buffer.

#### Returns

An IdeFile.

[transfer none]

### ide_buffer_get_line_flags ()

    IdeBufferLineFlags
    ide_buffer_get_line_flags (IdeBuffer *buffer,
                               guint line);

### ide_buffer_get_read_only ()

    gboolean
    ide_buffer_get_read_only (IdeBuffer *self);

### ide_buffer_get_highlight_diagnostics ()

    gboolean
    ide_buffer_get_highlight_diagnostics (IdeBuffer *self);

### ide_buffer_get_style_scheme_name ()

    const gchar *
    ide_buffer_get_style_scheme_name (IdeBuffer *self);

### ide_buffer_get_title ()

    const gchar *
    ide_buffer_get_title (IdeBuffer *self);

Gets the “title” property. This property contains a title for the buffer suitable for display.

#### Returns

A string containing the buffer title.

### ide_buffer_set_file ()

    void
    ide_buffer_set_file (IdeBuffer *self,
                         IdeFile *file);

Sets the underlying file to use when saving and loading `self` to and and from storage.

### ide_buffer_set_highlight_diagnostics ()

    void
    ide_buffer_set_highlight_diagnostics (IdeBuffer *self,
                                          gboolean highlight_diagnostics);

### ide_buffer_set_style_scheme_name ()

    void
    ide_buffer_set_style_scheme_name (IdeBuffer *self,
                                      const gchar *style_scheme_name);

### ide_buffer_trim_trailing_whitespace ()

    void
    ide_buffer_trim_trailing_whitespace (IdeBuffer *self);

### ide_buffer_check_for_volume_change ()

    void
    ide_buffer_check_for_volume_change (IdeBuffer *self);

### ide_buffer_get_iter_at_source_location ()

    void
    ide_buffer_get_iter_at_source_location
                                   (IdeBuffer *self,
                                    GtkTextIter *iter,
                                    IdeSourceLocation *location);

### ide_buffer_rehighlight ()

    void
    ide_buffer_rehighlight (IdeBuffer *self);

### ide_buffer_get_selection_bounds ()

    void
    ide_buffer_get_selection_bounds (IdeBuffer *self,
                                     GtkTextIter *insert,
                                     GtkTextIter *selection);

This function acts like `gtk_text_buffer_get_selection_bounds()` except that it always places the location of the insert mark at `insert` and the location of the selection mark at `selection` .

Calling `gtk_text_iter_order()` with the results of this function would be equivalent to calling `gtk_text_buffer_get_selection_bounds()`.

### ide_buffer_get_symbol_at_location_async ()

    void
    ide_buffer_get_symbol_at_location_async
                                   (IdeBuffer *self,
                                    const GtkTextIter *location,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

### ide_buffer_get_symbol_at_location_finish ()

    IdeSymbol *
    ide_buffer_get_symbol_at_location_finish
                                   (IdeBuffer *self,
                                    GAsyncResult *result,
                                    GError **error);

Completes an asynchronous request to locate a symbol at a location.

#### Returns

An IdeSymbol or `NULL`.

[transfer full]

### ide_buffer_get_symbols_async ()

    void
    ide_buffer_get_symbols_async (IdeBuffer *self,
                                  GCancellable *cancellable,
                                  GAsyncReadyCallback callback,
                                  gpointer user_data);

### ide_buffer_get_symbols_finish ()

    GPtrArray *
    ide_buffer_get_symbols_finish (IdeBuffer *self,
                                   GAsyncResult *result,
                                   GError **error);

#### Returns

A GPtrArray if successful; otherwise `NULL`.

[transfer container][element-type IdeSymbol*]

### ide_buffer_hold ()

    void
    ide_buffer_hold (IdeBuffer *self);

### ide_buffer_release ()

    void
    ide_buffer_release (IdeBuffer *self);

## Types and Values

### IDE_BUFFER_LINE_FLAGS_DIAGNOSTICS_MASK

    #define             IDE_BUFFER_LINE_FLAGS_DIAGNOSTICS_MASK

### enum IdeBufferLineFlags

#### Members

IDE_BUFFER_LINE_FLAGS_NONE |  |
IDE_BUFFER_LINE_FLAGS_ADDED |  |
IDE_BUFFER_LINE_FLAGS_CHANGED |  |
IDE_BUFFER_LINE_FLAGS_ERROR |  |
IDE_BUFFER_LINE_FLAGS_WARNING |  |
IDE_BUFFER_LINE_FLAGS_NOTE |  |

## Property Details

### The `“busy”` property

      “busy”                     gboolean

If the buffer is performing background work.

Flags: Read

Default value: FALSE

### The `“changed-on-volume”` property

      “changed-on-volume”        gboolean

If the file has changed on disk and the buffer is not in sync.

Flags: Read

Default value: FALSE

### The `“context”` property

      “context”                  IdeContext *

The IdeContext for the buffer.

Flags: Read / Write / Construct Only

### The `“file”` property

      “file”                     IdeFile *

The file represented by the buffer.

Flags: Read / Write

### The `“highlight-diagnostics”` property

      “highlight-diagnostics”    gboolean

If diagnostic warnings and errors should be highlighted.

Flags: Read / Write

Default value: FALSE

### The `“read-only”` property

      “read-only”                gboolean

If the underlying file is read only.

Flags: Read

Default value: FALSE

### The `“style-scheme-name”` property

      “style-scheme-name”        gchar *

Style Scheme Name.

Flags: Read / Write

Default value: NULL

### The `“title”` property

      “title”                    gchar *

The title of the buffer.

Flags: Read / Write

Default value: NULL

## Signal Details

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

    void
    user_function (IdeBuffer   *self,
                   GtkTextIter *location,
                   gpointer     user_data)

This signal is emitted when the insertion location has moved. You might want to attach to this signal to update the location of the insert mark in the display.

#### Parameters

self | An IdeBuffer. |
location | A GtkTextIter. |
user_data | user data set when the signal handler was connected. |

Flags: Run Last

### The `“line-flags-changed”` signal

    void
    user_function (IdeBuffer *arg0,
                   gpointer   user_data)

This signal is emitted when the calculated line flags have changed. This occurs when diagnostics and line changes have been recalculated.

#### Parameters

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

Flags: Run Last

### The `“loaded”` signal

    void
    user_function (IdeBuffer *arg0,
                   gpointer   user_data)

This signal is emitted when the buffer manager has completed loading the file.

#### Parameters

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

Flags: Run Last

### The `“saved”` signal

    void
    user_function (IdeBuffer *arg0,
                   gpointer   user_data)

This signal is emitted when the buffer manager has completed saving the file.

#### Parameters

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

Flags: Run Last