Re: GtkTextBuffer : Applying tags to newly input text



I'm not sure I'm following your question unless you're trying to point out
that they're applied to GtkTextIter's that are invalidated once the text is
changed.  That said, something is happening internally in the
`_gtk_text_btree` functions that implements the behavior I'm trying to
reproduce.  If i have text like `<b>foo bar</b>` and i put the cursor at
the space and type `baz ` the text will end up being `<b>foo baz bar</b>`.
So the behavior is clearly there to read a current set of tags and apply
them.  I haven't dug too much into the `_gtk_text_btree` code as it's all
internal to Gtk and clearly I can't call any of it directly.

I'm simply asking is it possible and if so, how do I do that at the end of
the buffer.  Using the example above starting with `<b>foo bar</b>` and
entering ` baz` at the end of bar should result in `<b>foo bar baz</b>`,
but everything I've tried ends up in `<b>foo bar</b> baz`.  Unfortunately I
haven't kept an exhaustive list of everything I've tried, but it's been a
lot, including the obvious of insert mark + the iter from
`gtk_text_buffer_get_end_iter`.

I haven't yet played with adding a mark at the end with right gravity as
that would result in me having to track the currently applied tags and
constantly reapply them which seems like a lot of overhead for something
that is already being handled internally in some way shape or form.

On Wed, Jun 13, 2018 at 2:51 AM, Karan Ahuja <karan26 ahuja gmail com>
wrote:

What are tags applied to ?
In the apply tag function - what are the tags applied to.

On 13 Jun 2018 12:34, "Gary Kramlich" <grim reaperworld com> wrote:

Hi all,

I'm working on a GtkTextBuffer subclass that needs to apply tags to to
newly inserted text.  I've tried all sort of tricks to make this happen
automatically, but I am coming up short.

Basically the GtkTextView is editable and I'm trying to allow the user to
set a format and then start typing. I've tried to apply a tag from the
iter
of the insertion mark to the end of the buffer and have any newly
inserted
text have that tag applied.  However, my attempts at doing this have been
nothing but failures.

I believe this is possible because if I start typing in the middle of an
already applied tag the newly inserted text has that tag applied and all
of
the existing text retains the tag.

I've played around a bit with additional marks and their gravity but
haven't had any success there either.

Any pointers would be greatly appreciated!

Thanks,

--
Gary Kramlich <grim reaperworld com>
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




-- 
Thanks,

--
Gary Kramlich <grim reaperworld com>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]