Stores text and attributes for display in a `GtkTextView`.
You may wish to begin by reading the [text widget conceptual overview](section-text-widget.html), which gives an overview of all the
objects and data types related to the text widget and how they work together.
GtkTextBuffer can support undoing changes to the buffer content, see [[email protected]_enable_undo].
- public void @delete (ref TextIter start, ref TextIter end)
Deletes text between start
and end
.
- public void add_mark (TextMark mark, TextIter where)
Adds the mark at position where
.
- public void add_selection_clipboard (Clipboard clipboard)
Adds clipboard
to the list of clipboards in which the
selection contents of this are available.
- public void apply_tag_by_name (string name, TextIter start, TextIter end)
Emits the “apply-tag” signal on this
.
- public bool backspace (ref TextIter iter, bool interactive, bool default_editable)
Performs the appropriate action as if the user hit the delete key with
the cursor at the position specified by iter
.
- public void begin_irreversible_action ()
Denotes the beginning of an action that may not be undone.
- public void copy_clipboard (Clipboard clipboard)
Copies the currently-selected text to a clipboard.
- public unowned TextChildAnchor create_child_anchor (TextIter iter)
Creates and inserts a child anchor.
- public unowned TextMark create_mark (string? mark_name, TextIter where, bool left_gravity)
Creates a mark at position where
.
- public unowned TextTag create_tag (string? tag_name, ...)
Creates a tag and adds it to the tag table for
this.
- public void cut_clipboard (Clipboard clipboard, bool default_editable)
Copies the currently-selected text to a clipboard, then deletes said
text if it’s editable.
- public bool delete_interactive (ref TextIter start_iter, ref TextIter end_iter, bool default_editable)
Deletes all editable text in the given range.
- public void delete_mark (TextMark mark)
Deletes mark
, so that it’s no longer located anywhere
in the buffer.
- public void delete_mark_by_name (string name)
Deletes the mark named name
; the mark must exist.
- public bool delete_selection (bool interactive, bool default_editable)
Deletes the range between the “insert” and “selection_bound”
marks, that is, the currently-selected text.
- public void end_irreversible_action ()
Denotes the end of an action that may not be undone.
- public void get_bounds (out TextIter start, out TextIter end)
Retrieves the first and last iterators in the buffer, i.
- public bool get_can_redo ()
Gets whether there is a redoable action in the history.
- public bool get_can_undo ()
Gets whether there is an undoable action in the history.
- public int get_char_count ()
Gets the number of characters in the buffer.
- public bool get_enable_undo ()
Gets whether the buffer is saving modifications to the buffer to allow
for undo and redo actions.
- public void get_end_iter (out TextIter iter)
Initializes iter
with the “end iterator,” one past
the last valid character in the text buffer.
- public bool get_has_selection ()
Indicates whether the buffer has some text currently selected.
- public unowned TextMark get_insert ()
Returns the mark that represents the cursor (insertion point).
- public void get_iter_at_child_anchor (out TextIter iter, TextChildAnchor anchor)
Obtains the location of anchor
within
this.
- public bool get_iter_at_line (out TextIter iter, int line_number)
Initializes iter
to the start of the given line.
- public bool get_iter_at_line_index (out TextIter iter, int line_number, int byte_index)
Obtains an iterator pointing to byte_index
within the
given line.
- public bool get_iter_at_line_offset (out TextIter iter, int line_number, int char_offset)
Obtains an iterator pointing to char_offset
within the
given line.
- public void get_iter_at_mark (out TextIter iter, TextMark mark)
Initializes iter
with the current position of mark
.
- public void get_iter_at_offset (out TextIter iter, int char_offset)
Initializes iter
to a position char_offset
chars from the start of the entire buffer.
- public int get_line_count ()
Obtains the number of lines in the buffer.
- public unowned TextMark? get_mark (string name)
Returns the mark named name
in buffer
this, or null if no such mark exists in the buffer.
- public uint get_max_undo_levels ()
Gets the maximum number of undo levels to perform.
- public bool get_modified ()
Indicates whether the buffer has been modified since the last call to
[method@Gtk.
- public unowned TextMark get_selection_bound ()
Returns the mark that represents the selection bound.
- public bool get_selection_bounds (out TextIter start, out TextIter end)
Returns true if some text is
selected; places the bounds of the selection in start
and end
.
- public ContentProvider get_selection_content ()
Get a content provider for this buffer.
- public string get_slice (TextIter start, TextIter end, bool include_hidden_chars)
Returns the text in the range [start
,end
).
- public void get_start_iter (out TextIter iter)
Initialized iter
with the first position in the text
buffer.
- public unowned TextTagTable get_tag_table ()
Get the `GtkTextTagTable` associated with this buffer.
- public string get_text (TextIter start, TextIter end, bool include_hidden_chars)
Returns the text in the range [start
,end
).
- public void insert (ref TextIter iter, string text, int len)
Inserts len
bytes of text
at position
iter
.
- public void insert_at_cursor (string text, int len)
Inserts text
in this.
- public bool insert_interactive (ref TextIter iter, string text, int len, bool default_editable)
Inserts text
in this.
- public bool insert_interactive_at_cursor (string text, int len, bool default_editable)
Inserts text
in this.
- public void insert_markup (ref TextIter iter, string markup, int len)
Inserts the text in markup
at position iter
.
- public void insert_range (ref TextIter iter, TextIter start, TextIter end)
Copies text, tags, and paintables between start
and
end
and inserts the copy at iter
.
- public bool insert_range_interactive (ref TextIter iter, TextIter start, TextIter end, bool default_editable)
Copies text, tags, and paintables between start
and
end
and inserts the copy at iter
.
- public void insert_with_tags (ref TextIter iter, string text, int len, ...)
Inserts text
into this
at iter
, applying the list of tags to the newly-inserted text.
- public void insert_with_tags_by_name (ref TextIter iter, string text, int len, ...)
Inserts text
into this
at iter
, applying the list of tags to the newly-inserted text.
- public void move_mark (TextMark mark, TextIter where)
Moves mark
to the new location where
.
- public void move_mark_by_name (string name, TextIter where)
Moves the mark named name
(which must exist) to location
where
.
- public void paste_clipboard (Clipboard clipboard, TextIter? override_location, bool default_editable)
Pastes the contents of a clipboard.
- public void place_cursor (TextIter where)
This function moves the “insert” and “selection_bound” marks
simultaneously.
- public void remove_all_tags (TextIter start, TextIter end)
Removes all tags in the range between start
and end
.
- public void remove_selection_clipboard (Clipboard clipboard)
- public void remove_tag_by_name (string name, TextIter start, TextIter end)
Emits the “remove-tag” signal.
- public void select_range (TextIter ins, TextIter bound)
This function moves the “insert” and “selection_bound” marks
simultaneously.
- public void set_enable_undo (bool enable_undo)
Sets whether or not to enable undoable actions in the text buffer.
- public void set_max_undo_levels (uint max_undo_levels)
Sets the maximum number of undo levels to perform.
- public void set_modified (bool setting)
Used to keep track of whether the buffer has been modified since the
last time it was saved.
- public void set_text (string text, int len = -1)
Deletes current contents of this,
and inserts text
instead.
- public virtual signal void apply_tag (TextTag tag, TextIter start, TextIter end)
Emitted to apply a tag to a range of text in a `GtkTextBuffer`.
- public virtual signal void begin_user_action ()
Emitted at the beginning of a single user-visible operation on a
`GtkTextBuffer`.
- public virtual signal void changed ()
Emitted when the content of a `GtkTextBuffer` has changed.
- public virtual signal void delete_range (TextIter start, TextIter end)
Emitted to delete a range from a `GtkTextBuffer`.
- public virtual signal void end_user_action ()
Emitted at the end of a single user-visible operation on the
`GtkTextBuffer`.
- public virtual signal void insert_child_anchor (TextIter iter, TextChildAnchor anchor)
Emitted to insert a `GtkTextChildAnchor` in a `GtkTextBuffer`.
- public virtual signal void insert_paintable (TextIter iter, Paintable paintable)
Emitted to insert a `GdkPaintable` in a `GtkTextBuffer`.
- public virtual signal void insert_text (ref TextIter pos, string new_text, int new_text_length)
Emitted to insert text in a `GtkTextBuffer`.
- public virtual signal void mark_deleted (TextMark mark)
Emitted as notification after a `GtkTextMark` is deleted.
- public virtual signal void mark_set (TextIter location, TextMark mark)
Emitted as notification after a `GtkTextMark` is set.
- public virtual signal void modified_changed ()
Emitted when the modified bit of a `GtkTextBuffer` flips.
- public virtual signal void paste_done (Clipboard clipboard)
Emitted after paste operation has been completed.
- public virtual signal void redo ()
Emitted when a request has been made to redo the previously undone
operation.
- public virtual signal void remove_tag (TextTag tag, TextIter start, TextIter end)
Emitted to remove all occurrences of tag
from a range of
text in a `GtkTextBuffer`.
- public virtual signal void undo ()
Emitted when a request has been made to undo the previous operation or
set of operations that have been grouped together.