TextBuffer
Object Hierarchy:
Description:
You may wish to begin by reading the [text widget conceptual overview](TextWidget.
html) which gives an overview of all the objects and data types related to the text widget and how they work together.
Namespace: Gtk
Package: gtk+-3.0
Content:
Properties:
- public TargetList copy_target_list { get; }
The list of targets this buffer supports for clipboard copying and as DND source.
- public int cursor_position { get; }
The position of the insert mark (as offset from the beginning of the buffer) .
- public bool has_selection { get; }
Whether the buffer has some text currently selected.
- public TargetList paste_target_list { get; }
The list of targets this buffer supports for clipboard pasting and as DND destination.
- public TextTagTable tag_table { get; construct; }
- public string text { owned get; set; }
The text content of the buffer.
Creation methods:
- public TextBuffer (TextTagTable? table)
Creates a new text buffer.
Methods:
- public void @delete (ref TextIter start, ref TextIter end)
Deletes text between
start
andend
. - public void add_mark (TextMark mark, TextIter where)
Adds the mark at position
where
. - public void add_selection_clipboard (Clipboard clipboard)
Adds
clipboard
to the list of clipboards in which the selection contents of this are available. - public void apply_tag_by_name (string name, TextIter start, TextIter end)
- public bool backspace (ref TextIter iter, bool interactive, bool default_editable)
Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by
iter
. - public void copy_clipboard (Clipboard clipboard)
Copies the currently-selected text to a clipboard.
- public unowned TextChildAnchor create_child_anchor (TextIter iter)
This is a convenience function which simply creates a child anchor with TextChildAnchor and inserts it into the buffer with insert_child_anchor.
- public unowned TextMark create_mark (string? mark_name, TextIter where, bool left_gravity)
Creates a mark at position
where
. - public unowned TextTag create_tag (string? tag_name, ...)
Creates a tag and adds it to the tag table for this.
- public void cut_clipboard (Clipboard clipboard, bool default_editable)
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
- public bool delete_interactive (ref TextIter start_iter, ref TextIter end_iter, bool default_editable)
Deletes all editable text in the given range.
- public void delete_mark (TextMark mark)
Deletes
mark
, so that it’s no longer located anywhere in the buffer. - public void delete_mark_by_name (string name)
Deletes the mark named
name
; the mark must exist. - public bool delete_selection (bool interactive, bool default_editable)
Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
- public bool deserialize (TextBuffer content_buffer, Atom format, TextIter iter, uint8[] data) throws Error
This function deserializes rich text in format
format
and inserts it atiter
. - public bool deserialize_get_can_create_tags (Atom format)
This functions returns the value set with deserialize_set_can_create_tags
- public void deserialize_set_can_create_tags (Atom format, bool can_create_tags)
Use this function to allow a rich text deserialization function to create new tags in the receiving buffer.
- public void get_bounds (out TextIter start, out TextIter end)
Retrieves the first and last iterators in the buffer, i.
- public int get_char_count ()
Gets the number of characters in the buffer; note that characters and bytes are not the same, you can’t e.
- public unowned TargetList get_copy_target_list ()
This function returns the list of targets this text buffer can provide for copying and as DND source.
- public Atom[] get_deserialize_formats ()
This function returns the rich text deserialize formats registered with this using register_deserialize_format or register_deserialize_tagset
- public void get_end_iter (out TextIter iter)
Initializes
iter
with the “end iterator,” one past the last valid character in the text buffer. - public bool get_has_selection ()
Indicates whether the buffer has some text currently selected.
- public unowned TextMark get_insert ()
Returns the mark that represents the cursor (insertion point).
- public void get_iter_at_child_anchor (out TextIter iter, TextChildAnchor anchor)
Obtains the location of
anchor
within this. - public void get_iter_at_line (out TextIter iter, int line_number)
Initializes
iter
to the start of the given line. - public void get_iter_at_line_index (out TextIter iter, int line_number, int byte_index)
Obtains an iterator pointing to
byte_index
within the given line. - public void get_iter_at_line_offset (out TextIter iter, int line_number, int char_offset)
Obtains an iterator pointing to
char_offset
within the given line. - public void get_iter_at_mark (out TextIter iter, TextMark mark)
Initializes
iter
with the current position ofmark
. - public void get_iter_at_offset (out TextIter iter, int char_offset)
Initializes
iter
to a positionchar_offset
chars from the start of the entire buffer. - public int get_line_count ()
Obtains the number of lines in the buffer.
- public unowned TextMark? get_mark (string name)
Returns the mark named
name
in buffer this, or null if no such mark exists in the buffer. - public bool get_modified ()
Indicates whether the buffer has been modified since the last call to set_modified set the modification flag to false.
- public unowned TargetList get_paste_target_list ()
This function returns the list of targets this text buffer supports for pasting and as DND destination.
- public unowned TextMark get_selection_bound ()
Returns the mark that represents the selection bound.
- public bool get_selection_bounds (out TextIter start, out TextIter end)
Returns true if some text is selected; places the bounds of the selection in
start
andend
(if the selection has length 0, thenstart
andend
are filled in with the same value). - public Atom[] get_serialize_formats ()
This function returns the rich text serialize formats registered with this using register_serialize_format or register_serialize_tagset
- public string get_slice (TextIter start, TextIter end, bool include_hidden_chars)
Returns the text in the range [
start
,end
). - public void get_start_iter (out TextIter iter)
Initialized
iter
with the first position in the text buffer. - public unowned TextTagTable get_tag_table ()
Get the TextTagTable associated with this buffer.
- public string get_text (TextIter start, TextIter end, bool include_hidden_chars)
Returns the text in the range [
start
,end
). - public void insert (ref TextIter iter, string text, int len)
Inserts
len
bytes oftext
at positioniter
. - public void insert_at_cursor (string text, int len)
Simply calls insert, using the current cursor position as the insertion point.
- public bool insert_interactive (ref TextIter iter, string text, int len, bool default_editable)
Like insert , but the insertion will not occur if
iter
is at a non-editable location in the buffer. - public bool insert_interactive_at_cursor (string text, int len, bool default_editable)
Calls insert_interactive at the cursor position.
- public void insert_markup (ref TextIter iter, string markup, int len)
Inserts the text in
markup
at positioniter
. - public void insert_range (ref TextIter iter, TextIter start, TextIter end)
Copies text, tags, and pixbufs between
start
andend
(the order ofstart
andend
doesn’t matter) and inserts the copy atiter
. - public bool insert_range_interactive (ref TextIter iter, TextIter start, TextIter end, bool default_editable)
Same as insert_range, but does nothing if the insertion point isn’t editable.
- public void insert_with_tags (ref TextIter iter, string text, int len, ...)
Inserts
text
into this atiter
, applying the list of tags to the newly-inserted text. - public void insert_with_tags_by_name (ref TextIter iter, string text, int len, ...)
Same as insert_with_tags, but allows you to pass in tag names instead of tag objects.
- public void move_mark (TextMark mark, TextIter where)
Moves
mark
to the new locationwhere
. - public void move_mark_by_name (string name, TextIter where)
Moves the mark named
name
(which must exist) to locationwhere
. - public void paste_clipboard (Clipboard clipboard, TextIter? override_location, bool default_editable)
Pastes the contents of a clipboard.
- public void place_cursor (TextIter where)
This function moves the “insert” and “selection_bound” marks simultaneously.
- public Atom register_deserialize_format (string mime_type, owned TextBufferDeserializeFunc function)
This function registers a rich text deserialization
function
along with itsmime_type
with the passed this. - public Atom register_deserialize_tagset (string? tagset_name)
This function registers GTK+’s internal rich text serialization format with the passed this.
- public Atom register_serialize_format (string mime_type, owned TextBufferSerializeFunc function)
This function registers a rich text serialization
function
along with itsmime_type
with the passed this. - public Atom register_serialize_tagset (string? tagset_name)
This function registers GTK+’s internal rich text serialization format with the passed this.
- public void remove_all_tags (TextIter start, TextIter end)
Removes all tags in the range between
start
andend
. - public void remove_selection_clipboard (Clipboard clipboard)
Removes a Clipboard added with add_selection_clipboard.
- public void remove_tag_by_name (string name, TextIter start, TextIter end)
Calls lookup on the buffer’s tag table to get a TextTag, then calls remove_tag.
- public void select_range (TextIter ins, TextIter bound)
This function moves the “insert” and “selection_bound” marks simultaneously.
- public uint8[] serialize (TextBuffer content_buffer, Atom format, TextIter start, TextIter end)
This function serializes the portion of text between
start
andend
in the rich text format represented byformat
. - public void set_modified (bool setting)
Used to keep track of whether the buffer has been modified since the last time it was saved.
- public void set_text (string text, int len = -1)
Deletes current contents of this, and inserts
text
instead. - public void unregister_deserialize_format (Atom format)
This function unregisters a rich text format that was previously registered using register_deserialize_format or register_deserialize_tagset.
- public void unregister_serialize_format (Atom format)
This function unregisters a rich text format that was previously registered using register_serialize_format or register_serialize_tagset
Signals:
- public virtual signal void apply_tag (TextTag tag, TextIter start, TextIter end)
The apply_tag signal is emitted to apply a tag to a range of text in a TextBuffer.
- public virtual signal void begin_user_action ()
The begin_user_action signal is emitted at the beginning of a single user-visible operation on a TextBuffer.
- public virtual signal void changed ()
The changed signal is emitted when the content of a TextBuffer has changed.
- public virtual signal void delete_range (TextIter start, TextIter end)
The delete_range signal is emitted to delete a range from a TextBuffer.
- public virtual signal void end_user_action ()
The end_user_action signal is emitted at the end of a single user-visible operation on the TextBuffer.
- public virtual signal void insert_child_anchor (TextIter iter, TextChildAnchor anchor)
The insert_child_anchor signal is emitted to insert a TextChildAnchor in a TextBuffer.
- public virtual signal void insert_pixbuf (TextIter iter, Pixbuf pixbuf)
The insert_pixbuf signal is emitted to insert a Pixbuf in a TextBuffer.
- public virtual signal void insert_text (ref TextIter pos, string new_text, int new_text_length)
The insert_text signal is emitted to insert text in a TextBuffer.
- public virtual signal void mark_deleted (TextMark mark)
The mark_deleted signal is emitted as notification after a TextMark is deleted.
- public virtual signal void mark_set (TextIter location, TextMark mark)
The mark_set signal is emitted as notification after a TextMark is set.
- public virtual signal void modified_changed ()
The modified_changed signal is emitted when the modified bit of a TextBuffer flips.
- public virtual signal void paste_done (Clipboard clipboard)
The paste-done signal is emitted after paste operation has been completed.
- public virtual signal void remove_tag (TextTag tag, TextIter start, TextIter end)
The remove_tag signal is emitted to remove all occurrences of
tag
from a range of text in a TextBuffer.
Inherited Members:
All known members inherited from class GLib.Object