insert text in textview without moving selection


Here is a scenario:
I have a textview with text in it. I select all the text with mouse.
Then, in my code, I insert text at the end of the text view.
What happens is that selection moves and includes the newly inserted
char. I understand that because after text is inserted, the iter of the
end of selection is updated to keep the end.

But I'd like the other behavior: selection doesn't move and doesn't
include the newly inserted char.

I did a workaround this way: before inserting, check if end of selection
== end_iter and set a flag.
After inserting, if flag is set, use gtk_text_buffer_select_range() with
a new iter that is end_iter-1.

I'd like to know if there is another way, less ugly, of doing such a thing.

Thanks for your help

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