Created
May 26, 2015 09:28
-
-
Save phillipberndt/67055649d869d065cb3c to your computer and use it in GitHub Desktop.
POC for GTK bug 749875, http://stackoverflow.com/questions/30387247
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <gtk/gtk.h> | |
void main() { | |
GtkTextIter start, end, inspos, tagpos; | |
gsize length; | |
GtkTextBuffer *buffer = gtk_text_buffer_new(NULL); | |
GtkTextTag *tag1 = gtk_text_buffer_create_tag(buffer, "tagone", NULL); | |
GtkTextTag *tag2 = gtk_text_buffer_create_tag(buffer, "tagtwo", NULL); | |
gtk_text_buffer_get_iter_at_mark(buffer, &inspos, gtk_text_buffer_get_insert(buffer)); | |
gtk_text_buffer_insert_interactive(buffer, &inspos, "tag1", 4, TRUE); | |
gtk_text_iter_backward_chars(&inspos, 4); | |
gtk_text_buffer_get_iter_at_mark(buffer, &tagpos, gtk_text_buffer_get_insert(buffer)); | |
gtk_text_buffer_apply_tag(buffer, tag1, &inspos, &tagpos); | |
gtk_text_buffer_get_iter_at_mark(buffer, &inspos, gtk_text_buffer_get_insert(buffer)); | |
gtk_text_buffer_insert_interactive(buffer, &inspos, "tags12", 6, TRUE); | |
gtk_text_iter_backward_chars(&inspos, 6); | |
gtk_text_buffer_get_iter_at_mark(buffer, &tagpos, gtk_text_buffer_get_insert(buffer)); | |
gtk_text_buffer_apply_tag(buffer, tag1, &inspos, &tagpos); | |
gtk_text_buffer_apply_tag(buffer, tag2, &inspos, &tagpos); | |
gtk_text_buffer_get_iter_at_mark(buffer, &inspos, gtk_text_buffer_get_insert(buffer)); | |
gtk_text_buffer_insert_interactive(buffer, &inspos, "notags", 6, TRUE); | |
gtk_text_buffer_get_start_iter(buffer, &start); | |
gtk_text_buffer_get_end_iter(buffer, &end); | |
GdkAtom format = gtk_text_buffer_register_serialize_tagset(buffer, NULL); | |
guint8 *serialized = gtk_text_buffer_serialize(buffer, buffer, format, &start, &end, &length); | |
write(1, serialized, length); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment