pub trait TextBufferExt:
IsA<TextBuffer>
+ Sealed
+ 'static {
Show 89 methods
// Provided methods
fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) { ... }
fn add_selection_clipboard(&self, clipboard: &Clipboard) { ... }
fn apply_tag(
&self,
tag: &impl IsA<TextTag>,
start: &TextIter,
end: &TextIter,
) { ... }
fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) { ... }
fn backspace(
&self,
iter: &mut TextIter,
interactive: bool,
default_editable: bool,
) -> bool { ... }
fn begin_irreversible_action(&self) { ... }
fn begin_user_action(&self) { ... }
fn copy_clipboard(&self, clipboard: &Clipboard) { ... }
fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor { ... }
fn create_mark(
&self,
mark_name: Option<&str>,
where_: &TextIter,
left_gravity: bool,
) -> TextMark { ... }
fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool) { ... }
fn delete(&self, start: &mut TextIter, end: &mut TextIter) { ... }
fn delete_interactive(
&self,
start_iter: &mut TextIter,
end_iter: &mut TextIter,
default_editable: bool,
) -> bool { ... }
fn delete_mark(&self, mark: &impl IsA<TextMark>) { ... }
fn delete_mark_by_name(&self, name: &str) { ... }
fn delete_selection(
&self,
interactive: bool,
default_editable: bool,
) -> bool { ... }
fn end_irreversible_action(&self) { ... }
fn end_user_action(&self) { ... }
fn bounds(&self) -> (TextIter, TextIter) { ... }
fn can_redo(&self) -> bool { ... }
fn can_undo(&self) -> bool { ... }
fn char_count(&self) -> i32 { ... }
fn enables_undo(&self) -> bool { ... }
fn end_iter(&self) -> TextIter { ... }
fn has_selection(&self) -> bool { ... }
fn get_insert(&self) -> TextMark { ... }
fn iter_at_child_anchor(
&self,
anchor: &impl IsA<TextChildAnchor>,
) -> TextIter { ... }
fn iter_at_line(&self, line_number: i32) -> Option<TextIter> { ... }
fn iter_at_line_index(
&self,
line_number: i32,
byte_index: i32,
) -> Option<TextIter> { ... }
fn iter_at_line_offset(
&self,
line_number: i32,
char_offset: i32,
) -> Option<TextIter> { ... }
fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter { ... }
fn iter_at_offset(&self, char_offset: i32) -> TextIter { ... }
fn line_count(&self) -> i32 { ... }
fn mark(&self, name: &str) -> Option<TextMark> { ... }
fn max_undo_levels(&self) -> u32 { ... }
fn is_modified(&self) -> bool { ... }
fn selection_bound(&self) -> TextMark { ... }
fn selection_bounds(&self) -> Option<(TextIter, TextIter)> { ... }
fn selection_content(&self) -> ContentProvider { ... }
fn slice(
&self,
start: &TextIter,
end: &TextIter,
include_hidden_chars: bool,
) -> GString { ... }
fn start_iter(&self) -> TextIter { ... }
fn tag_table(&self) -> TextTagTable { ... }
fn text(
&self,
start: &TextIter,
end: &TextIter,
include_hidden_chars: bool,
) -> GString { ... }
fn insert(&self, iter: &mut TextIter, text: &str) { ... }
fn insert_at_cursor(&self, text: &str) { ... }
fn insert_child_anchor(
&self,
iter: &mut TextIter,
anchor: &impl IsA<TextChildAnchor>,
) { ... }
fn insert_interactive(
&self,
iter: &mut TextIter,
text: &str,
default_editable: bool,
) -> bool { ... }
fn insert_interactive_at_cursor(
&self,
text: &str,
default_editable: bool,
) -> bool { ... }
fn insert_markup(&self, iter: &mut TextIter, markup: &str) { ... }
fn insert_paintable(
&self,
iter: &mut TextIter,
paintable: &impl IsA<Paintable>,
) { ... }
fn insert_range(
&self,
iter: &mut TextIter,
start: &TextIter,
end: &TextIter,
) { ... }
fn insert_range_interactive(
&self,
iter: &mut TextIter,
start: &TextIter,
end: &TextIter,
default_editable: bool,
) -> bool { ... }
fn move_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter) { ... }
fn move_mark_by_name(&self, name: &str, where_: &TextIter) { ... }
fn paste_clipboard(
&self,
clipboard: &Clipboard,
override_location: Option<&TextIter>,
default_editable: bool,
) { ... }
fn place_cursor(&self, where_: &TextIter) { ... }
fn redo(&self) { ... }
fn remove_all_tags(&self, start: &TextIter, end: &TextIter) { ... }
fn remove_commit_notify(&self, commit_notify_handler: u32) { ... }
fn remove_selection_clipboard(&self, clipboard: &Clipboard) { ... }
fn remove_tag(
&self,
tag: &impl IsA<TextTag>,
start: &TextIter,
end: &TextIter,
) { ... }
fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter) { ... }
fn select_range(&self, ins: &TextIter, bound: &TextIter) { ... }
fn set_enable_undo(&self, enable_undo: bool) { ... }
fn set_max_undo_levels(&self, max_undo_levels: u32) { ... }
fn set_modified(&self, setting: bool) { ... }
fn set_text(&self, text: &str) { ... }
fn undo(&self) { ... }
fn cursor_position(&self) -> i32 { ... }
fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_begin_user_action<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_end_user_action<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_insert_paintable<F: Fn(&Self, &TextIter, &Paintable) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_modified_changed<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_can_redo_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_can_undo_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_has_selection_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_text_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
}
Expand description
Provided Methods§
Sourcefn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter)
fn add_mark(&self, mark: &impl IsA<TextMark>, where_: &TextIter)
Adds the mark at position @where_.
The mark must not be added to another buffer, and if its name
is not None
then there must not be another mark in the buffer
with the same name.
Emits the mark-set
signal as notification
of the mark’s initial placement.
§mark
the mark to add
§where_
location to place mark
Sourcefn add_selection_clipboard(&self, clipboard: &Clipboard)
fn add_selection_clipboard(&self, clipboard: &Clipboard)
Adds @clipboard to the list of clipboards in which the selection contents of @self are available.
In most cases, @clipboard will be the gdk::Clipboard
returned by
WidgetExt::primary_clipboard()
for a view of @self.
§clipboard
Sourcefn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)
fn apply_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)
Emits the “apply-tag” signal on @self.
Calls TextTagTable::lookup()
on the buffer’s
tag table to get a TextTag
, then calls
apply_tag()
.
§name
name of a named TextTag
§start
one bound of range to be tagged
§end
other bound of range to be tagged
Sourcefn backspace(
&self,
iter: &mut TextIter,
interactive: bool,
default_editable: bool,
) -> bool
fn backspace( &self, iter: &mut 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.
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.
§iter
a position in @self
§interactive
whether the deletion is caused by user interaction
§default_editable
whether the buffer is editable by default
§Returns
true
if the buffer was modified
Sourcefn begin_irreversible_action(&self)
fn begin_irreversible_action(&self)
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 gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.
Sourcefn begin_user_action(&self)
fn begin_user_action(&self)
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. 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
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.
Sourcefn copy_clipboard(&self, clipboard: &Clipboard)
fn copy_clipboard(&self, clipboard: &Clipboard)
Sourcefn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor
fn create_child_anchor(&self, iter: &mut TextIter) -> TextChildAnchor
Creates and inserts a child anchor.
This is a convenience function which simply creates a child anchor
with TextChildAnchor::new()
and inserts it into the buffer
with insert_child_anchor()
.
The new anchor is owned by the buffer; no reference count is returned to the caller of this function.
§iter
location in the buffer
§Returns
the created child anchor
Sourcefn create_mark(
&self,
mark_name: Option<&str>,
where_: &TextIter,
left_gravity: bool,
) -> TextMark
fn create_mark( &self, mark_name: Option<&str>, where_: &TextIter, left_gravity: bool, ) -> TextMark
Creates a mark at position @where_.
If @mark_name is None
, the mark is anonymous; otherwise, the mark
can be retrieved by name using 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 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 mark-set
signal as notification
of the mark’s initial placement.
§mark_name
name for mark
§where_
location to place mark
§left_gravity
whether the mark has left gravity
§Returns
the new TextMark
object
Sourcefn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool)
fn cut_clipboard(&self, clipboard: &Clipboard, default_editable: bool)
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
§clipboard
the gdk::Clipboard
object to cut to
§default_editable
default editability of the buffer
Sourcefn delete(&self, start: &mut TextIter, end: &mut TextIter)
fn delete(&self, start: &mut TextIter, end: &mut TextIter)
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.
§start
a position in @self
§end
another position in @self
Sourcefn delete_interactive(
&self,
start_iter: &mut TextIter,
end_iter: &mut TextIter,
default_editable: bool,
) -> bool
fn delete_interactive( &self, start_iter: &mut TextIter, end_iter: &mut TextIter, default_editable: bool, ) -> bool
Deletes all editable text in the given range.
Calls 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.
§start_iter
start of range to delete
§end_iter
end of range
§default_editable
whether the buffer is editable by default
§Returns
whether some text was actually deleted
Sourcefn delete_mark(&self, mark: &impl IsA<TextMark>)
fn delete_mark(&self, mark: &impl IsA<TextMark>)
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
add_mark()
. Use TextMarkExt::is_deleted()
to find out if a mark has been removed from its buffer.
The mark-deleted
signal will be emitted as
notification after the mark is deleted.
§mark
a TextMark
in @self
Sourcefn delete_mark_by_name(&self, name: &str)
fn delete_mark_by_name(&self, name: &str)
Deletes the mark named @name; the mark must exist.
See delete_mark()
for details.
§name
name of a mark in @self
Sourcefn delete_selection(&self, interactive: bool, default_editable: bool) -> bool
fn delete_selection(&self, interactive: bool, default_editable: bool) -> bool
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).
§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
Sourcefn end_irreversible_action(&self)
fn end_irreversible_action(&self)
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 gtk_text_buffer_begin_irreversible_action() and gtk_text_buffer_end_irreversible_action() pairs.
Sourcefn end_user_action(&self)
fn end_user_action(&self)
Ends a user-visible operation.
Should be paired with a call to
begin_user_action()
.
See that function for a full explanation.
Sourcefn char_count(&self) -> i32
fn char_count(&self) -> i32
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
Sourcefn enables_undo(&self) -> bool
fn enables_undo(&self) -> bool
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.
Sourcefn end_iter(&self) -> TextIter
fn end_iter(&self) -> TextIter
Initializes @iter with the “end iterator,” one past the last valid character in the text buffer.
If dereferenced with 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 start_iter()
to get
character position 0) to the end iterator.
§Returns
§iter
iterator to initialize
Sourcefn has_selection(&self) -> bool
fn has_selection(&self) -> bool
Sourcefn get_insert(&self) -> TextMark
fn get_insert(&self) -> TextMark
Sourcefn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter
fn iter_at_child_anchor(&self, anchor: &impl IsA<TextChildAnchor>) -> TextIter
Sourcefn iter_at_line(&self, line_number: i32) -> Option<TextIter>
fn iter_at_line(&self, line_number: i32) -> Option<TextIter>
Sourcefn iter_at_line_index(
&self,
line_number: i32,
byte_index: i32,
) -> Option<TextIter>
fn iter_at_line_index( &self, line_number: i32, byte_index: i32, ) -> Option<TextIter>
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 @self, 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.
§line_number
line number counting from 0
§byte_index
byte index from start of line
§Returns
whether the exact position has been found
§iter
iterator to initialize
Sourcefn iter_at_line_offset(
&self,
line_number: i32,
char_offset: i32,
) -> Option<TextIter>
fn iter_at_line_offset( &self, line_number: i32, char_offset: i32, ) -> Option<TextIter>
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 @self, 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.
§line_number
line number counting from 0
§char_offset
char offset from start of line
§Returns
whether the exact position has been found
§iter
iterator to initialize
Sourcefn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter
fn iter_at_mark(&self, mark: &impl IsA<TextMark>) -> TextIter
Sourcefn iter_at_offset(&self, char_offset: i32) -> TextIter
fn iter_at_offset(&self, char_offset: i32) -> TextIter
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.
§char_offset
char offset from start of buffer, counting from 0, or -1
§Returns
§iter
iterator to initialize
Sourcefn line_count(&self) -> i32
fn line_count(&self) -> i32
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
Sourcefn max_undo_levels(&self) -> u32
fn max_undo_levels(&self) -> u32
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).
Sourcefn is_modified(&self) -> bool
fn is_modified(&self) -> bool
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
Sourcefn selection_bound(&self) -> TextMark
fn selection_bound(&self) -> TextMark
Returns the mark that represents the selection bound.
Equivalent to calling mark()
to get the mark named “selection_bound”, but very slightly
more efficient, and involves less typing.
The currently-selected text in @self 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.
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
Sourcefn selection_bounds(&self) -> Option<(TextIter, TextIter)>
fn selection_bounds(&self) -> Option<(TextIter, TextIter)>
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 None
, then they are not filled in, but the
return value still indicates whether text is selected.
§Returns
whether the selection has nonzero length
§start
iterator to initialize with selection start
§end
iterator to initialize with selection end
Sourcefn selection_content(&self) -> ContentProvider
fn selection_content(&self) -> ContentProvider
Get a content provider for this buffer.
It can be used to make the content of @self available
in a gdk::Clipboard
, see Clipboard::set_content()
.
§Returns
a new gdk::ContentProvider
.
Sourcefn slice(
&self,
start: &TextIter,
end: &TextIter,
include_hidden_chars: bool,
) -> GString
fn slice( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> GString
Returns the text in the range [@start,@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 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.
§start
start of a range
§end
end of a range
§include_hidden_chars
whether to include invisible text
§Returns
an allocated UTF-8 string
Sourcefn start_iter(&self) -> TextIter
fn start_iter(&self) -> TextIter
Initialized @iter with the first position in the text buffer.
This is the same as using iter_at_offset()
to get the iter at character offset 0.
§Returns
§iter
iterator to initialize
Sourcefn tag_table(&self) -> TextTagTable
fn tag_table(&self) -> TextTagTable
Sourcefn text(
&self,
start: &TextIter,
end: &TextIter,
include_hidden_chars: bool,
) -> GString
fn text( &self, start: &TextIter, end: &TextIter, include_hidden_chars: bool, ) -> GString
Returns the text in the range [@start,@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 slice()
.
§start
start of a range
§end
end of a range
§include_hidden_chars
whether to include invisible text
§Returns
an allocated UTF-8 string
Sourcefn insert(&self, iter: &mut TextIter, text: &str)
fn insert(&self, iter: &mut TextIter, text: &str)
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.
§iter
a position in the buffer
§text
text in UTF-8 format
§len
length of text in bytes, or -1
Sourcefn insert_at_cursor(&self, text: &str)
fn insert_at_cursor(&self, text: &str)
Sourcefn insert_child_anchor(
&self,
iter: &mut TextIter,
anchor: &impl IsA<TextChildAnchor>,
)
fn insert_child_anchor( &self, iter: &mut TextIter, anchor: &impl IsA<TextChildAnchor>, )
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 slice()
and
text()
.
Consider 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.
§iter
location to insert the anchor
§anchor
Sourcefn insert_interactive(
&self,
iter: &mut TextIter,
text: &str,
default_editable: bool,
) -> bool
fn insert_interactive( &self, iter: &mut TextIter, text: &str, default_editable: bool, ) -> bool
Inserts @text in @self.
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 TextViewExt::is_editable()
is appropriate here.
§iter
a position in @self
§text
some UTF-8 text
§len
length of text in bytes, or -1
§default_editable
default editability of buffer
§Returns
whether text was actually inserted
Sourcefn insert_interactive_at_cursor(
&self,
text: &str,
default_editable: bool,
) -> bool
fn insert_interactive_at_cursor( &self, text: &str, default_editable: bool, ) -> bool
Inserts @text in @self.
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 TextViewExt::is_editable()
is appropriate here.
§text
text in UTF-8 format
§len
length of text in bytes, or -1
§default_editable
default editability of buffer
§Returns
whether text was actually inserted
Sourcefn insert_markup(&self, iter: &mut TextIter, markup: &str)
fn insert_markup(&self, iter: &mut TextIter, markup: &str)
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 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.
§iter
location to insert the markup
§markup
a nul-terminated UTF-8 string containing Pango markup
§len
length of @markup in bytes, or -1
Sourcefn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<Paintable>)
fn insert_paintable(&self, iter: &mut TextIter, paintable: &impl IsA<Paintable>)
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 slice()
and
text()
.
§iter
location to insert the paintable
§paintable
Sourcefn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter)
fn insert_range(&self, iter: &mut TextIter, start: &TextIter, end: &TextIter)
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 @self, the two buffers must share the same tag table.
Implemented via emissions of the ::insert-text and ::apply-tag signals, so expect those.
§iter
a position in @self
§start
a position in a TextBuffer
§end
another position in the same buffer as @start
Sourcefn insert_range_interactive(
&self,
iter: &mut TextIter,
start: &TextIter,
end: &TextIter,
default_editable: bool,
) -> bool
fn insert_range_interactive( &self, iter: &mut TextIter, start: &TextIter, end: &TextIter, default_editable: bool, ) -> bool
Copies text, tags, and paintables between @start and @end and inserts the copy at @iter.
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 @iter if
no tags enclosing @iter affect editability. Typically the result
of TextViewExt::is_editable()
is appropriate here.
§iter
a position in @self
§start
a position in a TextBuffer
§end
another position in the same buffer as @start
§default_editable
default editability of the buffer
§Returns
whether an insertion was possible at @iter
Sourcefn move_mark_by_name(&self, name: &str, where_: &TextIter)
fn move_mark_by_name(&self, name: &str, where_: &TextIter)
Moves the mark named @name (which must exist) to location @where_.
See move_mark()
for details.
§name
name of a mark
§where_
new location for mark
Sourcefn paste_clipboard(
&self,
clipboard: &Clipboard,
override_location: Option<&TextIter>,
default_editable: bool,
)
fn paste_clipboard( &self, clipboard: &Clipboard, override_location: Option<&TextIter>, default_editable: bool, )
Pastes the contents of a clipboard.
If @override_location is None
, 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.
§clipboard
the gdk::Clipboard
to paste from
§override_location
location to insert pasted text
§default_editable
whether the buffer is editable by default
Sourcefn place_cursor(&self, where_: &TextIter)
fn place_cursor(&self, where_: &TextIter)
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.
§where_
where to put the cursor
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.
§start
one bound of range to be untagged
§end
other bound of range to be untagged
Sourcefn remove_commit_notify(&self, commit_notify_handler: u32)
Available on crate feature v4_16
only.
fn remove_commit_notify(&self, commit_notify_handler: u32)
v4_16
only.Removes the GtkTextBufferCommitNotify
handler previously registered
with TextBufferExtManual::add_commit_notify()
.
This may result in the user_data_destroy
being called that was passed when registering
the commit notify functions.
§commit_notify_handler
the notify handler identifier returned from
TextBufferExtManual::add_commit_notify()
.
Sourcefn remove_selection_clipboard(&self, clipboard: &Clipboard)
fn remove_selection_clipboard(&self, clipboard: &Clipboard)
Removes a gdk::Clipboard
added with
add_selection_clipboard()
§clipboard
a gdk::Clipboard
added to @self by
add_selection_clipboard()
Sourcefn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)
fn remove_tag_by_name(&self, name: &str, start: &TextIter, end: &TextIter)
Emits the “remove-tag” signal.
Calls TextTagTable::lookup()
on the buffer’s
tag table to get a TextTag
, then calls
remove_tag()
.
§name
name of a TextTag
§start
one bound of range to be untagged
§end
other bound of range to be untagged
Sourcefn select_range(&self, ins: &TextIter, bound: &TextIter)
fn select_range(&self, ins: &TextIter, bound: &TextIter)
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.
§ins
where to put the “insert” mark
§bound
where to put the “selection_bound” mark
Sourcefn set_enable_undo(&self, enable_undo: bool)
fn set_enable_undo(&self, enable_undo: bool)
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 max_undo_levels()
.
See begin_irreversible_action()
and
end_irreversible_action()
to create
changes to the buffer that cannot be undone.
§enable_undo
true
to enable undo
Sourcefn set_max_undo_levels(&self, max_undo_levels: u32)
fn set_max_undo_levels(&self, max_undo_levels: u32)
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.
§max_undo_levels
the maximum number of undo actions to perform
Sourcefn set_modified(&self, setting: bool)
fn set_modified(&self, setting: bool)
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 (@self, FALSE)
.
When the buffer is modified, it will automatically
toggle on the modified bit again. When the modified
bit flips, the buffer emits the
modified-changed
signal.
§setting
modification flag setting
Sourcefn set_text(&self, text: &str)
fn set_text(&self, text: &str)
Deletes current contents of @self, and inserts @text instead. This is
automatically marked as an irreversible action in the undo stack. If you
wish to mark this action as part of a larger undo operation, call
delete()
and insert()
directly instead.
If @len is -1, @text must be nul-terminated. @text must be valid UTF-8.
§text
UTF-8 text to insert
§len
length of @text in bytes
Sourcefn cursor_position(&self) -> i32
fn cursor_position(&self) -> i32
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.
Sourcefn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_apply_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted to apply a tag to a range of text in a TextBuffer
.
Applying actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the @start and @end iters (or has to revalidate them).
See also:
apply_tag()
,
TextBufferExtManual::insert_with_tags()
,
insert_range()
.
§tag
the applied tag
§start
the start of the range the tag is applied to
§end
the end of the range the tag is applied to
Sourcefn connect_begin_user_action<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_begin_user_action<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted at the beginning of a single user-visible
operation on a TextBuffer
.
See also:
begin_user_action()
,
insert_interactive()
,
insert_range_interactive()
,
delete_interactive()
,
backspace()
,
delete_selection()
.
Sourcefn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when the content of a TextBuffer
has changed.
Sourcefn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_delete_range<F: Fn(&Self, &TextIter, &TextIter) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted to delete a range from a TextBuffer
.
Note that if your handler runs before the default handler it must not invalidate the @start and @end iters (or has to revalidate them). The default signal handler revalidates the @start and @end iters to both point to the location where text was deleted. Handlers which run after the default handler (see g_signal_connect_after()) do not have access to the deleted text.
See also: delete()
.
§start
the start of the range to be deleted
§end
the end of the range to be deleted
Sourcefn connect_end_user_action<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_end_user_action<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted at the end of a single user-visible
operation on the TextBuffer
.
See also:
end_user_action()
,
insert_interactive()
,
insert_range_interactive()
,
delete_interactive()
,
backspace()
,
delete_selection()
,
backspace()
.
Sourcefn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_insert_child_anchor<F: Fn(&Self, &TextIter, &TextChildAnchor) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted to insert a TextChildAnchor
in a TextBuffer
.
Insertion actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the @location iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted @anchor.
See also: insert_child_anchor()
.
§location
position to insert @anchor in @textbuffer
§anchor
the TextChildAnchor
to be inserted
Sourcefn connect_insert_paintable<F: Fn(&Self, &TextIter, &Paintable) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_insert_paintable<F: Fn(&Self, &TextIter, &Paintable) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted to insert a gdk::Paintable
in a TextBuffer
.
Insertion actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the @location iter (or has to revalidate it). The default signal handler revalidates it to be placed after the inserted @paintable.
See also: insert_paintable()
.
§location
position to insert @paintable in @textbuffer
§paintable
the gdk::Paintable
to be inserted
Sourcefn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_mark_deleted<F: Fn(&Self, &TextMark) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted as notification after a TextMark
is deleted.
See also: delete_mark()
.
§mark
The mark that was deleted
Sourcefn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_mark_set<F: Fn(&Self, &TextIter, &TextMark) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted as notification after a TextMark
is set.
See also:
create_mark()
,
move_mark()
.
§location
The location of @mark in @textbuffer
§mark
The mark that is set
Sourcefn connect_modified_changed<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_modified_changed<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted when the modified bit of a TextBuffer
flips.
See also: set_modified()
.
Sourcefn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_paste_done<F: Fn(&Self, &Clipboard) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted after paste operation has been completed.
This is useful to properly scroll the view to the end
of the pasted text. See paste_clipboard()
for more details.
§clipboard
the gdk::Clipboard
pasted from
Sourcefn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_redo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when a request has been made to redo the previously undone operation.
Sourcefn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_remove_tag<F: Fn(&Self, &TextTag, &TextIter, &TextIter) + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted to remove all occurrences of @tag from a range
of text in a TextBuffer
.
Removal actually occurs in the default handler.
Note that if your handler runs before the default handler it must not invalidate the @start and @end iters (or has to revalidate them).
See also: remove_tag()
.
§tag
the tag to be removed
§start
the start of the range the tag is removed from
§end
the end of the range the tag is removed from
Sourcefn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_undo<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted when a request has been made to undo the previous operation or set of operations that have been grouped together.
fn connect_can_redo_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_can_undo_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_cursor_position_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_enable_undo_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_has_selection_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_text_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.