+ GtkTextIter start, end;
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ gint start_offset;
+
+ GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
+
+ GtkTextTag *default_tag = gtk_text_tag_table_lookup(tags, "default");
+ GtkTextTag *style_tag = gtk_text_tag_table_lookup(tags, win->window_stream->style);
+ GtkTextTag *glk_style_tag = gtk_text_tag_table_lookup(tags, win->window_stream->glk_style);
+
+ start_offset = gtk_text_iter_get_offset(&end);
+ gtk_text_buffer_insert(buffer, &end, win->buffer->str, -1);
+ gtk_text_buffer_get_iter_at_offset(buffer, &start, start_offset);
+
+ // Player's style overrides
+ gtk_text_buffer_apply_tag(buffer, style_tag, &start, &end);
+
+ // GLK Program's style overrides
+ gtk_text_buffer_apply_tag(buffer, glk_style_tag, &start, &end);
+
+ // Default style
+ gtk_text_buffer_apply_tag(buffer, default_tag, &start, &end);
+
+ // Link style overrides
+ if(win->window_stream->hyperlink_mode) {
+ GtkTextTag *link_style_tag = gtk_text_tag_table_lookup(tags, "hyperlink");
+ GtkTextTag *link_tag = win->current_hyperlink->tag;
+ gtk_text_buffer_apply_tag(buffer, link_style_tag, &start, &end);
+ gtk_text_buffer_apply_tag(buffer, link_tag, &start, &end);
+ }
+
+ // GLK Program's style overrides using garglk_set_zcolors()
+ if(win->zcolor != NULL) {
+ gtk_text_buffer_apply_tag(buffer, win->zcolor, &start, &end);
+ }
+
+ // GLK Program's style overrides using garglk_set_reversevideo()
+ if(win->zcolor_reversed != NULL) {
+ gtk_text_buffer_apply_tag(buffer, win->zcolor_reversed, &start, &end);
+ }