GtkTextView: inserting text with different styles



Hi,
Let's say I have a GtkTextView, with two color tags, red and blue:

text_view = gtk_text_view_new ();
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
gtk_text_buffer_create_tag (buffer, "my_red", "foreground", "#ff0000", NULL); gtk_text_buffer_create_tag (buffer, "my_blue", "foreground", "#00ff00", NULL);

Now I want too insert "Hello World":
gtk_text_buffer_insert_at_cursor (buffer, "Hello ", -1);
gtk_text_buffer_insert_at_cursor (buffer, "World", -1);

but I want Hello to be red and World to be blue.

What is the usual procedure to achieve this?
(perhaps get the iterators for the last insertion? it should be quite
easy but apparently I could not find information about this...)

Thanks,
Carlos





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