Gtk2::TextBuffer(3)

πŸ“¦
version 1.24993 Β· 2 versions
, in fedora 43

πŸ’– Gtk2::TextBuffer β€” your fave text-holding icon πŸ’–

okay so bestie, welcome to Gtk2::TextBuffer(3), served fresh from the User Contributed Perl Documentation. this is the wrapper for GtkTextBuffer, and it's literally the whole vibe of "text goes here, tags go there, marks are everywhere". pull up a chair 🫢


🌈 HIERARCHY (the family tree, slay)

Glib::Object
+----Gtk2::TextBuffer

so it's a Glib::Object girly. periodt. πŸ‘‘


✨ METHODS ✨

textbuffer = Gtk2::TextBuffer->new ($tagtable=undef)

  • $tagtable (Gtk2::TextTagTable or undef) β€” hand it a tag table, or don't, she's flexible πŸ’…

$buffer->add_mark ($mark, $where)

  • $mark (Gtk2::TextMark)
  • $where (Gtk2::TextIter)
Since: gtk+ 2.12 πŸŽ€

$buffer->add_selection_clipboard ($clipboard)

  • $clipboard (Gtk2::Clipboard)
Since: gtk+ 2.2 πŸŽ€

$buffer->apply_tag ($tag, $start, $end)

  • $tag (Gtk2::TextTag)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

$buffer->apply_tag_by_name ($name, $start, $end)

  • $name (string)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

boolean = $buffer->backspace ($iter, $interactive, $default_editable)

  • $iter (Gtk2::TextIter)
  • $interactive (boolean)
  • $default_editable (boolean)
Since: gtk+ 2.6 πŸŽ€

$buffer->begin_user_action

no args, she just ✨begins✨ the user action. no cap.


(start, end) = $buffer->get_bounds

grabs the very first and very last iterators in the buffer, i.e. the entire buffer lies within the range (start,end). the whole thing, the entire buffet πŸ“


integer = $buffer->get_char_count


$buffer->copy_clipboard ($clipboard)

  • $clipboard (Gtk2::Clipboard)
Since: gtk+ 2.2 πŸŽ€

targetlist = $buffer->get_copy_target_list

Since: gtk+ 2.10 πŸŽ€

textchildanchor = $buffer->create_child_anchor ($iter)

  • $iter (Gtk2::TextIter)

textmark = $buffer->create_mark ($mark_name, $where, $left_gravity)

  • $mark_name (string or undef)
  • $where (Gtk2::TextIter)
  • $left_gravity (boolean)

texttag = $buffer->create_tag ($tag_name, $property_name1, $property_value1, ...)

  • $tag_name (string or undef)
  • $property_name1 (string) the first property name
  • $property_value1 (string) the first property value
  • ... (list) pairs of names and values

like, pairs bestie. names and values, hand in hand πŸ’ž


$buffer->cut_clipboard ($clipboard, $default_editable)

  • $clipboard (Gtk2::Clipboard)
  • $default_editable (boolean)
Since: gtk+ 2.2 πŸŽ€

$buffer->delete ($start, $end)

  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

boolean = $buffer->delete_interactive ($start_iter, $end_iter, $default_editable)

  • $start_iter (Gtk2::TextIter)
  • $end_iter (Gtk2::TextIter)
  • $default_editable (boolean)

$buffer->delete_mark ($mark)

  • $mark (Gtk2::TextMark)

$buffer->delete_mark_by_name ($name)

  • $name (string)

boolean = $buffer->delete_selection ($interactive, $default_editable)

  • $interactive (boolean)
  • $default_editable (boolean)

$register_buffer->deserialize ($content_buffer, $format, $iter, $data)

  • $content_buffer (Gtk2::TextBuffer)
  • $format (Gtk2::Gdk::Atom)
  • $iter (Gtk2::TextIter)
  • $data (scalar)
may croak with a Glib::Error in $@ on failure 😭 keep that in mind fr fr

list = $buffer->get_deserialize_formats


boolean = $buffer->deserialize_get_can_create_tags ($format)

  • $format (Gtk2::Gdk::Atom)

$buffer->deserialize_set_can_create_tags ($format, $can_create_tags)

  • $format (Gtk2::Gdk::Atom)
  • $can_create_tags (boolean)

textiter = $buffer->get_end_iter


$buffer->end_user_action

the ✨closing✨ of the user action era πŸ¦‹


boolean = $buffer->get_has_selection

Since: gtk+ 2.10 πŸŽ€

$buffer->insert ($iter, $text)

  • $iter (Gtk2::TextIter)
  • $text (string)

$buffer->insert_at_cursor ($text)

  • $text (string)

$buffer->insert_child_anchor ($iter, $anchor)

  • $iter (Gtk2::TextIter)
  • $anchor (Gtk2::TextChildAnchor)

textmark = $buffer->get_insert


boolean = $buffer->insert_interactive ($iter, $text, $default_editable)

  • $iter (Gtk2::TextIter)
  • $text (string)
  • $default_editable (boolean)

boolean = $buffer->insert_interactive_at_cursor ($text, $default_editable)

  • $text (string)
  • $default_editable (boolean)

$buffer->insert_pixbuf ($iter, $pixbuf)

  • $iter (Gtk2::TextIter)
  • $pixbuf (Gtk2::Gdk::Pixbuf)

$buffer->insert_range ($iter, $start, $end)

  • $iter (Gtk2::TextIter)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

boolean = $buffer->insert_range_interactive ($iter, $start, $end, $default_editable)

  • $iter (Gtk2::TextIter)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)
  • $default_editable (boolean)

$buffer->insert_with_tags ($iter, $text, ...)

  • $iter (Gtk2::TextIter)
  • $text (string)
  • ... (list) of Gtk2::TextTag's

$buffer->insert_with_tags_by_name ($iter, $text, ...)

  • $iter (Gtk2::TextIter)
  • $text (string)
  • ... (list) of strings, tag names

textiter = $buffer->get_iter_at_child_anchor ($anchor)

  • $anchor (Gtk2::TextChildAnchor)

textiter = $buffer->get_iter_at_line ($line_number)

  • $line_number (integer)

textiter = $buffer->get_iter_at_line_index ($line_number, $byte_index)

  • $line_number (integer)
  • $byte_index (integer)

textiter = $buffer->get_iter_at_line_offset ($line_number, $char_offset)

  • $line_number (integer)
  • $char_offset (integer)

textiter = $buffer->get_iter_at_mark ($mark)

  • $mark (Gtk2::TextMark)

textiter = $buffer->get_iter_at_offset ($char_offset)

  • $char_offset (integer)

integer = $buffer->get_line_count


textmark or undef = $buffer->get_mark ($name)

  • $name (string)

boolean = $buffer->get_modified


$buffer->set_modified ($setting)

  • $setting (boolean)

$buffer->move_mark ($mark, $where)

  • $mark (Gtk2::TextMark)
  • $where (Gtk2::TextIter)

$buffer->move_mark_by_name ($name, $where)

  • $name (string)
  • $where (Gtk2::TextIter)

$buffer->paste_clipboard ($clipboard, $override_location, $default_editable)

  • $clipboard (Gtk2::Clipboard)
  • $override_location (Gtk2::TextIter or undef)
  • $default_editable (boolean)
Since: gtk+ 2.2 πŸŽ€

targetlist = $buffer->get_paste_target_list

Since: gtk+ 2.10 πŸŽ€

$buffer->place_cursor ($where)

  • $where (Gtk2::TextIter)

atom = $buffer->register_deserialize_format ($mime_type, $function, $user_data=undef)

  • $mime_type (string)
  • $function (scalar)
  • $user_data (scalar)

atom = $buffer->register_deserialize_tagset ($tagset_name)

  • $tagset_name (string or undef)

atom = $buffer->register_serialize_format ($mime_type, $function, $user_data=undef)

  • $mime_type (string)
  • $function (scalar)
  • $user_data (scalar)

atom = $buffer->register_serialize_tagset ($tagset_name)

  • $tagset_name (string or undef)

$buffer->remove_all_tags ($start, $end)

  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

$buffer->remove_selection_clipboard ($clipboard)

  • $clipboard (Gtk2::Clipboard)
Since: gtk+ 2.2 πŸŽ€

$buffer->remove_tag ($tag, $start, $end)

  • $tag (Gtk2::TextTag)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

$buffer->remove_tag_by_name ($name, $start, $end)

  • $name (string)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

$buffer->select_range ($ins, $bound)

  • $ins (Gtk2::TextIter)
  • $bound (Gtk2::TextIter)
Since: gtk+ 2.4 πŸŽ€

textmark = $buffer->get_selection_bound


(start, end) = $buffer->get_selection_bounds

returns start and end if some text is selected, empty otherwise; places the bounds of the selection in start and end (if the selection has length 0, then start and end are filled in with the same value). start and end will be in ascending order. so organised of her ✨


scalar = $register_buffer->serialize ($content_buffer, $format, $start, $end)

  • $content_buffer (Gtk2::TextBuffer)
  • $format (Gtk2::Gdk::Atom)
  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)

list = $buffer->get_serialize_formats


string = $buffer->get_slice ($start, $end, $include_hidden_chars)

  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)
  • $include_hidden_chars (boolean)

textiter = $buffer->get_start_iter


texttagtable = $buffer->get_tag_table


string = $buffer->get_text ($start, $end, $include_hidden_chars)

  • $start (Gtk2::TextIter)
  • $end (Gtk2::TextIter)
  • $include_hidden_chars (boolean)

$buffer->set_text ($text)

  • $text (string)

$buffer->unregister_deserialize_format ($format)

  • $format (Gtk2::Gdk::Atom)

$buffer->unregister_serialize_format ($format)

  • $format (Gtk2::Gdk::Atom)

πŸŽ€ PROPERTIES πŸŽ€

  • 'copy-target-list' (Gtk2::TargetList : default undef : readable / private / static-nick / static-blurb) β€” the list of targets this buffer supports for clipboard copying and DND source
  • 'cursor-position' (integer : default 0 : readable / private / static-nick / static-blurb) β€” the position of the insert mark (as offset from the beginning of the buffer)
  • 'has-selection' (boolean : default false : readable / private / static-nick / static-blurb) β€” whether the buffer has some text currently selected
  • 'paste-target-list' (Gtk2::TargetList : default undef : readable / private / static-nick / static-blurb) β€” the list of targets this buffer supports for clipboard pasting and DND destination
  • 'tag-table' (Gtk2::TextTagTable : default undef : readable / writable / construct-only / private / static-nick / static-blurb) β€” Text Tag Table
  • 'text' (string : default "" : readable / writable / private / static-nick / static-blurb) β€” Current text of the buffer

πŸ”₯ SIGNALS πŸ”₯

the whole squad, in order, no skips bestie:

  • apply-tag (Gtk2::TextBuffer, Gtk2::TextTag, Gtk2::TextIter, Gtk2::TextIter)
  • begin-user-action (Gtk2::TextBuffer)
  • changed (Gtk2::TextBuffer)
  • delete-range (Gtk2::TextBuffer, Gtk2::TextIter, Gtk2::TextIter)
  • end-user-action (Gtk2::TextBuffer)
  • insert-child-anchor (Gtk2::TextBuffer, Gtk2::TextIter, Gtk2::TextChildAnchor)
  • insert-pixbuf (Gtk2::TextBuffer, Gtk2::TextIter, Gtk2::Gdk::Pixbuf)
  • insert-text (Gtk2::TextBuffer, Gtk2::TextIter, string, integer)
  • mark-deleted (Gtk2::TextBuffer, Gtk2::TextMark)
  • mark-set (Gtk2::TextBuffer, Gtk2::TextIter, Gtk2::TextMark)
  • modified-changed (Gtk2::TextBuffer)
  • paste-done (Gtk2::TextBuffer, Gtk2::Clipboard)
  • remove-tag (Gtk2::TextBuffer, Gtk2::TextTag, Gtk2::TextIter, Gtk2::TextIter)

πŸ‘€ SEE ALSO

  • Gtk2
  • Glib::Object

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Gtk2 for a full notice.


and that's the whole page bestie!! πŸ’œ this one shipped in perl v5.42.0 dated 2025-07-25, and ngl, that's a whole era ago. go forth and buffer your text, you absolute icon πŸŒΈβœ¨πŸ¦‹

πŸ“¦ where this page comes from