Apply GtkTextTag to next insertion (e.g. how to insert signal handler after default handler)


I’m trying to use GtkTextView/GtkTextBuffer along with GtkTextTag to change the formatting of text. But all the examples I can find only show how I can use GtkTextTag to change the formatting of text already in the buffer. How can I extend the GtkTextTags at the cursor to whatever is inserted next?

Essentially, this is the same question as this post:

But that post received no responses, and I can’t reply to it anymore, so I’m trying again :crossed_fingers:t3:.

One way I thought of solving this was if I could connect my own signal handler to the “insert-text” signal after the default signal handler. By that point, the new text would be in the buffer, and I could extend the tags to the new text. But according to the documentation, the default signal handler runs last.

  1. Is there a way to insert my own signal handler after the default handler?
  2. Is there another way to accomplish this?

Thank you!

I figured out how to accomplish this. For posterity, I’ll describe it here. Rather than connecting to the “insert-text” signal using text_buffer.connect (in Python), I used text_buffer.connect_after. This allowed me to run my own signal handler after the default signal handler, where I could extend the previous tags to the newly inserted text, now that the default signal handler had added it to the buffer.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.