Re: deleting text associated with a particular tag?
- From: Owen Taylor <otaylor redhat com>
- To: skip pobox com (Skip Montanaro)
- Cc: gtk-list gnome org
- Subject: Re: deleting text associated with a particular tag?
- Date: 25 Apr 2001 10:03:31 -0400
<skip pobox com> writes:
> How do I delete text from a GtkTextBuffer that is associated with a
> particular tag name? There doesn't seem to be a TextView/TextBuffer example
> in the 1.3.x examples directory for me to work from and it's not obvious
> from looking at the function signatures and descriptions in the reference
> manual.
Well, the basic function you would use is:
gboolean gtk_text_iter_forward_to_tag_toggle (GtkTextIter *iter,
GtkTextTag *tag);
The code would look something like:
void
delete_text_with_tag (GtkTextBuffer *buffer, GtkTextTag *tag)
{
GtkTextIter start;
GtkTextIter end;
gtk_text_iter_get_iter_at_offset (buffer, 0, &start);
if (!gtk_text_iter_begins_tag (start, tag))
if (!gtk_text_iter_forward_to_tag_toggle (&start, tag))
return;
do
{
end = start;
gtk_text_iter_forward_to_tag_toggle (&end, tag);
gtk_text_buffer_delete (buffer, &start, &end);
}
while (gtk_text_iter_forward_to_tag_toggle (&start, tag);
}
[ Not tested ]
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]