Details
gtk_text_buffer_new ()
Creates a new text buffer.
gtk_text_buffer_get_line_count ()
Obtains the number of lines in the buffer. This value is cached, so
the function is very fast.
gtk_text_buffer_get_char_count ()
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.
gtk_text_buffer_get_tag_table ()
Get the GtkTextTagTable associated with this buffer.
gtk_text_buffer_insert ()
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.
gtk_text_buffer_insert_at_cursor ()
void gtk_text_buffer_insert_at_cursor
(GtkTextBuffer *buffer,
const gchar *text,
gint len); |
Simply calls gtk_text_buffer_insert(), using the current
cursor position as the insertion point.
gtk_text_buffer_insert_interactive ()
gboolean gtk_text_buffer_insert_interactive
(GtkTextBuffer *buffer,
GtkTextIter *iter,
const gchar *text,
gint len,
gboolean default_editable); |
Like gtk_text_buffer_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_text_view_get_editable() is appropriate here.
gtk_text_buffer_insert_interactive_at_cursor ()
gboolean gtk_text_buffer_insert_interactive_at_cursor
(GtkTextBuffer *buffer,
const gchar *text,
gint len,
gboolean default_editable); |
Calls gtk_text_buffer_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_text_view_get_editable() is appropriate here.
gtk_text_buffer_insert_range ()
Copies text, tags, and pixbufs between start and end (the order
of start and end doesn't matter) and inserts the copy at iter.
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.
gtk_text_buffer_insert_range_interactive ()
Same as gtk_text_buffer_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_text_view_get_editable() is appropriate here.
gtk_text_buffer_insert_with_tags_by_name ()
void gtk_text_buffer_insert_with_tags_by_name
(GtkTextBuffer *buffer,
GtkTextIter *iter,
const gchar *text,
gint len,
const gchar *first_tag_name,
...); |
Same as gtk_text_buffer_insert_with_tags(), but allows you
to pass in tag names instead of tag objects.
gtk_text_buffer_delete ()
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.
Note that the final newline in the buffer may not be deleted; a
GtkTextBuffer always contains at least one newline. You can
safely include the final newline in the range [start,end) but it
won't be affected by the deletion.
gtk_text_buffer_delete_interactive ()
Deletes all <emphasis>editable</emphasis> text in the given range.
Calls gtk_text_buffer_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.
gtk_text_buffer_set_text ()
void gtk_text_buffer_set_text (GtkTextBuffer *buffer,
const gchar *text,
gint len); |
Deletes current contents of buffer, and inserts text instead. If
text doesn't end with a newline, a newline is added;
GtkTextBuffer contents must always end with a newline. If text
ends with a newline, the new buffer contents will be exactly
text. If len is -1, text must be nul-terminated.
gtk_text_buffer_get_text ()
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 <emphasis>not</emphasis> correspond to byte
and character indexes into the buffer. Contrast with
gtk_text_buffer_get_slice().
gtk_text_buffer_get_slice ()
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 <emphasis>do</emphasis> correspond to byte
and character indexes into the buffer. Contrast with
gtk_text_buffer_get_text(). Note that 0xFFFC can occur in normal
text as well, so it is not a reliable indicator that a pixbuf or
widget is in the buffer.
gtk_text_buffer_insert_pixbuf ()
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 pixbufs, but the "text" variants do
not. e.g. see gtk_text_buffer_get_slice() and
gtk_text_buffer_get_text().
gtk_text_buffer_insert_child_anchor ()
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 pixbufs, but the "text" variants do
not. e.g. see gtk_text_buffer_get_slice() and
gtk_text_buffer_get_text(). Consider
gtk_text_buffer_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.
gtk_text_buffer_create_child_anchor ()
This is a convenience function which simply creates a child anchor
with gtk_text_child_anchor_new() and inserts it into the buffer
with gtk_text_buffer_insert_child_anchor().
gtk_text_buffer_create_mark ()
Creates a mark at position where. If mark_name is NULL, the mark
is anonymous; otherwise, the mark can be retrieved by name using
gtk_text_buffer_get_mark(). If a mark has left gravity, and text is
inserted at the mark's current location, the mark will be moved to
the left of the newly-inserted text. If the mark has right gravity
(left_gravity = FALSE), the mark will end up on the right of
newly-inserted text. The standard left-to-right cursor is a mark
with right gravity (when you type, the cursor stays on the right
side of the text you're typing).
The caller of this function does <emphasis>not</emphasis> own a reference
to the returned GtkTextMark, 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.
gtk_text_buffer_move_mark ()
Moves mark to the new location where. Emits the "mark_set" signal
as notification of the move.
gtk_text_buffer_move_mark_by_name ()
Moves the mark named name (which must exist) to location where.
See gtk_text_buffer_move_mark() for details.
gtk_text_buffer_delete_mark ()
Deletes mark, so that it's no longer located anywhere in the
buffer. Removes the reference the buffer holds to the mark, so if
you 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. There is no way to undelete a
mark. gtk_text_mark_get_deleted() will return TRUE after this
function has been called on a mark; gtk_text_mark_get_deleted()
indicates that a mark no longer belongs to a buffer. The "mark_deleted"
signal will be emitted as notification after the mark is deleted.
gtk_text_buffer_delete_mark_by_name ()
void gtk_text_buffer_delete_mark_by_name
(GtkTextBuffer *buffer,
const gchar *name); |
Deletes the mark named name; the mark must exist. See
gtk_text_buffer_delete_mark() for details.
gtk_text_buffer_get_mark ()
Returns the mark named name in buffer buffer, or NULL if no such
mark exists in the buffer.
gtk_text_buffer_get_insert ()
Returns the mark that represents the cursor (insertion point).
Equivalent to calling gtk_text_buffer_get_mark() to get the mark
name "insert," but very slightly more efficient, and involves less
typing.
gtk_text_buffer_get_selection_bound ()
Returns the mark that represents the selection bound. Equivalent
to calling gtk_text_buffer_get_mark() to get the mark name
"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_text_buffer_get_selection_bounds() is another convenient function
for handling the selection, if you just want to know whether there's a
selection and what its bounds are.
gtk_text_buffer_place_cursor ()
This function moves the "insert" and "selection_bound" marks
simultaneously. If you move them to the same place in two steps
with gtk_text_buffer_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.
gtk_text_buffer_apply_tag ()
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.
gtk_text_buffer_remove_tag ()
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.
gtk_text_buffer_remove_all_tags ()
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.
gtk_text_buffer_create_tag ()
GtkTextTag* gtk_text_buffer_create_tag (GtkTextBuffer *buffer,
const gchar *tag_name,
const gchar *first_property_name,
...); |
Creates a tag and adds it to the tag table for buffer.
Equivalent to calling gtk_text_tag_new() and then adding the
tag to the buffer's tag table. The returned tag has its refcount
incremented, as if you'd called gtk_text_tag_new().
If tag_name is NULL, the tag is anonymous.
The first_property_name argument and subsequent arguments are a list
of properties to set on the tag, as with g_object_set().
gtk_text_buffer_get_iter_at_line_offset ()
void gtk_text_buffer_get_iter_at_line_offset
(GtkTextBuffer *buffer,
GtkTextIter *iter,
gint line_number,
gint char_offset); |
Obtains an iterator pointing to char_offset within the given
line. The char_offset must exist, offsets off the end of the line
are not allowed. Note <emphasis>characters</emphasis>, not bytes;
UTF-8 may encode one character as multiple bytes.
gtk_text_buffer_get_iter_at_offset ()
Initializes iter to a position char_offset chars from the start
of the entire buffer.
gtk_text_buffer_get_iter_at_line ()
Initializes iter to the start of the given line.
gtk_text_buffer_get_iter_at_line_index ()
void gtk_text_buffer_get_iter_at_line_index
(GtkTextBuffer *buffer,
GtkTextIter *iter,
gint line_number,
gint byte_index); |
Obtains an iterator pointing to byte_index within the given line.
byte_index must be the start of a UTF-8 character, and must not be
beyond the end of the line. Note <emphasis>bytes</emphasis>, not
characters; UTF-8 may encode one character as multiple bytes.
gtk_text_buffer_get_iter_at_mark ()
Initializes iter with the current position of mark.
gtk_text_buffer_get_iter_at_child_anchor ()
gtk_text_buffer_get_end_iter ()
Initializes iter with the "end iterator," one past the last valid
character in the text buffer. If dereferenced with
gtk_text_iter_get_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_text_buffer_get_start_iter() to get
character position 0) to the end iterator.
gtk_text_buffer_get_bounds ()
Retrieves the first and last iterators in the buffer, i.e. the
entire buffer lies within the range [start,end).
gtk_text_buffer_get_modified ()
Indicates whether the buffer has been modified since the last call
to gtk_text_buffer_set_modified() set the modification flag to
FALSE. Used for example to enable a "save" function in a text
editor.
gtk_text_buffer_set_modified ()
void gtk_text_buffer_set_modified (GtkTextBuffer *buffer,
gboolean setting); |
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 a "modified_changed" signal.
gtk_text_buffer_delete_selection ()
gboolean gtk_text_buffer_delete_selection
(GtkTextBuffer *buffer,
gboolean interactive,
gboolean default_editable); |
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).
gtk_text_buffer_paste_clipboard ()
void gtk_text_buffer_paste_clipboard (GtkTextBuffer *buffer,
gboolean default_editable); |
Pastes the clipboard contents at the insertion point. (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.)
gtk_text_buffer_copy_clipboard ()
Copies the currently-selected text to the clipboard.
gtk_text_buffer_cut_clipboard ()
void gtk_text_buffer_cut_clipboard (GtkTextBuffer *buffer,
gboolean default_editable); |
Copies the currently-selected text to the clipboard, then deletes
said text if it's editable.
gtk_text_buffer_paste_primary ()
void gtk_text_buffer_paste_primary (GtkTextBuffer *buffer,
const GtkTextIter *override_location,
gboolean default_editable); |
Pastes the primary selection at the insertion point, or at override_location.
(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.)
gtk_text_buffer_get_selection_bounds ()
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
NULL, then they are not filled in, but the return value still indicates
whether text is selected.