class Gtk::TextBuffer
- Gtk::TextBuffer
- GObject::Object
- Reference
- Object
Overview
Stores text and attributes for display in a Gtk::TextView
.
You may wish to begin by reading the text widget conceptual overview, which gives an overview of all the objects and data types related to the text widget and how they work together.
Gtk::TextBuffer can support undoing changes to the buffer
content, see Gtk::TextBuffer#enable_undo=
.
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/text_buffer.crConstructors
-
.new(table : Gtk::TextTagTable | Nil) : self
Creates a new text buffer.
-
.new
Initialize a new
TextBuffer
. - .new(*, can_redo : Bool | Nil = nil, can_undo : Bool | Nil = nil, cursor_position : Int32 | Nil = nil, enable_undo : Bool | Nil = nil, has_selection : Bool | Nil = nil, tag_table : Gtk::TextTagTable | Nil = nil, text : String | Nil = nil)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. -
#add_mark(mark : Gtk::TextMark, where : Gtk::TextIter) : Nil
Adds the mark at position where.
-
#add_selection_clipboard(clipboard : Gdk::Clipboard) : Nil
Adds clipboard to the list of clipboards in which the selection contents of buffer are available.
-
#apply_tag(tag : Gtk::TextTag, start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Emits the “apply-tag” signal on buffer.
-
#apply_tag_by_name(name : String, start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Emits the “apply-tag” signal on buffer.
- #apply_tag_signal
-
#backspace(iter : Gtk::TextIter, interactive : Bool, default_editable : Bool) : Bool
Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by iter.
-
#begin_irreversible_action : Nil
Denotes the beginning of an action that may not be undone.
-
#begin_user_action : Nil
Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation.
- #begin_user_action_signal
-
#bounds : Gtk::TextIter
Retrieves the first and last iterators in the buffer, i.e.
-
#can_redo : Bool
Gets whether there is a redoable action in the history.
- #can_redo? : Bool
-
#can_undo : Bool
Gets whether there is an undoable action in the history.
- #can_undo? : Bool
- #changed_signal
-
#char_count : Int32
Gets the number of characters in the buffer.
-
#copy_clipboard(clipboard : Gdk::Clipboard) : Nil
Copies the currently-selected text to a clipboard.
-
#create_child_anchor(iter : Gtk::TextIter) : Gtk::TextChildAnchor
Creates and inserts a child anchor.
-
#create_mark(mark_name : String | Nil, where : Gtk::TextIter, left_gravity : Bool) : Gtk::TextMark
Creates a mark at position where.
- #cursor_position : Int32
-
#cut_clipboard(clipboard : Gdk::Clipboard, default_editable : Bool) : Nil
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
-
#delete(start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Deletes text between start and end.
-
#delete_interactive(start_iter : Gtk::TextIter, end_iter : Gtk::TextIter, default_editable : Bool) : Bool
Deletes all editable text in the given range.
-
#delete_mark(mark : Gtk::TextMark) : Nil
Deletes mark, so that it’s no longer located anywhere in the buffer.
-
#delete_mark_by_name(name : String) : Nil
Deletes the mark named name; the mark must exist.
- #delete_range_signal
-
#delete_selection(interactive : Bool, default_editable : Bool) : Bool
Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
-
#enable_undo : Bool
Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
-
#enable_undo=(enable_undo : Bool) : Nil
Sets whether or not to enable undoable actions in the text buffer.
- #enable_undo? : Bool
-
#end_irreversible_action : Nil
Denotes the end of an action that may not be undone.
-
#end_iter : Gtk::TextIter
Initializes iter with the “end iterator,” one past the last valid character in the text buffer.
-
#end_user_action : Nil
Ends a user-visible operation.
- #end_user_action_signal
-
#has_selection : Bool
Indicates whether the buffer has some text currently selected.
- #has_selection? : Bool
-
#hash(hasher)
See
Object#hash(hasher)
-
#insert(iter : Gtk::TextIter, text : String, len : Int32) : Nil
Inserts len bytes of text at position iter.
-
#insert : Gtk::TextMark
Returns the mark that represents the cursor (insertion point).
-
#insert_at_cursor(text : String, len : Int32) : Nil
Inserts text in buffer.
-
#insert_child_anchor(iter : Gtk::TextIter, anchor : Gtk::TextChildAnchor) : Nil
Inserts a child widget anchor into the text buffer at iter.
- #insert_child_anchor_signal
-
#insert_interactive(iter : Gtk::TextIter, text : String, len : Int32, default_editable : Bool) : Bool
Inserts text in buffer.
-
#insert_interactive_at_cursor(text : String, len : Int32, default_editable : Bool) : Bool
Inserts text in buffer.
-
#insert_markup(iter : Gtk::TextIter, markup : String, len : Int32) : Nil
Inserts the text in markup at position iter.
-
#insert_paintable(iter : Gtk::TextIter, paintable : Gdk::Paintable) : Nil
Inserts an image into the text buffer at iter.
- #insert_paintable_signal
-
#insert_range(iter : Gtk::TextIter, start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Copies text, tags, and paintables between start and end and inserts the copy at iter.
-
#insert_range_interactive(iter : Gtk::TextIter, start : Gtk::TextIter, end _end : Gtk::TextIter, default_editable : Bool) : Bool
Copies text, tags, and paintables between start and end and inserts the copy at iter.
- #insert_text_signal
-
#iter_at_child_anchor(anchor : Gtk::TextChildAnchor) : Gtk::TextIter
Obtains the location of anchor within buffer.
-
#iter_at_line(line_number : Int32) : Gtk::TextIter
Initializes iter to the start of the given line.
-
#iter_at_line_index(line_number : Int32, byte_index : Int32) : Gtk::TextIter
Obtains an iterator pointing to byte_index within the given line.
-
#iter_at_line_offset(line_number : Int32, char_offset : Int32) : Gtk::TextIter
Obtains an iterator pointing to char_offset within the given line.
-
#iter_at_mark(mark : Gtk::TextMark) : Gtk::TextIter
Initializes iter with the current position of mark.
-
#iter_at_offset(char_offset : Int32) : Gtk::TextIter
Initializes iter to a position char_offset chars from the start of the entire buffer.
-
#line_count : Int32
Obtains the number of lines in the buffer.
-
#mark(name : String) : Gtk::TextMark | Nil
Returns the mark named name in buffer buffer, or
nil
if no such mark exists in the buffer. - #mark_deleted_signal
- #mark_set_signal
-
#max_undo_levels : UInt32
Gets the maximum number of undo levels to perform.
-
#max_undo_levels=(max_undo_levels : UInt32) : Nil
Sets the maximum number of undo levels to perform.
-
#modified : Bool
Indicates whether the buffer has been modified since the last call to
Gtk::TextBuffer#modified=
set the modification flag tofalse
. -
#modified=(setting : Bool) : Nil
Used to keep track of whether the buffer has been modified since the last time it was saved.
- #modified_changed_signal
-
#move_mark(mark : Gtk::TextMark, where : Gtk::TextIter) : Nil
Moves mark to the new location where.
-
#move_mark_by_name(name : String, where : Gtk::TextIter) : Nil
Moves the mark named name (which must exist) to location where.
-
#paste_clipboard(clipboard : Gdk::Clipboard, override_location : Gtk::TextIter | Nil, default_editable : Bool) : Nil
Pastes the contents of a clipboard.
- #paste_done_signal
-
#place_cursor(where : Gtk::TextIter) : Nil
This function moves the “insert” and “selection_bound” marks simultaneously.
-
#redo : Nil
Redoes the next redoable action on the buffer, if there is one.
- #redo_signal
-
#remove_all_tags(start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Removes all tags in the range between start and end.
-
#remove_selection_clipboard(clipboard : Gdk::Clipboard) : Nil
Removes a
Gdk::Clipboard
added with gtk_text_buffer_add_selection_clipboard(). -
#remove_tag(tag : Gtk::TextTag, start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Emits the “remove-tag” signal.
-
#remove_tag_by_name(name : String, start : Gtk::TextIter, end _end : Gtk::TextIter) : Nil
Emits the “remove-tag” signal.
- #remove_tag_signal
-
#select_range(ins : Gtk::TextIter, bound : Gtk::TextIter) : Nil
This function moves the “insert” and “selection_bound” marks simultaneously.
-
#selection_bound : Gtk::TextMark
Returns the mark that represents the selection bound.
-
#selection_bounds : Gtk::TextIter
Returns
true
if some text is selected; places the bounds of the selection in start and end. -
#selection_content : Gdk::ContentProvider
Get a content provider for this buffer.
-
#set_text(text : String, len : Int32) : Nil
Deletes current contents of buffer, and inserts text instead.
-
#slice(start : Gtk::TextIter, end _end : Gtk::TextIter, include_hidden_chars : Bool) : String
Returns the text in the range [@start,@end).
-
#start_iter : Gtk::TextIter
Initialized iter with the first position in the text buffer.
-
#tag_table : Gtk::TextTagTable
Get the
Gtk::TextTagTable
associated with this buffer. - #tag_table=(value : Gtk::TextTagTable | Nil) : Gtk::TextTagTable | Nil
-
#text(start : Gtk::TextIter, end _end : Gtk::TextIter, include_hidden_chars : Bool) : String
Returns the text in the range [@start,@end).
- #text : String
- #text=(value : String) : String
-
#text=(value : Nil) : Nil
Set
#text
property to nil. -
#text? : String | Nil
Same as
#text
, but can return nil. -
#undo : Nil
Undoes the last undoable action on the buffer, if there is one.
- #undo_signal
Instance methods inherited from class GObject::Object
==(other : self)
==,
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void) | Nil
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
hash(hasher)
hash,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void) | Nil
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void) | Nil) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void) | Nil
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void) | Nil
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
cast?(obj : GObject::Object) : self | Nil
cast?,
compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Macros inherited from class GObject::Object
previous_vfunc(*args)
previous_vfunc,
previous_vfunc!(*args)
previous_vfunc!,
signal(signature)
signal
Constructor Detail
Class Method Detail
Returns the type id (GType) registered in GLib type system.
Instance Method Detail
Returns true
if this reference is the same as other. Invokes same?
.
Adds the mark at position where.
The mark must not be added to another buffer, and if its name
is not nil
then there must not be another mark in the buffer
with the same name.
Emits the [signal@Gtk.TextBuffer::mark-set] signal as notification of the mark's initial placement.
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#primary_clipboard
for a view of buffer.
Emits the “apply-tag” signal on buffer.
The default handler for the signal applies tag to the given range. start and end do not have to be in order.
Emits the “apply-tag” signal on buffer.
Calls Gtk::TextTagTable#lookup
on the buffer’s
tag table to get a Gtk::TextTag
, then calls
Gtk::TextBuffer#apply_tag
.
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 function; however, the iter will be re-initialized to point to the location where text was deleted.
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
Gtk::TextBuffer#end_irreversible_action
after the irreversible
action has completed.
You may nest calls to gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.
Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation.
The operations between gtk_text_buffer_begin_user_action() and
gtk_text_buffer_end_user_action() can then be grouped when creating
an undo stack. Gtk::TextBuffer
maintains a count of calls to
gtk_text_buffer_begin_user_action() that have not been closed with
a call to gtk_text_buffer_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
Gtk::TextBuffer#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.
Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [@start,@end).
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.
Copies the currently-selected text to a clipboard.
Creates and inserts a child anchor.
This is a convenience function which simply creates a child anchor
with Gtk::TextChildAnchor.new
and inserts it into the buffer
with Gtk::TextBuffer#insert_child_anchor
.
The new anchor is owned by the buffer; no reference count is returned to the caller of this function.
Creates a mark at position where.
If mark_name is nil
, the mark is anonymous; otherwise, the mark
can be retrieved by name using Gtk::TextBuffer#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).
The caller of this function does not own a
reference to the returned Gtk::TextMark
, so you can ignore the
return value if you like. Marks are owned by the buffer and go
away when the buffer does.
Emits the [signal@Gtk.TextBuffer::mark-set] signal as notification of the mark's initial placement.
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
Deletes text between start and end.
The order of start and end is not actually relevant; gtk_text_buffer_delete() will reorder them.
This function actually emits the “delete-range” signal, and the default handler of that signal deletes the text. Because the buffer is modified, all outstanding iterators become invalid after calling this function; however, the start and end will be re-initialized to point to the location where text was deleted.
Deletes all editable text in the given range.
Calls Gtk::TextBuffer#delete
for each editable
sub-range of [@start,@end). start and end are revalidated
to point to the location of the last deleted range, or left
untouched if no text was deleted.
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 haven’t called g_object_ref() on the mark, it will be freed.
Even if the mark isn’t freed, most operations on mark become
invalid, until it gets added to a buffer again with
Gtk::TextBuffer#add_mark
. Use Gtk::TextMark#deleted
to find out if a mark has been removed from its buffer.
The [signal@Gtk.TextBuffer::mark-deleted] signal will be emitted as notification after the mark is deleted.
Deletes the mark named name; the mark must exist.
See Gtk::TextBuffer#delete_mark
for details.
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).
Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
See Gtk::TextBuffer#begin_irreversible_action
and
Gtk::TextBuffer#end_irreversible_action
to create
changes to the buffer that cannot be undone.
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 Gtk::TextBuffer#max_undo_levels
.
See Gtk::TextBuffer#begin_irreversible_action
and
Gtk::TextBuffer#end_irreversible_action
to create
changes to the buffer that cannot be undone.
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 Gtk::TextBuffer#begin_irreversible_action
was called.
You may nest calls to gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.
Initializes iter with the “end iterator,” one past the last valid character in the text buffer.
If dereferenced with Gtk::TextIter#char
, the end
iterator has a character value of 0.
The entire buffer lies in the range from the first position in
the buffer (call Gtk::TextBuffer#start_iter
to get
character position 0) to the end iterator.
Ends a user-visible operation.
Should be paired with a call to
Gtk::TextBuffer#begin_user_action
.
See that function for a full explanation.
Indicates whether the buffer has some text currently selected.
Inserts len bytes of text at position iter.
If len is -1, text must be nul-terminated and will be inserted in its entirety. Emits the “insert-text” signal; insertion actually occurs in the default handler for the signal. iter is invalidated when insertion occurs (because the buffer contents change), but the default signal handler revalidates it to point to the end of the inserted text.
Returns the mark that represents the cursor (insertion point).
Equivalent to calling Gtk::TextBuffer#mark
to get the mark named “insert”, but very slightly more
efficient, and involves less typing.
Inserts text in buffer.
Simply calls Gtk::TextBuffer#insert
,
using the current cursor position as the insertion point.
Inserts a child widget anchor into the text buffer at iter.
The anchor will be counted as one character in character counts, and
when obtaining the buffer contents as a string, will be represented
by the Unicode “object replacement character” 0xFFFC. Note that the
“slice” variants for obtaining portions of the buffer as a string
include this character for child anchors, but the “text” variants do
not. E.g. see Gtk::TextBuffer#slice
and
Gtk::TextBuffer#text
.
Consider Gtk::TextBuffer#create_child_anchor
as a more
convenient alternative to this function. The buffer will add a
reference to the anchor, so you can unref it after insertion.
Inserts text in buffer.
Like Gtk::TextBuffer#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#editable
is appropriate here.
Inserts text in buffer.
Calls Gtk::TextBuffer#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#editable
is appropriate here.
Inserts the text in markup at position iter. markup will be inserted in its entirety and must be nul-terminated and valid UTF-8. Emits the [signal@Gtk.TextBuffer::insert-text] signal, possibly multiple times; insertion actually occurs in the default handler for the signal. iter will point to the end of the inserted text on return.
Inserts an image into the text buffer at iter.
The image will be counted as one character in character counts,
and when obtaining the buffer contents as a string, will be
represented by the Unicode “object replacement character” 0xFFFC.
Note that the “slice” variants for obtaining portions of the buffer
as a string include this character for paintable, but the “text”
variants do not. e.g. see Gtk::TextBuffer#slice
and
Gtk::TextBuffer#text
.
Copies text, tags, and paintables between start and end and inserts the copy at iter.
The order of start and end doesn’t matter.
Used instead of simply getting/inserting text because it preserves images and tags. If start and end are in a different buffer from buffer, the two buffers must share the same tag table.
Implemented via emissions of the ::insert-text and ::apply-tag signals, so expect those.
Copies text, tags, and paintables between start and end and inserts the copy at iter.
Same as Gtk::TextBuffer#insert_range
, but does nothing
if the insertion point isn’t editable. The default_editable
parameter indicates whether the text is editable at iter if
no tags enclosing iter affect editability. Typically the result
of Gtk::TextView#editable
is appropriate here.
Obtains the location of anchor within buffer.
Initializes iter to the start of the given line.
If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned.
Obtains an iterator pointing to byte_index within the given line. byte_index must be the start of a UTF-8 character. Note bytes, not characters; UTF-8 may encode one character as multiple bytes.
If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned. And if byte_index is off the end of the line, the iterator at the end of the line is returned.
Obtains an iterator pointing to char_offset within the given line.
Note characters, not bytes; UTF-8 may encode one character as multiple bytes.
If line_number is greater than or equal to the number of lines in the buffer, the end iterator is returned. And if char_offset is off the end of the line, the iterator at the end of the line is returned.
Initializes iter with the current position of mark.
Initializes iter to a position char_offset chars from the start of the entire buffer.
If char_offset is -1 or greater than the number of characters in the buffer, iter is initialized to the end iterator, the iterator one past the last valid character in the buffer.
Obtains the number of lines in the buffer.
This value is cached, so the function is very fast.
Returns the mark named name in buffer buffer, or nil
if no such
mark exists in the buffer.
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.
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.
Indicates whether the buffer has been modified since the last call
to Gtk::TextBuffer#modified=
set the modification flag to
false
.
Used for example to enable a “save” function in a text editor.
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 (@buffer, FALSE)
.
When the buffer is modified, it will automatically
toggled on the modified bit again. When the modified
bit flips, the buffer emits the
[signal@Gtk.TextBuffer::modified-changed] signal.
Moves mark to the new location where.
Emits the [signal@Gtk.TextBuffer::mark-set] signal as notification of the move.
Moves the mark named name (which must exist) to location where.
See Gtk::TextBuffer#move_mark
for details.
Pastes the contents of a clipboard.
If override_location is nil
, 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.
This function moves the “insert” and “selection_bound” marks simultaneously.
If you move them to the same place in two steps with
Gtk::TextBuffer#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.
Removes all tags in the range between start and 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.
Removes a Gdk::Clipboard
added with
gtk_text_buffer_add_selection_clipboard().
Emits the “remove-tag” signal.
The default handler for the signal removes all occurrences of tag from the given range. start and end don’t have to be in order.
Emits the “remove-tag” signal.
Calls Gtk::TextTagTable#lookup
on the buffer’s
tag table to get a Gtk::TextTag
, then calls
Gtk::TextBuffer#remove_tag
.
This function moves the “insert” and “selection_bound” marks simultaneously.
If you move them in two steps with
Gtk::TextBuffer#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.
Returns the mark that represents the selection bound.
Equivalent to calling Gtk::TextBuffer#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.
Gtk::TextBuffer#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 true
if some text is selected; 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.
If start and end are nil
, then they are not filled in, but the
return value still indicates whether text is selected.
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#content=
.
Deletes current contents of buffer, and inserts text instead.
If len is -1, text must be nul-terminated. text must be valid UTF-8.
Initialized iter with the first position in the text buffer.
This is the same as using Gtk::TextBuffer#iter_at_offset
to get the iter at character offset 0.