gtkmm: Gtk::TextBuffer Class Reference

gtkmm 4.23.2

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Symbols | List of all members
Gtk::TextBuffer Class Reference
TextView Classes

Multi-line attributed text that can be displayed by one or more Gtk::TextView widgets. More...

`#include <gtkmm/textbuffer.h>`

Inheritance diagram for Gtk::TextBuffer:
[legend]

## Public Types
enum class | NotifyFlags { NotifyFlags::BEFORE_INSERT = 1 << 0 , NotifyFlags::AFTER_INSERT = 1 << 1 , NotifyFlags::BEFORE_DELETE = 1 << 2 , NotifyFlags::AFTER_DELETE = 1 << 3 }
| Values for [callb.nosp@m.ack@.nosp@m.Gtk.T.nosp@m.extB.nosp@m.uffer.nosp@m.Comm.nosp@m.itNot.nosp@m.ify] to denote the point of the notification. More...
typedef TextIter | iterator
typedef TextConstIter | const_iterator
typedef TextTag | Tag
typedef TextTagTable | TagTable
typedef TextMark | Mark
typedef TextChildAnchor | ChildAnchor
using | SlotCommitNotify = sigc::slot<void(NotifyFlags, guint, guint)>
| A notification callback used by add_commit_notify().
Public Types inherited from Glib::Object
typedef void(*)(gpointer data | DestroyNotify)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify | func_destroy_notify

## Public Member Functions
| TextBuffer (TextBuffer && src) noexcept
TextBuffer & | operator= (TextBuffer && src) noexcept
| ~TextBuffer () noexcept override
GtkTextBuffer * | gobj ()
| Provides access to the underlying C GObject.
const GtkTextBuffer * | gobj () const
| Provides access to the underlying C GObject.
GtkTextBuffer * | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
int | get_line_count () const
| Obtains the number of lines in the buffer.
int | get_char_count () const
| Gets the number of characters in the buffer.
int | size () const
| See get_char_count().
Glib::RefPtr< TextBuffer::TagTable > | get_tag_table ()
| Get the Gtk::TextTagTable associated with this buffer.
Glib::RefPtr< const TextBuffer::TagTable > | get_tag_table () const
| Get the Gtk::TextTagTable associated with this buffer.
void | set_text (const Glib::ustring & text)
| Removes the current contents of the buffer, and inserts text instead.
void | set_text (const char * text_begin, const char * text_end)
| Removes the current contents of the buffer, and inserts text instead.
iterator | insert (const iterator & pos, const Glib::ustring & text)
| Inserts text at position pos.
iterator | insert (const iterator & pos, const char * text_begin, const char * text_end)
| Inserts text at position pos.
void | insert_at_cursor (const Glib::ustring & text)
| Inserts text, using the current cursor position as the insertion point.
void | insert_at_cursor (const char * text_begin, const char * text_end)
| Inserts text, using the current cursor position as the insertion point.
std::pair< iterator, bool > | insert_interactive (const iterator & pos, const Glib::ustring & text, bool default_editable=true)
| Like insert(), but the insertion will not occur if iter is at a non-editable location in the buffer.
std::pair< iterator, bool > | insert_interactive (const iterator & pos, const char * text_begin, const char * text_end, bool default_editable=true)
| Like insert(), but the insertion will not occur if pos is at a non-editable location in the buffer.
bool | insert_interactive_at_cursor (const Glib::ustring & text, bool default_editable=true)
| Calls insert_interactive() at the cursor position.
bool | insert_interactive_at_cursor (const char * text_begin, const char * text_end, bool default_editable=true)
| Calls insert_interactive() at the cursor position.
iterator | insert (const iterator & pos, const const_iterator & range_begin, const const_iterator & range_end)
| Copies text, tags, and paintable between range_begin and range_end (the order of range_begin and range_begin doesn't matter) and inserts the copy at pos.
std::pair< iterator, bool > | insert_interactive (const iterator & pos, const const_iterator & range_begin, const const_iterator & range_end, bool default_editable=true)
| Same as insert_range(), but does nothing if the insertion point isn't editable.
iterator | insert_with_tag (const iterator & pos, const Glib::ustring & text, const Glib::RefPtr< Tag > & tag)
iterator | insert_with_tag (const iterator & pos, const char * text_begin, const char * text_end, const Glib::RefPtr< Tag > & tag)
iterator | insert_with_tag (const iterator & pos, const Glib::ustring & text, const Glib::ustring & tag_name)
iterator | insert_with_tag (const iterator & pos, const char * text_begin, const char * text_end, const Glib::ustring & tag_name)
iterator | insert_with_tags (const iterator & pos, const Glib::ustring & text, const std::vector< Glib::RefPtr< Tag > > & tags)
| Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.
iterator | insert_with_tags (const iterator & pos, const char * text_begin, const char * text_end, const std::vector< Glib::RefPtr< Tag > > & tags)
| Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.
iterator | insert_with_tags_by_name (const iterator & pos, const Glib::ustring & text, const std::vector< Glib::ustring > & tag_names)
| Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.
iterator | insert_with_tags_by_name (const iterator & pos, const char * text_begin, const char * text_end, const std::vector< Glib::ustring > & tag_names)
| Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function.
iterator | insert_markup (const iterator & pos, const Glib::ustring & markup)
| Inserts text in markup at position pos.
iterator | insert_markup (const iterator & pos, const char * markup_begin, const char * markup_end)
| Inserts markup text at position pos.
iterator | erase (const iterator & range_begin, const iterator & range_end)
std::pair< iterator, bool > | erase_interactive (const iterator & range_begin, const iterator & range_end, bool default_editable=true)
iterator | backspace (const iterator & iter, bool interactive=true, bool default_editable=true)
| Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter.
Glib::ustring | get_text (const const_iterator & range_start, const const_iterator & range_end, bool include_hidden_chars=true) const
| Returns the text in the range [ range_start, range_end).
Glib::ustring | get_text (bool include_hidden_chars=true) const
| Returns all the text in the buffer.
Glib::ustring | get_slice (const const_iterator & range_start, const const_iterator & range_end, bool include_hidden_chars=true) const
| Returns the text in the range [ range_start, range_end).
iterator | insert_paintable (const iterator & pos, const Glib::RefPtr< Gdk::Paintable > & paintable)
iterator | insert_child_anchor (const iterator & pos, const Glib::RefPtr< ChildAnchor > & anchor)
Glib::RefPtr< ChildAnchor > | create_child_anchor (const iterator & pos)
void | add_mark (const Glib::RefPtr< TextBuffer::Mark > & mark, const iterator & where)
| Adds the mark at position where.
Glib::RefPtr< TextBuffer::Mark > | create_mark (const Glib::ustring & mark_name, const iterator & where, bool left_gravity=true)
| Creates a mark at position where.
Glib::RefPtr< Mark > | create_mark (const iterator & where, bool left_gravity=true)
| Create an anonymous mark.
void | move_mark (const Glib::RefPtr< Mark > & mark, const iterator & where)
| Moves mark to the new location where.
void | delete_mark (const Glib::RefPtr< Mark > & mark)
| Deletes mark, so that it's no longer located anywhere in the buffer.
Glib::RefPtr< TextBuffer::Mark > | get_mark (const Glib::ustring & name)
| Returns the mark named name in buffer buffer, or nullptr if no such mark exists in the buffer.
Glib::RefPtr< const TextBuffer::Mark > | get_mark (const Glib::ustring & name) const
| Returns the mark named name in buffer buffer, or nullptr if no such mark exists in the buffer.
void | move_mark_by_name (const Glib::ustring & name, const iterator & where)
| Moves the mark named name (which must exist) to location where.
void | delete_mark_by_name (const Glib::ustring & name)
| Deletes the mark named name; the mark must exist.
Glib::RefPtr< TextBuffer::Mark > | get_insert ()
| Returns the mark that represents the cursor (insertion point).
Glib::RefPtr< TextBuffer::Mark > | get_selection_bound ()
| Returns the mark that represents the selection bound.
void | place_cursor (const iterator & where)
| This function moves the “insert” and “selection_bound” marks simultaneously.
void | apply_tag (const Glib::RefPtr< Tag > & tag, const iterator & range_start, const iterator & range_end)
| Emits the “apply-tag” signal on buffer.
void | remove_tag (const Glib::RefPtr< Tag > & tag, const iterator & range_start, const iterator & range_end)
| Emits the “remove-tag” signal.
void | apply_tag_by_name (const Glib::ustring & name, const iterator & range_start, const iterator & range_end)
| Emits the “apply-tag” signal on buffer.
void | remove_tag_by_name (const Glib::ustring & name, const iterator & range_start, const iterator & range_end)
| Emits the “remove-tag” signal.
void | remove_all_tags (const iterator & range_start, const iterator & range_end)
| Removes all tags in the range between range_start and range_end.
Glib::RefPtr< Tag > | create_tag (const Glib::ustring & tag_name)
| Creates a tag and adds it to the tag table for buffer.
Glib::RefPtr< Tag > | create_tag ()
| Creates an anoymous tag and adds it to the tag table for buffer.
iterator | get_iter_at_line_offset (int line_number, int char_offset)
const_iterator | get_iter_at_line_offset (int line_number, int char_offset) const
iterator | get_iter_at_line_index (int line_number, int byte_index)
const_iterator | get_iter_at_line_index (int line_number, int byte_index) const
iterator | get_iter_at_offset (int char_offset)
const_iterator | get_iter_at_offset (int char_offset) const
iterator | get_iter_at_line (int line_number)
const_iterator | get_iter_at_line (int line_number) const
iterator | begin ()
const_iterator | begin () const
iterator | end ()
const_iterator | end () const
void | get_bounds (iterator & range_begin, iterator & range_end)
void | get_bounds (const_iterator & range_begin, const_iterator & range_end) const
iterator | get_iter_at_mark (const Glib::RefPtr< Mark > & mark)
| Get the current position of a mark.
const_iterator | get_iter_at_mark (const Glib::RefPtr< Mark > & mark) const
| Get the current position of a mark.
iterator | get_iter_at_child_anchor (const Glib::RefPtr< ChildAnchor > & anchor)
| Get the current position of an anchor.
const_iterator | get_iter_at_child_anchor (const Glib::RefPtr< ChildAnchor > & anchor) const
| Get the current position of an anchor.
bool | get_modified () const
| Indicates whether the buffer has been modified since the last call to set_modified() set the modification flag to false.
void | set_modified (bool setting=true)
| Used to keep track of whether the buffer has been modified since the last time it was saved.
bool | get_has_selection () const
| Indicates whether the buffer has some text currently selected.
void | add_selection_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard)
| Adds clipboard to the list of clipboards in which the selection contents of buffer are available.
void | remove_selection_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard)
| Removes a Gdk::Clipboard added with add_selection_clipboard().
void | cut_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard, bool default_editable=true)
| Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
void | copy_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard)
| Copies the currently-selected text to a clipboard.
void | paste_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard, const iterator & override_location, bool default_editable=true)
| Pastes the contents of a clipboard.
void | paste_clipboard (const Glib::RefPtr< Gdk::Clipboard > & clipboard, bool default_editable=true)
| A paste_clipboard() convenience overload.
bool | get_selection_bounds (iterator & range_start, iterator & range_end)
| Returns true if some text is selected; places the bounds of the selection in range_start and range_end.
bool | get_selection_bounds (const_iterator & range_start, const_iterator & range_end) const
| Returns true if some text is selected; places the bounds of the selection in range_start and range_end.
bool | erase_selection (bool interactive=true, bool default_editable=true)
| Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
Glib::RefPtr< Gdk::ContentProvider > | get_selection_content ()
| Get a content provider for this buffer.
void | select_range (const iterator & ins, const iterator & bound)
| This function moves the “insert” and “selection_bound” marks simultaneously.
bool | get_can_undo () const
| Gets whether there is an undoable action in the history.
bool | get_can_redo () const
| Gets whether there is a redoable action in the history.
bool | get_enable_undo () const
| Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
void | set_enable_undo (bool enable_undo=true)
| Sets whether or not to enable undoable actions in the text buffer.
guint | get_max_undo_levels () const
| Gets the maximum number of undo levels to perform.
void | set_max_undo_levels (guint max_undo_levels)
| Sets the maximum number of undo levels to perform.
void | undo ()
| Undoes the last undoable action on the buffer, if there is one.
void | redo ()
| Redoes the next redoable action on the buffer, if there is one.
void | begin_irreversible_action ()
| Denotes the beginning of an action that may not be undone.
void | end_irreversible_action ()
| Denotes the end of an action that may not be undone.
void | begin_user_action ()
| Called to indicate that the buffer operations between here and a call to end_user_action() are part of a single user-visible operation.
void | end_user_action ()
| Ends a user-visible operation.
guint | add_commit_notify (NotifyFlags flags, const SlotCommitNotify & slot)
| Adds a SlotCommitNotify to be called when a change is to be made to the Gtk::TextBuffer.
void | remove_commit_notify (guint commit_notify_handler)
| Removes the SlotCommitNotify handler previously registered with add_commit_notify().
Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::ustring &, int)> | signal_insert ()
Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::RefPtr< Gdk::Paintable > &)> | signal_insert_paintable ()
Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::RefPtr< ChildAnchor > &)> | signal_insert_child_anchor ()
Glib::SignalProxy< void(TextBuffer::iterator &, TextBuffer::iterator &)> | signal_erase ()
Glib::SignalProxy< void()> | signal_changed ()
Glib::SignalProxy< void()> | signal_modified_changed ()
Glib::SignalProxy< void(const TextBuffer::iterator &, const Glib::RefPtr< TextBuffer::Mark > &)> | signal_mark_set ()
Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Mark > &)> | signal_mark_deleted ()
Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Tag > &, const TextBuffer::iterator &, const TextBuffer::iterator &)> | signal_apply_tag ()
Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Tag > &, const TextBuffer::iterator &, const TextBuffer::iterator &)> | signal_remove_tag ()
Glib::SignalProxy< void()> | signal_begin_user_action ()
Glib::SignalProxy< void()> | signal_end_user_action ()
Glib::SignalProxy< void(const Glib::RefPtr< Gdk::Clipboard > &)> | signal_paste_done ()
Glib::SignalProxy< void()> | signal_redo ()
Glib::SignalProxy< void()> | signal_undo ()
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< TextBuffer::TagTable > > | property_tag_table () const
| The GtkTextTagTable for the buffer.
Glib::PropertyProxy< Glib::ustring > | property_text ()
| The text content of the buffer.
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_text () const
| The text content of the buffer.
Glib::PropertyProxy_ReadOnly< bool > | property_has_selection () const
| Whether the buffer has some text currently selected.
Glib::PropertyProxy_ReadOnly< int > | property_cursor_position () const
| The position of the insert mark.
Glib::PropertyProxy_ReadOnly< bool > | property_can_undo () const
| Denotes that the buffer can undo the last applied action.
Glib::PropertyProxy_ReadOnly< bool > | property_can_redo () const
| Denotes that the buffer can reapply the last undone action.
Glib::PropertyProxy< bool > | property_enable_undo ()
| Denotes if support for undoing and redoing changes to the buffer is allowed.
Glib::PropertyProxy_ReadOnly< bool > | property_enable_undo () const
| Denotes if support for undoing and redoing changes to the buffer is allowed.
Public Member Functions inherited from Glib::Object
| Object (const Object &)=delete
Object & | operator= (const Object &)=delete
| Object (Object &&src) noexcept
Object & | operator= (Object &&src) noexcept
void * | get_data (const QueryQuark &key)
void | set_data (const Quark &key, void *data)
void | set_data_with_c_callback (const Quark &key, void *data, GDestroyNotify notify)
void | set_data (const Quark &key, void *data, DestroyNotify notify)
void | remove_data (const QueryQuark &quark)
void * | steal_data (const QueryQuark &quark)
Glib::RefPtr< Glib::Object > | wrap (GObject *object, bool take_copy=false)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase &)=delete
ObjectBase & | operator= (const ObjectBase &)=delete
void | set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
void | get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
void | set_property (const Glib::ustring &property_name, const PropertyType &value)
void | get_property (const Glib::ustring &property_name, PropertyType &value) const
PropertyType | get_property (const Glib::ustring &property_name) const
sigc::connection | connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
sigc::connection | connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
void | freeze_notify ()
void | thaw_notify ()
virtual void | reference () const
virtual void | unreference () const
GObject * | gobj ()
const GObject * | gobj () const
GObject * | gobj_copy () const
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src) noexcept
| ~trackable ()
void | add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src) noexcept
void | remove_destroy_notify_callback (notifiable *data) const

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system.
static Glib::RefPtr< TextBuffer > | create ()
static Glib::RefPtr< TextBuffer > | create (const Glib::RefPtr< TagTable > & tag_table)

## Protected Member Functions
| TextBuffer ()
| TextBuffer (const Glib::RefPtr< TagTable > & tag_table)
virtual void | on_insert (TextBuffer::iterator & pos, const Glib::ustring & text, int bytes)
| This is a default handler for the signal signal_insert().
virtual void | on_insert_paintable (TextBuffer::iterator & pos, const Glib::RefPtr< Gdk::Paintable > & paintable)
| This is a default handler for the signal signal_insert_paintable().
virtual void | on_insert_child_anchor (TextBuffer::iterator & pos, const Glib::RefPtr< ChildAnchor > & anchor)
| This is a default handler for the signal signal_insert_child_anchor().
virtual void | on_erase (TextBuffer::iterator & range_start, TextBuffer::iterator & range_end)
| This is a default handler for the signal signal_erase().
virtual void | on_changed ()
| This is a default handler for the signal signal_changed().
virtual void | on_modified_changed ()
| This is a default handler for the signal signal_modified_changed().
virtual void | on_mark_set (const TextBuffer::iterator & location, const Glib::RefPtr< TextBuffer::Mark > & mark)
| This is a default handler for the signal signal_mark_set().
virtual void | on_mark_deleted (const Glib::RefPtr< TextBuffer::Mark > & mark)
| This is a default handler for the signal signal_mark_deleted().
virtual void | on_apply_tag (const Glib::RefPtr< TextBuffer::Tag > & tag, const TextBuffer::iterator & range_begin, const TextBuffer::iterator & range_end)
| This is a default handler for the signal signal_apply_tag().
virtual void | on_remove_tag (const Glib::RefPtr< TextBuffer::Tag > & tag, const TextBuffer::iterator & range_begin, const TextBuffer::iterator & range_end)
| This is a default handler for the signal signal_remove_tag().
virtual void | on_begin_user_action ()
| This is a default handler for the signal signal_begin_user_action().
virtual void | on_end_user_action ()
| This is a default handler for the signal signal_end_user_action().
virtual void | on_paste_done (const Glib::RefPtr< Gdk::Clipboard > & clipboard)
| This is a default handler for the signal signal_paste_done().
virtual void | on_redo ()
| This is a default handler for the signal signal_redo().
virtual void | on_undo ()
| This is a default handler for the signal signal_undo().
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams &construct_params)
| Object (GObject *castitem)
| ~Object () noexcept override
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| ObjectBase (const char *custom_type_name)
| ObjectBase (const std::type_info &custom_type_info)
| ObjectBase (ObjectBase &&src) noexcept
ObjectBase & | operator= (ObjectBase &&src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject *castitem)
void | initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)

## Related Symbols
(Note that these are not member symbols.)
Glib::RefPtr< Gtk::TextBuffer > | wrap (GtkTextBuffer * object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

Multi-line attributed text that can be displayed by one or more Gtk::TextView widgets.

Text in a buffer can be marked with tags. A Gtk::TextBuffer::Tag is an attribute that can be applied to some range of text. For example, a tag might be called "bold" and make the text inside the tag bold. However, the tag concept is more general than that; tags don't have to affect appearance. They can instead affect the behavior of mouse and key presses, "lock" a range of text so the user can't edit it, or countless other things. A tag is represented by a Gtk::TextBuffer::Tag object. One Gtk::TextBuffer::Tag can be applied to any number of text ranges in any number of Gtk::TextBuffers.

Each tag is stored in a Gtk::TextBuffer::TagTable. A tag table defines a set of tags that can be used together. Each buffer has one tag table associated with it; only tags from that tag table can be used with the buffer. A single tag table can be shared between multiple buffers, however.

Most text manipulation is accomplished with iterators, represented by an iterator or a const_iterator. The iterator can be used to navigate over characters, words, lines, and sentences.

But iterators can't be used to preserve positions across buffer modifications. To preserve a position, the Gtk::TextBuffer::Mark object is ideal. There are two marks built-in to GtkTextBuffer; these are named "insert" and "selection_bound" and refer to the insertion point and the boundary of the selection which is not the insertion point. If no text is selected, these two marks will be in the same position. You can manipulate what is selected and where the cursor appears by moving these marks around.

Text buffers always contain at least one line, but may be empty (that is, buffers can contain zero characters). The last line in the text buffer never ends in a line separator (such as newline); the other lines in the buffer always end in a line separator. Line separators count as characters when computing character counts and character offsets. Note that some Unicode line separators are represented with multiple bytes in UTF-8, and the two-character sequence "\r\n" is also considered a line separator.

## Member Typedef Documentation

## ◆ ChildAnchor

typedef TextChildAnchor Gtk::TextBuffer::ChildAnchor

## ◆ const_iterator

typedef TextConstIter Gtk::TextBuffer::const_iterator

## ◆ iterator

typedef TextIter Gtk::TextBuffer::iterator

## ◆ Mark

typedef TextMark Gtk::TextBuffer::Mark

## ◆ SlotCommitNotify

using Gtk::TextBuffer::SlotCommitNotify = sigc::slot<void(NotifyFlags, guint, guint)>

A notification callback used by add_commit_notify().

For instance:

void on_commit_notify(NotifyFlags flags, guint position, guint length);
Gtk::TextBuffer::NotifyFlags
NotifyFlags
Values for [callback@Gtk.TextBufferCommitNotify] to denote the point of the notification.
Definition textbuffer.h:190

You may not modify the TextBuffer from a SlotCommitNotify callback and that is enforced by the Gtk::TextBuffer API.

A SlotCommitNotify callback may be used to be notified about changes to the underlying buffer right before-or-after the changes are committed to the underlying B-Tree. This is useful if you want to observe changes to the buffer without other signal handlers potentially modifying state on the way to the default signal handler.

When flags is Gtk::TextBuffer::NotifyFlags::BEFORE_INSERT, position is set to the offset in characters from the start of the buffer where the insertion will occur. length is set to the number of characters to be inserted. You may not yet retrieve the text until it has been inserted. You may access the text from Gtk::TextBuffer::NotifyFlags::AFTER_INSERT using get_slice().

When flags is Gtk::TextBuffer::NotifyFlags::AFTER_INSERT, position is set to offset in characters where the insertion occurred and length is set to the number of characters inserted.

When flags is Gtk::TextBuffer::NotifyFlags::BEFORE_DELETE, position is set to offset in characters where the deletion will occur and length is set to the number of characters that will be removed. You may still retrieve the text from this handler using position and length.

When flags is Gtk::TextBuffer::NotifyFlags::AFTER_DELETE, length is set to zero to denote that the delete-range has already been committed to the underlying B-Tree. You may no longer retrieve the text that has been deleted from the Gtk::TextBuffer.

Parameters

  flags | The type of commit notification.
  position | The position of the text operation.
  length | The length of the text operation in characters.

Since gtkmm 4.16

## ◆ Tag

typedef TextTag Gtk::TextBuffer::Tag

## ◆ TagTable

typedef TextTagTable Gtk::TextBuffer::TagTable

## Constructor & Destructor Documentation

## ◆ TextBuffer() [1/3]

Gtk::TextBuffer::TextBuffer | ( | TextBuffer && | src | ) |
| noexcept

## ◆ ~TextBuffer()

Gtk::TextBuffer::~TextBuffer | ( |  | ) |
| overridenoexcept

## ◆ TextBuffer() [2/3]

Gtk::TextBuffer::TextBuffer | ( |  | ) |
| protected

## ◆ TextBuffer() [3/3]

Gtk::TextBuffer::TextBuffer | ( | const Glib::RefPtr< TagTable > & | tag_table | ) |
| explicitprotected

## Member Function Documentation

## ◆ add_commit_notify()

guint Gtk::TextBuffer::add_commit_notify | ( | NotifyFlags | flags,
|  | const SlotCommitNotify & | slot )

Adds a SlotCommitNotify to be called when a change is to be made to the Gtk::TextBuffer.

Functions are explicitly forbidden from making changes to the Gtk::TextBuffer from this callback. It is intended for tracking changes to the buffer only.

It may be advantageous to use add_commit_notify() over connecting to signal_insert() or signal_erase() to avoid ordering issues with other signal handlers which may further modify the Gtk::TextBuffer.

Since gtkmm 4.16

Parameters

  flags | Which notifications should be dispatched to slot.
  Slots | A SlotCommitNotify to call for commit notifications.

Returns
  A handler id which may be used to remove the commit notify callback using remove_commit_notify().

## ◆ add_mark()

void Gtk::TextBuffer::add_mark | ( | const Glib::RefPtr< TextBuffer::Mark > & | mark,
|  | const iterator & | where )

Adds the mark at position where.

The mark must not be added to another buffer, and if its name is not nullptr then there must not be another mark in the buffer with the same name.

Emits the signal_mark_set() signal as notification of the mark's initial placement.

Parameters

  mark | The mark to add.
  where | Location to place mark.

## ◆ add_selection_clipboard()

void Gtk::TextBuffer::add_selection_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard | ) |

Adds clipboard to the list of clipboards in which the selection contents of buffer are available.

In most cases, clipboard will be the Gdk::Clipboard returned by Gtk::Widget::get_primary_clipboard() for a view of buffer.

Parameters

  clipboard | A Gdk::Clipboard.

## ◆ apply_tag()

void Gtk::TextBuffer::apply_tag | ( | const Glib::RefPtr< Tag > & | tag,
|  | const iterator & | range_start,
|  | const iterator & | range_end )

Emits the “apply-tag” signal on buffer.

The default handler for the signal applies tag to the given range. range_start and range_end do not have to be in order.

Parameters

  tag | A Gtk::TextTag.
  range_start | One bound of range to be tagged.
  range_end | Other bound of range to be tagged.

## ◆ apply_tag_by_name()

void Gtk::TextBuffer::apply_tag_by_name | ( | const Glib::ustring & | name,
|  | const iterator & | range_start,
|  | const iterator & | range_end )

Emits the “apply-tag” signal on buffer.

Calls Gtk::TextTagTable::lookup() on the buffer’s tag table to get a Gtk::TextTag, then calls apply_tag().

Parameters

  name | Name of a named Gtk::TextTag.
  range_start | One bound of range to be tagged.
  range_end | Other bound of range to be tagged.

## ◆ backspace()

iterator Gtk::TextBuffer::backspace | ( | const iterator & | iter,
|  | bool | interactive = true,
|  | bool | default_editable = true )

Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter.

In the normal case a single character will be deleted, but when combining accents are involved, more than one character can be deleted, and when precomposed character and accent combinations are involved, less than one character will be deleted.

Because the buffer is modified, all outstanding iterators become invalid after calling this method; however, this method returns a valid iterator that points to the location where text was deleted.

Parameters

  iter | A position in the buffer.
  interactive | Whether the deletion is caused by user interaction.
  default_editable | Whether the buffer is editable by default.

Returns
  An iterator to the location where text was deleted, if the buffer was modified.

## ◆ begin() [1/2]

iterator Gtk::TextBuffer::begin | ( |  | ) |

## ◆ begin() [2/2]

const_iterator Gtk::TextBuffer::begin | ( |  | ) | const

## ◆ begin_irreversible_action()

void Gtk::TextBuffer::begin_irreversible_action | ( |  | ) |

Denotes the beginning of an action that may not be undone.

This will cause any previous operations in the undo/redo queue to be cleared.

This should be paired with a call to end_irreversible_action() after the irreversible action has completed.

You may nest calls to begin_irreversible_action() and end_irreversible_action() pairs.

## ◆ begin_user_action()

void Gtk::TextBuffer::begin_user_action | ( |  | ) |

Called to indicate that the buffer operations between here and a call to end_user_action() are part of a single user-visible operation.

The operations between begin_user_action() and end_user_action() can then be grouped when creating an undo stack. Gtk::TextBuffer maintains a count of calls to begin_user_action() that have not been closed with a call to end_user_action(), and emits the “begin-user-action” and “end-user-action” signals only for the outermost pair of calls. This allows you to build user actions from other user actions.

The “interactive” buffer mutation functions, such as insert_interactive(), automatically call begin/end user action around the buffer operations they perform, so there's no need to add extra calls if you user action consists solely of a single call to one of those functions.

## ◆ copy_clipboard()

void Gtk::TextBuffer::copy_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard | ) |

Copies the currently-selected text to a clipboard.

Parameters

  clipboard | The Gdk::Clipboard object to copy to.

## ◆ create() [1/2]

Glib::RefPtr< TextBuffer > Gtk::TextBuffer::create | ( |  | ) |
| static

## ◆ create() [2/2]

Glib::RefPtr< TextBuffer > Gtk::TextBuffer::create | ( | const Glib::RefPtr< TagTable > & | tag_table | ) |
| static

## ◆ create_child_anchor()

Glib::RefPtr< ChildAnchor > Gtk::TextBuffer::create_child_anchor | ( | const iterator & | pos | ) |

## ◆ create_mark() [1/2]

Glib::RefPtr< TextBuffer::Mark > Gtk::TextBuffer::create_mark | ( | const Glib::ustring & | mark_name,
|  | const iterator & | where,
|  | bool | left_gravity = true )

Creates a mark at position where.

The mark can be retrieved by name using get_mark(). If a mark has left gravity, and text is inserted at the mark's current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity ( left_gravity = false), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you're typing).

Emits the "mark_set" signal as notification of the mark's initial placement.

Parameters

  mark_name | Name for mark.
  where | Location to place mark.
  left_gravity | Whether the mark has left gravity.

Returns
  The new Gtk::TextMark object.

## ◆ create_mark() [2/2]

Glib::RefPtr< Mark > Gtk::TextBuffer::create_mark | ( | const iterator & | where,
|  | bool | left_gravity = true )

Create an anonymous mark.

Creates an anonymous mark at position where.

If a mark has left gravity, and text is inserted at the mark's current location, the mark will be moved to the left of the newly-inserted text. If the mark has right gravity ( left_gravity = false), the mark will end up on the right of newly-inserted text. The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you're typing).

Emits the "mark_set" signal as notification of the mark's initial placement.

Parameters

  where | Location to place mark.
  left_gravity | Whether the mark has left gravity.

Returns
  The new Gtk::TextMark object.

## ◆ create_tag() [1/2]

Glib::RefPtr< Tag > Gtk::TextBuffer::create_tag | ( |  | ) |

Creates an anoymous tag and adds it to the tag table for buffer.

Equivalent to calling Gtk::TextBuffer::Tag::create() and then adding the tag to the buffer's tag table.

Returns
  The new tag.

## ◆ create_tag() [2/2]

Glib::RefPtr< Tag > Gtk::TextBuffer::create_tag | ( | const Glib::ustring & | tag_name | ) |

Creates a tag and adds it to the tag table for buffer.

Equivalent to calling Gtk::TextBuffer::Tag::create() and then adding the tag to the buffer's tag table. A tag called tag_name must not already exist in the tag table for this buffer.

Parameters

  tag_name | The name for the new tag.

Returns
  The new tag.

## ◆ cut_clipboard()

void Gtk::TextBuffer::cut_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard,
|  | bool | default_editable = true )

Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.

Parameters

  clipboard | The Gdk::Clipboard object to cut to.
  default_editable | Default editability of the buffer.

## ◆ delete_mark()

void Gtk::TextBuffer::delete_mark | ( | const Glib::RefPtr< Mark > & | mark | ) |

Deletes mark, so that it's no longer located anywhere in the buffer.

Removes the reference the buffer holds to the mark, so if you don't keep a Glib::RefPtr to the mark, it will be freed. Even if the mark isn't freed, most operations on mark become invalid. There is no way to undelete a mark. Gtk::TextMark::get_deleted() will return true after this function has been called on a mark; Gtk::TextMark::get_deleted() indicates that a mark no longer belongs to a buffer. The "mark_deleted" signal will be emitted as notification after the mark is deleted.

Parameters

  mark | A Gtk::TextMark in buffer.

## ◆ delete_mark_by_name()

void Gtk::TextBuffer::delete_mark_by_name | ( | const Glib::ustring & | name | ) |

Deletes the mark named name; the mark must exist.

See delete_mark() for details.

Parameters

  name | Name of a mark in buffer.

## ◆ end() [1/2]

iterator Gtk::TextBuffer::end | ( |  | ) |

## ◆ end() [2/2]

const_iterator Gtk::TextBuffer::end | ( |  | ) | const

## ◆ end_irreversible_action()

void Gtk::TextBuffer::end_irreversible_action | ( |  | ) |

Denotes the end of an action that may not be undone.

This will cause any previous operations in the undo/redo queue to be cleared.

This should be called after completing modifications to the text buffer after begin_irreversible_action() was called.

You may nest calls to begin_irreversible_action() and end_irreversible_action() pairs.

## ◆ end_user_action()

void Gtk::TextBuffer::end_user_action | ( |  | ) |

Ends a user-visible operation.

Should be paired with a call to begin_user_action(). See that function for a full explanation.

## ◆ erase()

iterator Gtk::TextBuffer::erase | ( | const iterator & | range_begin,
|  | const iterator & | range_end )

## ◆ erase_interactive()

std::pair< iterator, bool > Gtk::TextBuffer::erase_interactive | ( | const iterator & | range_begin,
|  | const iterator & | range_end,
|  | bool | default_editable = true )

## ◆ erase_selection()

bool Gtk::TextBuffer::erase_selection | ( | bool | interactive = true,
|  | bool | default_editable = true )

Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.

If interactive is true, the editability of the selection will be considered (users can’t delete uneditable text).

Parameters

  interactive | Whether the deletion is caused by user interaction.
  default_editable | Whether the buffer is editable by default.

Returns
  Whether there was a non-empty selection to delete.

## ◆ get_bounds() [1/2]

void Gtk::TextBuffer::get_bounds | ( | const_iterator & | range_begin,
|  | const_iterator & | range_end ) const

## ◆ get_bounds() [2/2]

void Gtk::TextBuffer::get_bounds | ( | iterator & | range_begin,
|  | iterator & | range_end )

## ◆ get_can_redo()

bool Gtk::TextBuffer::get_can_redo | ( |  | ) | const

Gets whether there is a redoable action in the history.

Returns
  true if there is a redoable action.

## ◆ get_can_undo()

bool Gtk::TextBuffer::get_can_undo | ( |  | ) | const

Gets whether there is an undoable action in the history.

Returns
  true if there is an undoable action.

## ◆ get_char_count()

int Gtk::TextBuffer::get_char_count | ( |  | ) | const

Gets the number of characters in the buffer.

Note that characters and bytes are not the same, you can’t e.g. expect the contents of the buffer in string form to be this many bytes long.

The character count is cached, so this function is very fast.

Returns
  Number of characters in the buffer.

## ◆ get_enable_undo()

bool Gtk::TextBuffer::get_enable_undo | ( |  | ) | const

Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.

See begin_irreversible_action() and end_irreversible_action() to create changes to the buffer that cannot be undone.

Returns
  true if undoing and redoing changes to the buffer is allowed.

## ◆ get_has_selection()

bool Gtk::TextBuffer::get_has_selection | ( |  | ) | const

Indicates whether the buffer has some text currently selected.

Returns
  true if the there is text selected.

## ◆ get_insert()

Glib::RefPtr< TextBuffer::Mark > Gtk::TextBuffer::get_insert | ( |  | ) |

Returns the mark that represents the cursor (insertion point).

Equivalent to calling get_mark() to get the mark named “insert”, but very slightly more efficient, and involves less typing.

Returns
  Insertion point mark.

## ◆ get_iter_at_child_anchor() [1/2]

iterator Gtk::TextBuffer::get_iter_at_child_anchor | ( | const Glib::RefPtr< ChildAnchor > & | anchor | ) |

Get the current position of an anchor.

Parameters

  anchor | A Gtk::TextBuffer::Anchor that appears in the buffer.

Returns
  An iterator that points to the position of the anchor.

## ◆ get_iter_at_child_anchor() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_child_anchor | ( | const Glib::RefPtr< ChildAnchor > & | anchor | ) | const

Get the current position of an anchor.

Parameters

  anchor | A Gtk::TextBuffer::Anchor that appears in the buffer.

Returns
  An iterator that points to the position of the anchor.

## ◆ get_iter_at_line() [1/2]

iterator Gtk::TextBuffer::get_iter_at_line | ( | int | line_number | ) |

## ◆ get_iter_at_line() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_line | ( | int | line_number | ) | const

## ◆ get_iter_at_line_index() [1/2]

iterator Gtk::TextBuffer::get_iter_at_line_index | ( | int | line_number,
|  | int | byte_index )

## ◆ get_iter_at_line_index() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_line_index | ( | int | line_number,
|  | int | byte_index ) const

## ◆ get_iter_at_line_offset() [1/2]

iterator Gtk::TextBuffer::get_iter_at_line_offset | ( | int | line_number,
|  | int | char_offset )

## ◆ get_iter_at_line_offset() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_line_offset | ( | int | line_number,
|  | int | char_offset ) const

## ◆ get_iter_at_mark() [1/2]

iterator Gtk::TextBuffer::get_iter_at_mark | ( | const Glib::RefPtr< Mark > & | mark | ) |

Get the current position of a mark.

Parameters

  mark | The Gtk::TextBuffer::Mark

Returns
  An iterator that points to the position of the mark.

## ◆ get_iter_at_mark() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_mark | ( | const Glib::RefPtr< Mark > & | mark | ) | const

Get the current position of a mark.

Parameters

  mark | The Gtk::TextBuffer::Mark

Returns
  An iterator that points to the position of the mark.

## ◆ get_iter_at_offset() [1/2]

iterator Gtk::TextBuffer::get_iter_at_offset | ( | int | char_offset | ) |

## ◆ get_iter_at_offset() [2/2]

const_iterator Gtk::TextBuffer::get_iter_at_offset | ( | int | char_offset | ) | const

## ◆ get_line_count()

int Gtk::TextBuffer::get_line_count | ( |  | ) | const

Obtains the number of lines in the buffer.

This value is cached, so the function is very fast.

Returns
  Number of lines in the buffer.

## ◆ get_mark() [1/2]

Glib::RefPtr< TextBuffer::Mark > Gtk::TextBuffer::get_mark | ( | const Glib::ustring & | name | ) |

Returns the mark named name in buffer buffer, or nullptr if no such mark exists in the buffer.

Parameters

  name | A mark name.

Returns
  A Gtk::TextMark.

## ◆ get_mark() [2/2]

Glib::RefPtr< const TextBuffer::Mark > Gtk::TextBuffer::get_mark | ( | const Glib::ustring & | name | ) | const

Returns the mark named name in buffer buffer, or nullptr if no such mark exists in the buffer.

Parameters

  name | A mark name.

Returns
  A Gtk::TextMark.

## ◆ get_max_undo_levels()

guint Gtk::TextBuffer::get_max_undo_levels | ( |  | ) | const

Gets the maximum number of undo levels to perform.

If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.

Returns
  The max number of undo levels allowed (0 indicates unlimited).

## ◆ get_modified()

bool Gtk::TextBuffer::get_modified | ( |  | ) | const

Indicates whether the buffer has been modified since the last call to set_modified() set the modification flag to false.

Used for example to enable a “save” function in a text editor.

Returns
  true if the buffer has been modified.

## ◆ get_selection_bound()

Glib::RefPtr< TextBuffer::Mark > Gtk::TextBuffer::get_selection_bound | ( |  | ) |

Returns the mark that represents the selection bound.

Equivalent to calling get_mark() to get the mark named “selection_bound”, but very slightly more efficient, and involves less typing.

The currently-selected text in buffer is the region between the “selection_bound” and “insert” marks. If “selection_bound” and “insert” are in the same place, then there is no current selection. get_selection_bounds() is another convenient function for handling the selection, if you just want to know whether there’s a selection and what its bounds are.

Returns
  Selection bound mark.

## ◆ get_selection_bounds() [1/2]

bool Gtk::TextBuffer::get_selection_bounds | ( | const_iterator & | range_start,
|  | const_iterator & | range_end ) const

Returns true if some text is selected; places the bounds of the selection in range_start and range_end.

If the selection has length 0, then range_start and range_end are filled in with the same value. range_start and range_end will be in ascending order. If range_start and range_end are nullptr, then they are not filled in, but the return value still indicates whether text is selected.

Parameters

  range_start | Iterator to initialize with selection start.
  range_end | Iterator to initialize with selection end.

Returns
  Whether the selection has nonzero length.

## ◆ get_selection_bounds() [2/2]

bool Gtk::TextBuffer::get_selection_bounds | ( | iterator & | range_start,
|  | iterator & | range_end )

Returns true if some text is selected; places the bounds of the selection in range_start and range_end.

If the selection has length 0, then range_start and range_end are filled in with the same value. range_start and range_end will be in ascending order. If range_start and range_end are nullptr, then they are not filled in, but the return value still indicates whether text is selected.

Parameters

  range_start | Iterator to initialize with selection start.
  range_end | Iterator to initialize with selection end.

Returns
  Whether the selection has nonzero length.

## ◆ get_selection_content()

Glib::RefPtr< Gdk::ContentProvider > Gtk::TextBuffer::get_selection_content | ( |  | ) |

Get a content provider for this buffer.

It can be used to make the content of buffer available in a Gdk::Clipboard, see Gdk::Clipboard::set_content().

Returns
  A new Gdk::ContentProvider.

## ◆ get_slice()

Glib::ustring Gtk::TextBuffer::get_slice | ( | const const_iterator & | range_start,
|  | const const_iterator & | range_end,
|  | bool | include_hidden_chars = true ) const

Returns the text in the range [ range_start, range_end).

Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. The returned string includes a 0xFFFC character whenever the buffer contains embedded images, so byte and character indexes into the returned string do correspond to byte and character indexes into the buffer. Contrast with get_text(). Note that 0xFFFC can occur in normal text as well, so it is not a reliable indicator that a paintable or widget is in the buffer.

Parameters

  range_start | Start of a range.
  range_end | End of a range.
  include_hidden_chars | Whether to include invisible text.

Returns
  An allocated UTF-8 string.

## ◆ get_tag_table() [1/2]

Glib::RefPtr< TextBuffer::TagTable > Gtk::TextBuffer::get_tag_table | ( |  | ) |

Get the Gtk::TextTagTable associated with this buffer.

Returns
  The buffer’s tag table.

## ◆ get_tag_table() [2/2]

Glib::RefPtr< const TextBuffer::TagTable > Gtk::TextBuffer::get_tag_table | ( |  | ) | const

Get the Gtk::TextTagTable associated with this buffer.

Returns
  The buffer’s tag table.

## ◆ get_text() [1/2]

Glib::ustring Gtk::TextBuffer::get_text | ( | bool | include_hidden_chars = true | ) | const

Returns all the text in the buffer.

Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with get_slice().

Parameters

  include_hidden_chars | Whether to include invisible text.

Returns
  An allocated UTF-8 string.

## ◆ get_text() [2/2]

Glib::ustring Gtk::TextBuffer::get_text | ( | const const_iterator & | range_start,
|  | const const_iterator & | range_end,
|  | bool | include_hidden_chars = true ) const

Returns the text in the range [ range_start, range_end).

Excludes undisplayed text (text marked with tags that set the invisibility attribute) if include_hidden_chars is false. Does not include characters representing embedded images, so byte and character indexes into the returned string do not correspond to byte and character indexes into the buffer. Contrast with get_slice().

Parameters

  range_start | Start of a range.
  range_end | End of a range.
  include_hidden_chars | Whether to include invisible text.

Returns
  An allocated UTF-8 string.

## ◆ get_type()

GType Gtk::TextBuffer::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

## ◆ gobj() [1/2]

GtkTextBuffer * Gtk::TextBuffer::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

## ◆ gobj() [2/2]

const GtkTextBuffer * Gtk::TextBuffer::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

## ◆ gobj_copy()

GtkTextBuffer * Gtk::TextBuffer::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

## ◆ insert() [1/3]

iterator Gtk::TextBuffer::insert | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end )

Inserts text at position pos.

Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. The pos iterator is invalidated when insertion occurs (because the buffer contents change).

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.

Returns
  An iterator that points to the end of the inserted text.

## ◆ insert() [2/3]

iterator Gtk::TextBuffer::insert | ( | const iterator & | pos,
|  | const const_iterator & | range_begin,
|  | const const_iterator & | range_end )

Copies text, tags, and paintable between range_begin and range_end (the order of range_begin and range_begin doesn't matter) and inserts the copy at pos.

Used instead of simply getting/inserting text because it preserves images and tags. If range_begin and range_end are in a different buffer, the two buffers must share the same tag table.

Implemented via emissions of the insert_text and apply_tag signals, so expect those.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  range_begin | A position in a buffer.
  range_end | Another position in the same buffer as range_begin.

Returns
  Whether text was actually inserted

## ◆ insert() [3/3]

iterator Gtk::TextBuffer::insert | ( | const iterator & | pos,
|  | const Glib::ustring & | text )

Inserts text at position pos.

Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. The pos iterator is invalidated when insertion occurs (because the buffer contents change).

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text | The text to be inserted in the buffer.

Returns
  An iterator that points to the end of the inserted text.

## ◆ insert_at_cursor() [1/2]

void Gtk::TextBuffer::insert_at_cursor | ( | const char * | text_begin,
|  | const char * | text_end )

Inserts text, using the current cursor position as the insertion point.

Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal.

Parameters

  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.

## ◆ insert_at_cursor() [2/2]

void Gtk::TextBuffer::insert_at_cursor | ( | const Glib::ustring & | text | ) |

Inserts text, using the current cursor position as the insertion point.

Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal.

Parameters

  text | The text to be inserted in the buffer.

## ◆ insert_child_anchor()

iterator Gtk::TextBuffer::insert_child_anchor | ( | const iterator & | pos,
|  | const Glib::RefPtr< ChildAnchor > & | anchor )

## ◆ insert_interactive() [1/3]

std::pair< iterator, bool > Gtk::TextBuffer::insert_interactive | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end,
|  | bool | default_editable = true )

Like insert(), but the insertion will not occur if pos is at a non-editable location in the buffer.

Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).

default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of Gtk::TextView::get_editable() is appropriate here.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.
  default_editable | Default editability of buffer.

Returns
  Whether text was actually inserted

## ◆ insert_interactive() [2/3]

std::pair< iterator, bool > Gtk::TextBuffer::insert_interactive | ( | const iterator & | pos,
|  | const const_iterator & | range_begin,
|  | const const_iterator & | range_end,
|  | bool | default_editable = true )

Same as insert_range(), but does nothing if the insertion point isn't editable.

The default_editable parameter indicates whether the text is editable at pos if no tags enclosing pos affect editability. Typically the result of Gtk::TextView::get_editable() is appropriate here.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  range_begin | A position in a buffer.
  range_end | Another position in the same buffer as range_begin.
  default_editable | Default editability of buffer.

Returns
  Whether text was actually inserted

## ◆ insert_interactive() [3/3]

std::pair< iterator, bool > Gtk::TextBuffer::insert_interactive | ( | const iterator & | pos,
|  | const Glib::ustring & | text,
|  | bool | default_editable = true )

Like insert(), but the insertion will not occur if iter is at a non-editable location in the buffer.

Usually you want to prevent insertions at ineditable locations if the insertion results from a user action (is interactive).

default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of Gtk::TextView::get_editable() is appropriate here.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text | The text to be inserted in the buffer.
  default_editable | Default editability of buffer

Returns
  Whether text was actually inserted

## ◆ insert_interactive_at_cursor() [1/2]

bool Gtk::TextBuffer::insert_interactive_at_cursor | ( | const char * | text_begin,
|  | const char * | text_end,
|  | bool | default_editable = true )

Calls insert_interactive() at the cursor position.

default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of Gtk::TextView::get_editable() is appropriate here.

Parameters

  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.
  default_editable | Default editability of buffer

Returns
  Whether text was actually inserted

## ◆ insert_interactive_at_cursor() [2/2]

bool Gtk::TextBuffer::insert_interactive_at_cursor | ( | const Glib::ustring & | text,
|  | bool | default_editable = true )

Calls insert_interactive() at the cursor position.

default_editable indicates the editability of text that doesn't have a tag affecting editability applied to it. Typically the result of Gtk::TextView::get_editable() is appropriate here.

Parameters

  text | The text to be inserted in the buffer.
  default_editable | Default editability of buffer

Returns
  Whether text was actually inserted

## ◆ insert_markup() [1/2]

iterator Gtk::TextBuffer::insert_markup | ( | const iterator & | pos,
|  | const char * | markup_begin,
|  | const char * | markup_end )

Inserts markup text at position pos.

Emits the "insert_text" signal; insertion actually occurs in the default handler for the signal. The pos iterator will point to the end of the inserted text on return.

Parameters

  pos | Location to insert the markup.
  markup_begin | The start of a UTF8 character array containing pango markup.
  markup_end | The end of the UTF8 character array containing pango markup.

Returns
  An iterator that points to the end of the inserted markup text.

## ◆ insert_markup() [2/2]

iterator Gtk::TextBuffer::insert_markup | ( | const iterator & | pos,
|  | const Glib::ustring & | markup )

Inserts text in markup at position pos.

Emits the "insert_text" signal, possibly multiple times; insertion actually occurs in the default handler for the signal. The pos iterator will point to the end of the inserted text on return.

Parameters

  pos | Location to insert the markup.
  markup | The text containing pango markup to be inserted in the buffer.

Returns
  An iterator that points to the end of the inserted markup text.

## ◆ insert_paintable()

iterator Gtk::TextBuffer::insert_paintable | ( | const iterator & | pos,
|  | const Glib::RefPtr< Gdk::Paintable > & | paintable )

## ◆ insert_with_tag() [1/4]

iterator Gtk::TextBuffer::insert_with_tag | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end,
|  | const Glib::RefPtr< Tag > & | tag )

## ◆ insert_with_tag() [2/4]

iterator Gtk::TextBuffer::insert_with_tag | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end,
|  | const Glib::ustring & | tag_name )

## ◆ insert_with_tag() [3/4]

iterator Gtk::TextBuffer::insert_with_tag | ( | const iterator & | pos,
|  | const Glib::ustring & | text,
|  | const Glib::RefPtr< Tag > & | tag )

## ◆ insert_with_tag() [4/4]

iterator Gtk::TextBuffer::insert_with_tag | ( | const iterator & | pos,
|  | const Glib::ustring & | text,
|  | const Glib::ustring & | tag_name )

## ◆ insert_with_tags() [1/2]

iterator Gtk::TextBuffer::insert_with_tags | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end,
|  | const std::vector< Glib::RefPtr< Tag > > & | tags )

Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.

Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.
  Tags | A standard C++ container of Gtk::TextBuffer::Tags.

Returns
  Whether text was actually inserted

## ◆ insert_with_tags() [2/2]

iterator Gtk::TextBuffer::insert_with_tags | ( | const iterator & | pos,
|  | const Glib::ustring & | text,
|  | const std::vector< Glib::RefPtr< Tag > > & | tags )

Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.

Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text | The text to be inserted in the buffer.
  Tags | A standard C++ container of Gtk::TextBuffer::Tags.

Returns
  Whether text was actually inserted

## ◆ insert_with_tags_by_name() [1/2]

iterator Gtk::TextBuffer::insert_with_tags_by_name | ( | const iterator & | pos,
|  | const char * | text_begin,
|  | const char * | text_end,
|  | const std::vector< Glib::ustring > & | tag_names )

Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.
  tag_names | A standard C++ container of tag names.

Returns
  Whether text was actually inserted

## ◆ insert_with_tags_by_name() [2/2]

iterator Gtk::TextBuffer::insert_with_tags_by_name | ( | const iterator & | pos,
|  | const Glib::ustring & | text,
|  | const std::vector< Glib::ustring > & | tag_names )

Inserts text into buffer at pos, applying the list of tags to the newly-inserted text.

Equivalent to calling insert(), then apply_tag() on the inserted text; This is just a convenience function.

Parameters

  pos | An iterator pointing to the position at which the text should be inserted.
  text | The text to be inserted in the buffer.
  tag_names | A standard C++ container of tag names.

Returns
  Whether text was actually inserted

## ◆ move_mark()

void Gtk::TextBuffer::move_mark | ( | const Glib::RefPtr< Mark > & | mark,
|  | const iterator & | where )

Moves mark to the new location where.

Emits the signal_mark_set() signal as notification of the move.

Parameters

  mark | A Gtk::TextMark.
  where | New location for mark in buffer.

## ◆ move_mark_by_name()

void Gtk::TextBuffer::move_mark_by_name | ( | const Glib::ustring & | name,
|  | const iterator & | where )

Moves the mark named name (which must exist) to location where.

See move_mark() for details.

Parameters

  name | Name of a mark.
  where | New location for mark.

## ◆ on_apply_tag()

virtual void Gtk::TextBuffer::on_apply_tag | ( | const Glib::RefPtr< TextBuffer::Tag > & | tag,
|  | const TextBuffer::iterator & | range_begin,
|  | const TextBuffer::iterator & | range_end )
| protectedvirtual

This is a default handler for the signal signal_apply_tag().

## ◆ on_begin_user_action()

virtual void Gtk::TextBuffer::on_begin_user_action | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_begin_user_action().

## ◆ on_changed()

virtual void Gtk::TextBuffer::on_changed | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_changed().

## ◆ on_end_user_action()

virtual void Gtk::TextBuffer::on_end_user_action | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_end_user_action().

## ◆ on_erase()

virtual void Gtk::TextBuffer::on_erase | ( | TextBuffer::iterator & | range_start,
|  | TextBuffer::iterator & | range_end )
| protectedvirtual

This is a default handler for the signal signal_erase().

## ◆ on_insert()

virtual void Gtk::TextBuffer::on_insert | ( | TextBuffer::iterator & | pos,
|  | const Glib::ustring & | text,
|  | int | bytes )
| protectedvirtual

This is a default handler for the signal signal_insert().

## ◆ on_insert_child_anchor()

virtual void Gtk::TextBuffer::on_insert_child_anchor | ( | TextBuffer::iterator & | pos,
|  | const Glib::RefPtr< ChildAnchor > & | anchor )
| protectedvirtual

This is a default handler for the signal signal_insert_child_anchor().

## ◆ on_insert_paintable()

virtual void Gtk::TextBuffer::on_insert_paintable | ( | TextBuffer::iterator & | pos,
|  | const Glib::RefPtr< Gdk::Paintable > & | paintable )
| protectedvirtual

This is a default handler for the signal signal_insert_paintable().

## ◆ on_mark_deleted()

virtual void Gtk::TextBuffer::on_mark_deleted | ( | const Glib::RefPtr< TextBuffer::Mark > & | mark | ) |
| protectedvirtual

This is a default handler for the signal signal_mark_deleted().

## ◆ on_mark_set()

virtual void Gtk::TextBuffer::on_mark_set | ( | const TextBuffer::iterator & | location,
|  | const Glib::RefPtr< TextBuffer::Mark > & | mark )
| protectedvirtual

This is a default handler for the signal signal_mark_set().

## ◆ on_modified_changed()

virtual void Gtk::TextBuffer::on_modified_changed | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_modified_changed().

## ◆ on_paste_done()

virtual void Gtk::TextBuffer::on_paste_done | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard | ) |
| protectedvirtual

This is a default handler for the signal signal_paste_done().

## ◆ on_redo()

virtual void Gtk::TextBuffer::on_redo | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_redo().

## ◆ on_remove_tag()

virtual void Gtk::TextBuffer::on_remove_tag | ( | const Glib::RefPtr< TextBuffer::Tag > & | tag,
|  | const TextBuffer::iterator & | range_begin,
|  | const TextBuffer::iterator & | range_end )
| protectedvirtual

This is a default handler for the signal signal_remove_tag().

## ◆ on_undo()

virtual void Gtk::TextBuffer::on_undo | ( |  | ) |
| protectedvirtual

This is a default handler for the signal signal_undo().

## ◆ operator=()

TextBuffer & Gtk::TextBuffer::operator= | ( | TextBuffer && | src | ) |
| noexcept

## ◆ paste_clipboard() [1/2]

void Gtk::TextBuffer::paste_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard,
|  | bool | default_editable = true )

A paste_clipboard() convenience overload.

## ◆ paste_clipboard() [2/2]

void Gtk::TextBuffer::paste_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard,
|  | const iterator & | override_location,
|  | bool | default_editable = true )

Pastes the contents of a clipboard.

If override_location is nullptr, the pasted text will be inserted at the cursor position, or the buffer selection will be replaced if the selection is non-empty.

Note
  pasting is asynchronous, that is, we’ll ask for the paste data and return, and at some point later after the main loop runs, the paste data will be inserted.

Parameters

  clipboard | The Gdk::Clipboard to paste from.
  override_location | Location to insert pasted text.
  default_editable | Whether the buffer is editable by default.

## ◆ place_cursor()

void Gtk::TextBuffer::place_cursor | ( | const iterator & | where | ) |

This function moves the “insert” and “selection_bound” marks simultaneously.

If you move them to the same place in two steps with move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

Parameters

  where | Where to put the cursor.

## ◆ property_can_redo()

Glib::PropertyProxy_ReadOnly< bool > Gtk::TextBuffer::property_can_redo | ( |  | ) | const

Denotes that the buffer can reapply the last undone action.

Default value: false

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_can_undo()

Glib::PropertyProxy_ReadOnly< bool > Gtk::TextBuffer::property_can_undo | ( |  | ) | const

Denotes that the buffer can undo the last applied action.

Default value: false

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_cursor_position()

Glib::PropertyProxy_ReadOnly< int > Gtk::TextBuffer::property_cursor_position | ( |  | ) | const

The position of the insert mark.

This is an offset from the beginning of the buffer. It is useful for getting notified when the cursor moves.

Default value: 0

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_enable_undo() [1/2]

Glib::PropertyProxy< bool > Gtk::TextBuffer::property_enable_undo | ( |  | ) |

Denotes if support for undoing and redoing changes to the buffer is allowed.

Default value: true

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_enable_undo() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gtk::TextBuffer::property_enable_undo | ( |  | ) | const

Denotes if support for undoing and redoing changes to the buffer is allowed.

Default value: true

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_has_selection()

Glib::PropertyProxy_ReadOnly< bool > Gtk::TextBuffer::property_has_selection | ( |  | ) | const

Whether the buffer has some text currently selected.

Default value: false

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_tag_table()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< TextBuffer::TagTable > > Gtk::TextBuffer::property_tag_table | ( |  | ) | const

The GtkTextTagTable for the buffer.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ property_text() [1/2]

Glib::PropertyProxy< Glib::ustring > Gtk::TextBuffer::property_text | ( |  | ) |

The text content of the buffer.

Without child widgets and images, see Gtk::TextBuffer::get_text() for more information.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

## ◆ property_text() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::TextBuffer::property_text | ( |  | ) | const

The text content of the buffer.

Without child widgets and images, see Gtk::TextBuffer::get_text() for more information.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

## ◆ redo()

void Gtk::TextBuffer::redo | ( |  | ) |

Redoes the next redoable action on the buffer, if there is one.

## ◆ remove_all_tags()

void Gtk::TextBuffer::remove_all_tags | ( | const iterator & | range_start,
|  | const iterator & | range_end )

Removes all tags in the range between range_start and range_end.

Be careful with this function; it could remove tags added in code unrelated to the code you’re currently writing. That is, using this function is probably a bad idea if you have two or more unrelated code sections that add tags.

Parameters

  range_start | One bound of range to be untagged.
  range_end | Other bound of range to be untagged.

## ◆ remove_commit_notify()

void Gtk::TextBuffer::remove_commit_notify | ( | guint | commit_notify_handler | ) |

Removes the SlotCommitNotify handler previously registered with add_commit_notify().

Since gtkmm 4.16

Parameters

  commit_notify_handler | The notify handler identifier returned from add_commit_notify().

## ◆ remove_selection_clipboard()

void Gtk::TextBuffer::remove_selection_clipboard | ( | const Glib::RefPtr< Gdk::Clipboard > & | clipboard | ) |

Removes a Gdk::Clipboard added with add_selection_clipboard().

Parameters

  clipboard | A Gdk::Clipboard added to buffer by add_selection_clipboard().

## ◆ remove_tag()

void Gtk::TextBuffer::remove_tag | ( | const Glib::RefPtr< Tag > & | tag,
|  | const iterator & | range_start,
|  | const iterator & | range_end )

Emits the “remove-tag” signal.

The default handler for the signal removes all occurrences of tag from the given range. range_start and range_end don’t have to be in order.

Parameters

  tag | A Gtk::TextTag.
  range_start | One bound of range to be untagged.
  range_end | Other bound of range to be untagged.

## ◆ remove_tag_by_name()

void Gtk::TextBuffer::remove_tag_by_name | ( | const Glib::ustring & | name,
|  | const iterator & | range_start,
|  | const iterator & | range_end )

Emits the “remove-tag” signal.

Calls Gtk::TextTagTable::lookup() on the buffer’s tag table to get a Gtk::TextTag, then calls remove_tag().

Parameters

  name | Name of a Gtk::TextTag.
  range_start | One bound of range to be untagged.
  range_end | Other bound of range to be untagged.

## ◆ select_range()

void Gtk::TextBuffer::select_range | ( | const iterator & | ins,
|  | const iterator & | bound )

This function moves the “insert” and “selection_bound” marks simultaneously.

If you move them in two steps with move_mark(), you will temporarily select a region in between their old and new locations, which can be pretty inefficient since the temporarily-selected region will force stuff to be recalculated. This function moves them as a unit, which can be optimized.

Parameters

  ins | Where to put the “insert” mark.
  bound | Where to put the “selection_bound” mark.

## ◆ set_enable_undo()

void Gtk::TextBuffer::set_enable_undo | ( | bool | enable_undo = true | ) |

Sets whether or not to enable undoable actions in the text buffer.

Undoable actions in this context are changes to the text content of the buffer. Changes to tags and marks are not tracked.

If enabled, the user will be able to undo the last number of actions up to get_max_undo_levels().

See begin_irreversible_action() and end_irreversible_action() to create changes to the buffer that cannot be undone.

Parameters

  enable_undo | true to enable undo.

## ◆ set_max_undo_levels()

void Gtk::TextBuffer::set_max_undo_levels | ( | guint | max_undo_levels | ) |

Sets the maximum number of undo levels to perform.

If 0, unlimited undo actions may be performed. Note that this may have a memory usage impact as it requires storing an additional copy of the inserted or removed text within the text buffer.

Parameters

  max_undo_levels | The maximum number of undo actions to perform.

## ◆ set_modified()

void Gtk::TextBuffer::set_modified | ( | bool | setting = true | ) |

Used to keep track of whether the buffer has been modified since the last time it was saved.

Whenever the buffer is saved to disk, call gtk_text_buffer_set_modified ( @a buffer, <tt>false</tt>). When the buffer is modified, it will automatically toggle on the modified bit again. When the modified bit flips, the buffer emits the signal_modified_changed() signal.

Parameters

  setting | Modification flag setting.

## ◆ set_text() [1/2]

void Gtk::TextBuffer::set_text | ( | const char * | text_begin,
|  | const char * | text_end )

Removes the current contents of the buffer, and inserts text instead.

Parameters

  text_begin | The start of a UTF8 character array.
  text_end | The end of the UTF8 character array.

## ◆ set_text() [2/2]

void Gtk::TextBuffer::set_text | ( | const Glib::ustring & | text | ) |

Removes the current contents of the buffer, and inserts text instead.

Parameters

  text | The text to put in the buffer.

## ◆ signal_apply_tag()

Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Tag > &, const TextBuffer::iterator &, const TextBuffer::iterator &)> Gtk::TextBuffer::signal_apply_tag | ( |  | ) |

Slot Prototype:
  void on_my_apply_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end)

Flags: Run Last

Emitted to apply a tag to a range of text in a Gtk::TextBuffer.

Applying actually occurs in the default handler.

Note that if your handler runs before the default handler it must not invalidate the range_begin and range_end iters (or has to revalidate them).

See also: Gtk::TextBuffer::apply_tag(), Gtk::TextBuffer::insert_with_tags(), Gtk::TextBuffer::insert_range().

Parameters

  tag | The applied tag.
  range_begin | The start of the range the tag is applied to.
  range_end | The end of the range the tag is applied to.

## ◆ signal_begin_user_action()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_begin_user_action | ( |  | ) |

Slot Prototype:
  void on_my_begin_user_action()

Flags: Run Last

Emitted at the beginning of a single user-visible operation on a Gtk::TextBuffer.

See also: Gtk::TextBuffer::begin_user_action(), Gtk::TextBuffer::insert_interactive(), Gtk::TextBuffer::insert_range_interactive(), Gtk::TextBuffer::delete_interactive(), Gtk::TextBuffer::backspace(), Gtk::TextBuffer::delete_selection().

## ◆ signal_changed()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_changed | ( |  | ) |

Slot Prototype:
  void on_my_changed()

Flags: Run Last

Emitted when the content of a Gtk::TextBuffer has changed.

## ◆ signal_end_user_action()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_end_user_action | ( |  | ) |

Slot Prototype:
  void on_my_end_user_action()

Flags: Run Last

Emitted at the end of a single user-visible operation on the Gtk::TextBuffer.

See also: Gtk::TextBuffer::end_user_action(), Gtk::TextBuffer::insert_interactive(), Gtk::TextBuffer::insert_range_interactive(), Gtk::TextBuffer::delete_interactive(), Gtk::TextBuffer::backspace(), Gtk::TextBuffer::delete_selection(), Gtk::TextBuffer::backspace().

## ◆ signal_erase()

Glib::SignalProxy< void(TextBuffer::iterator &, TextBuffer::iterator &)> Gtk::TextBuffer::signal_erase | ( |  | ) |

Slot Prototype:
  void on_my_erase(TextBuffer::iterator& range_start, TextBuffer::iterator& range_end)

Flags: Run Last

Emitted to delete a range from a Gtk::TextBuffer.

Note that if your handler runs before the default handler it must not invalidate the range_start and range_end iters (or has to revalidate them). The default signal handler revalidates the range_start and range_end iters to both point to the location where text was deleted. Handlers which run after the default handler (see Glib::signal_connect_after()) do not have access to the deleted text.

See also: Gtk::TextBuffer::delete().

Parameters

  range_start | The start of the range to be deleted.
  range_end | The end of the range to be deleted.

## ◆ signal_insert()

Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::ustring &, int)> Gtk::TextBuffer::signal_insert | ( |  | ) |

Slot Prototype:
  void on_my_insert(TextBuffer::iterator& pos, const Glib::ustring& text, int bytes)

Flags: Run Last

Emitted to insert text in a Gtk::TextBuffer.

Insertion actually occurs in the default handler.

Note that if your handler runs before the default handler it must not invalidate the pos iter (or has to revalidate it). The default signal handler revalidates it to point to the end of the inserted text.

See also: Gtk::TextBuffer::insert(), Gtk::TextBuffer::insert_range().

Parameters

  pos | Position to insert text in textbuffer.
  text | The UTF-8 text to be inserted.
  bytes | Length of the inserted text in bytes.

## ◆ signal_insert_child_anchor()

Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::RefPtr< ChildAnchor > &)> Gtk::TextBuffer::signal_insert_child_anchor | ( |  | ) |

Slot Prototype:
  void on_my_insert_child_anchor(TextBuffer::iterator& pos, const Glib::RefPtr<ChildAnchor>& anchor)

Flags: Run Last

Emitted to insert a Gtk::TextChildAnchor in a Gtk::TextBuffer.

Insertion actually occurs in the default handler.

Note that if your handler runs before the default handler it must not invalidate the pos iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted anchor.

See also: Gtk::TextBuffer::insert_child_anchor().

Parameters

  pos | Position to insert anchor in textbuffer.
  anchor | The Gtk::TextChildAnchor to be inserted.

## ◆ signal_insert_paintable()

Glib::SignalProxy< void(TextBuffer::iterator &, const Glib::RefPtr< Gdk::Paintable > &)> Gtk::TextBuffer::signal_insert_paintable | ( |  | ) |

Slot Prototype:
  void on_my_insert_paintable(TextBuffer::iterator& pos, const Glib::RefPtr<Gdk::Paintable>& paintable)

Flags: Run Last

Emitted to insert a Gdk::Paintable in a Gtk::TextBuffer.

Insertion actually occurs in the default handler.

Note that if your handler runs before the default handler it must not invalidate the pos iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted paintable.

See also: Gtk::TextBuffer::insert_paintable().

Parameters

  pos | Position to insert paintable in textbuffer.
  paintable | The Gdk::Paintable to be inserted.

## ◆ signal_mark_deleted()

Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Mark > &)> Gtk::TextBuffer::signal_mark_deleted | ( |  | ) |

Slot Prototype:
  void on_my_mark_deleted(const Glib::RefPtr<TextBuffer::Mark>& mark)

Flags: Run Last

Emitted as notification after a Gtk::TextMark is deleted.

See also: Gtk::TextBuffer::delete_mark().

Parameters

  mark | The mark that was deleted.

## ◆ signal_mark_set()

Glib::SignalProxy< void(const TextBuffer::iterator &, const Glib::RefPtr< TextBuffer::Mark > &)> Gtk::TextBuffer::signal_mark_set | ( |  | ) |

Slot Prototype:
  void on_my_mark_set(const TextBuffer::iterator& location, const Glib::RefPtr<TextBuffer::Mark>& mark)

Flags: Run Last

Emitted as notification after a Gtk::TextMark is set.

See also: Gtk::TextBuffer::create_mark(), Gtk::TextBuffer::move_mark().

Parameters

  location | The location of mark in textbuffer.
  mark | The mark that is set.

## ◆ signal_modified_changed()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_modified_changed | ( |  | ) |

Slot Prototype:
  void on_my_modified_changed()

Flags: Run Last

Emitted when the modified bit of a Gtk::TextBuffer flips.

See also: Gtk::TextBuffer::set_modified().

## ◆ signal_paste_done()

Glib::SignalProxy< void(const Glib::RefPtr< Gdk::Clipboard > &)> Gtk::TextBuffer::signal_paste_done | ( |  | ) |

Slot Prototype:
  void on_my_paste_done(const Glib::RefPtr<Gdk::Clipboard>& clipboard)

Flags: Run Last

Emitted after paste operation has been completed.

This is useful to properly scroll the view to the end of the pasted text. See Gtk::TextBuffer::paste_clipboard() for more details.

Parameters

  clipboard | The Gdk::Clipboard pasted from.

## ◆ signal_redo()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_redo | ( |  | ) |

Slot Prototype:
  void on_my_redo()

Flags: Run Last

Emitted when a request has been made to redo the previously undone operation.

## ◆ signal_remove_tag()

Glib::SignalProxy< void(const Glib::RefPtr< TextBuffer::Tag > &, const TextBuffer::iterator &, const TextBuffer::iterator &)> Gtk::TextBuffer::signal_remove_tag | ( |  | ) |

Slot Prototype:
  void on_my_remove_tag(const Glib::RefPtr<TextBuffer::Tag>& tag, const TextBuffer::iterator& range_begin, const TextBuffer::iterator& range_end)

Flags: Run Last

Emitted to remove all occurrences of tag from a range of text in a Gtk::TextBuffer.

Removal actually occurs in the default handler.

Note that if your handler runs before the default handler it must not invalidate the range_begin and range_end iters (or has to revalidate them).

See also: Gtk::TextBuffer::remove_tag().

Parameters

  tag | The tag to be removed.
  range_begin | The start of the range the tag is removed from.
  range_end | The end of the range the tag is removed from.

## ◆ signal_undo()

Glib::SignalProxy< void()> Gtk::TextBuffer::signal_undo | ( |  | ) |

Slot Prototype:
  void on_my_undo()

Flags: Run Last

Emitted when a request has been made to undo the previous operation or set of operations that have been grouped together.

## ◆ size()

int Gtk::TextBuffer::size | ( |  | ) | const

See get_char_count().

## ◆ undo()

void Gtk::TextBuffer::undo | ( |  | ) |

Undoes the last undoable action on the buffer, if there is one.

## Friends And Related Symbol Documentation

## ◆ wrap()

Glib::RefPtr< Gtk::TextBuffer > wrap | ( | GtkTextBuffer * | object,
|  | bool | take_copy = false )
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.