IdeBuffer

IdeBuffer

Functions

void ide_buffer_format_selection_async ()
gboolean ide_buffer_format_selection_finish ()
gboolean ide_buffer_get_busy ()
gboolean ide_buffer_get_changed_on_volume ()
gsize ide_buffer_get_change_count ()
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_spell_checking ()
gboolean ide_buffer_get_highlight_diagnostics ()
gboolean ide_buffer_get_loading ()
const gchar * ide_buffer_get_style_scheme_name ()
const gchar * ide_buffer_get_title ()
gchar * ide_buffer_get_uri ()
void ide_buffer_set_file ()
void ide_buffer_set_highlight_diagnostics ()
void ide_buffer_set_spell_checking ()
void ide_buffer_set_style_scheme_name ()
void ide_buffer_trim_trailing_whitespace ()
void ide_buffer_check_for_volume_change ()
IdeSourceLocation * ide_buffer_get_insert_location ()
IdeSourceLocation * ide_buffer_get_iter_location ()
void ide_buffer_get_iter_at_source_location ()
void ide_buffer_rehighlight ()
void ide_buffer_get_selection_bounds ()
IdeRenameProvider * ide_buffer_get_rename_provider ()
IdeExtensionSetAdapter * ide_buffer_get_symbol_resolvers ()
void ide_buffer_get_symbol_at_location_async ()
IdeSymbol * ide_buffer_get_symbol_at_location_finish ()
void ide_buffer_hold ()
void ide_buffer_release ()
gchar * ide_buffer_get_word_at_iter ()
void ide_buffer_sync_to_unsaved_files ()
gboolean ide_buffer_get_failed ()
const GError * ide_buffer_get_failure ()
gboolean ide_buffer_get_has_diagnostics ()
void ide_buffer_get_build_flags_async ()
gchar ** ide_buffer_get_build_flags_finish ()
const gchar * ide_buffer_get_language_id ()

Properties

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

Signals

void change-settled Run Last
void cursor-moved Run Last
void destroy Run Last
void line-flags-changed Run Last
void loaded Run Last
void saved Run Last
void symbol-resolvers-loaded Run Last

Types and Values

Object Hierarchy

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

Description

Functions

ide_buffer_format_selection_async ()

void
ide_buffer_format_selection_async (IdeBuffer *self,
                                   IdeFormatterOptions *options,
                                   GCancellable *cancellable,
                                   GAsyncReadyCallback callback,
                                   gpointer user_data);

ide_buffer_format_selection_finish ()

gboolean
ide_buffer_format_selection_finish (IdeBuffer *self,
                                    GAsyncResult *result,
                                    GError **error);

ide_buffer_get_busy ()

gboolean
ide_buffer_get_busy (IdeBuffer *self);

Gets the “busy” property. Return whether the buffer is performing background work or not.

Parameters

self

an IdeBuffer.

 

Returns

TRUE if the IdeBuffer is performing background work. Otherwise FALSE.


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

an IdeBuffer.

 

Returns

TRUE if the file has changed.


ide_buffer_get_change_count ()

gsize
ide_buffer_get_change_count (IdeBuffer *self);

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.

Parameters

self

an IdeBuffer.

 

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.

Parameters

self

an IdeBuffer.

 

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

Parameters

self

an IdeBuffer.

 

iter

a GtkTextIter.

 

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.

Parameters

self

an IdeBuffer.

 

Returns

An IdeFile.

[transfer none]


ide_buffer_get_line_flags ()

IdeBufferLineFlags
ide_buffer_get_line_flags (IdeBuffer *self,
                           guint line);

Return the flags set for the IdeBuffer line number. (diagnostics and errors messages, line changed or added, notes)

Parameters

self

an IdeBuffer.

 

line

a buffer line number.

 

Returns

An IdeBufferLineFlags struct.

[transfer full]


ide_buffer_get_read_only ()

gboolean
ide_buffer_get_read_only (IdeBuffer *self);

Gets the “read-only” property. This property indicate if the underlying file is read only or not.

Parameters

self

an IdeBuffer.

 

Returns

TRUE if the IdeBuffer is read only. Otherwise FALSE.


ide_buffer_get_spell_checking ()

gboolean
ide_buffer_get_spell_checking (IdeBuffer *self);

ide_buffer_get_highlight_diagnostics ()

gboolean
ide_buffer_get_highlight_diagnostics (IdeBuffer *self);

Gets the “highlight-diagnostics” property. Return whether the diagnostic warnings and errors should be highlighted.

Parameters

self

an IdeBuffer.

 

Returns

TRUE if diagnostics are highlighted. Otherwise FALSE.


ide_buffer_get_loading ()

gboolean
ide_buffer_get_loading (IdeBuffer *self);

ide_buffer_get_style_scheme_name ()

const gchar *
ide_buffer_get_style_scheme_name (IdeBuffer *self);

Gets the “style-scheme-name” property. This property contains the current style scheme used by the buffer.

Parameters

self

an IdeBuffer.

 

Returns

A string containing the name of the currently used style scheme.

[transfer none]


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.

Parameters

self

an IdeBuffer.

 

Returns

A string containing the buffer title.


ide_buffer_get_uri ()

gchar *
ide_buffer_get_uri (IdeBuffer *self);

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 from storage.

Parameters

self

an IdeBuffer.

 

file

An IdeFile.

 

ide_buffer_set_highlight_diagnostics ()

void
ide_buffer_set_highlight_diagnostics (IdeBuffer *self,
                                      gboolean highlight_diagnostics);

Sets the “highlight-diagnostics” property. Sets whether the diagnostic warnings and errors should be highlighted.

Parameters

self

an IdeBuffer.

 

highlight_diagnostics

Whether to highlight the diagnostics or not.

 

ide_buffer_set_spell_checking ()

void
ide_buffer_set_spell_checking (IdeBuffer *self,
                               gboolean enable);

ide_buffer_set_style_scheme_name ()

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

Sets the “style-scheme-name” property. Sets the style scheme to be used by this buffer.

Parameters

self

an IdeBuffer.

 

style_scheme_name

A string containing the name of the style scheme to use.

 

ide_buffer_trim_trailing_whitespace ()

void
ide_buffer_trim_trailing_whitespace (IdeBuffer *self);

Trim trailing whitespaces from the buffer.

Parameters

self

an IdeBuffer.

 

ide_buffer_check_for_volume_change ()

void
ide_buffer_check_for_volume_change (IdeBuffer *self);

Update the “read-only” property and the corresponding modification time (mtime).

Parameters

self

an IdeBuffer.

 

ide_buffer_get_insert_location ()

IdeSourceLocation *
ide_buffer_get_insert_location (IdeBuffer *self);

Gets the location of the insert mark as an IdeSourceLocation.

Returns

An IdeSourceLocation.

[transfer full]


ide_buffer_get_iter_location ()

IdeSourceLocation *
ide_buffer_get_iter_location (IdeBuffer *self,
                              const GtkTextIter *iter);

Gets the location of the iter as an IdeSourceLocation.

Returns

An IdeSourceLocation.

[transfer full]


ide_buffer_get_iter_at_source_location ()

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

Fill iter with the position designated by location .

Parameters

self

an IdeBuffer.

 

iter

a GtkTextIter.

[out]

location

a IdeSourceLocation.

 

ide_buffer_rehighlight ()

void
ide_buffer_rehighlight (IdeBuffer *self);

Force the IdeBuffer to rebuild the highlight.

Parameters

self

an IdeBuffer.

 

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().

Parameters

self

an IdeBuffer.

 

insert

a GtkTextIter to get the insert position.

[out]

selection

a GtkTextIter to get the selection position.

[out]

ide_buffer_get_rename_provider ()

IdeRenameProvider *
ide_buffer_get_rename_provider (IdeBuffer *self);

Gets the IdeRenameProvider for this buffer, or NULL.

Returns

An IdeRenameProvider or NULL if there is no IdeRenameProvider that can statisfy the buffer.

[nullable][transfer none]


ide_buffer_get_symbol_resolvers ()

IdeExtensionSetAdapter *
ide_buffer_get_symbol_resolvers (IdeBuffer *self);

Gets the symbol resolvers for the buffer based on the current language.

Parameters

self

an IdeBuffer.

 

Returns

An IdeExtensionSetAdapter or NULL.

[nullable][transfer none]


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);

Asynchronously get a possible symbol at location .

Parameters

self

an IdeBuffer.

 

location

a GtkTextIter indicating a position to search for a symbol.

 

cancellable

a GCancellable.

 

callback

a GAsyncReadyCallback.

 

user_data

a gpointer to hold 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.

Parameters

self

an IdeBuffer.

 

result

a GAsyncResult.

 

error

a GError.

[out]

Returns

An IdeSymbol or NULL.

[transfer full]


ide_buffer_hold ()

void
ide_buffer_hold (IdeBuffer *self);

ide_buffer_release ()

void
ide_buffer_release (IdeBuffer *self);

ide_buffer_get_word_at_iter ()

gchar *
ide_buffer_get_word_at_iter (IdeBuffer *self,
                             const GtkTextIter *iter);

Gets the word found under the position denoted by iter .

Parameters

self

an IdeBuffer.

 

iter

a GtkTextIter.

 

Returns

A newly allocated string.

[transfer full]


ide_buffer_sync_to_unsaved_files ()

void
ide_buffer_sync_to_unsaved_files (IdeBuffer *self);

ide_buffer_get_failed ()

gboolean
ide_buffer_get_failed (IdeBuffer *self);

ide_buffer_get_failure ()

const GError *
ide_buffer_get_failure (IdeBuffer *self);

ide_buffer_get_has_diagnostics ()

gboolean
ide_buffer_get_has_diagnostics (IdeBuffer *self);

Gets the “has-diagnostics” property. Return whether the buffer contains diagnostic messages or not.

Parameters

self

an IdeBuffer.

 

Returns

TRUE if the IdeBuffer has diagnostics messages. Otherwise FALSE.


ide_buffer_get_build_flags_async ()

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

ide_buffer_get_build_flags_finish ()

gchar **
ide_buffer_get_build_flags_finish (IdeBuffer *self,
                                   GAsyncResult *result,
                                   GError **error);

Completes a request to get the build flags for the buffer.

Parameters

self

a IdeBuffer

 

result

the result provided to callback

 

error

location for a GError, or NULL

 

Returns

an array of build flags.

[transfer full][array zero-terminated=1]

Since: 3.30


ide_buffer_get_language_id ()

const gchar *
ide_buffer_get_language_id (IdeBuffer *self);

A helper to get the language identifier of the buffers current language.

Parameters

self

a IdeBuffer

 

Returns

a string containing the language id, or NULL.

[nullable]

Types and Values

IDE_TYPE_BUFFER

#define IDE_TYPE_BUFFER (ide_buffer_get_type ())

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_DELETED

   

IDE_BUFFER_LINE_FLAGS_ERROR

   

IDE_BUFFER_LINE_FLAGS_WARNING

   

IDE_BUFFER_LINE_FLAGS_NOTE

   

struct IdeBufferClass

struct IdeBufferClass {
  GtkSourceBufferClass parent_class;

  void (*cursor_moved) (IdeBuffer         *self,
                        const GtkTextIter *location);
};

IdeBuffer

typedef struct _IdeBuffer IdeBuffer;

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 “failed” property

  “failed”                   gboolean

The "failed" property is set to TRUE if the buffer failed to load.

Flags: Read

Default value: FALSE

Since: 3.28


The “file” property

  “file”                     IdeFile *

The file represented by the buffer.

Flags: Read / Write


The “has-diagnostics” property

  “has-diagnostics”          gboolean

If the buffer contains diagnostic messages.

Flags: Read

Default value: FALSE


The “highlight-diagnostics” property

  “highlight-diagnostics”    gboolean

If diagnostic warnings and errors should be highlighted.

Flags: Read / Write

Default value: TRUE


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 “change-settled” signal

void
user_function (IdeBuffer *self,
               gpointer   user_data)

This signal is emitted as short period of time after changes have occurred. It provides plugins a convenient way to wait for the editor to settle before performing expensive work.

You should probably use this instead of implementing your own settling management.

Parameters

self

An IdeBuffer

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 3.26


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 “destroy” signal

void
user_function (IdeBuffer *idebuffer,
               gpointer   user_data)

This signal is emitted when the buffer should be destroyed, as the IdeBufferManager has reclaimed the buffer.

Parameters

user_data

user data set when the signal handler was connected.

 

Flags: Run Last


The “line-flags-changed” signal

void
user_function (IdeBuffer *idebuffer,
               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 *idebuffer,
               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 *idebuffer,
               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


The “symbol-resolvers-loaded” signal

void
user_function (IdeBuffer *idebuffer,
               gpointer   user_data)

Flags: Run Last