+
+/* Update pager and reverse video tags */
+void
+style_update(ChimaraGlk *glk)
+{
+ CHIMARA_GLK_USE_PRIVATE(glk, priv);
+
+ GtkTextTag *pager_tag = GTK_TEXT_TAG( g_hash_table_lookup(priv->styles->text_buffer, "pager") );
+ text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
+}
+
+/* Determine the current colors used to render the text for a given stream.
+ * This can be set in a number of places */
+static void
+style_cascade_colors(GtkTextTag *tag, GtkTextTag *glk_tag, GtkTextTag *default_tag, GdkColor **foreground, GdkColor **background)
+{
+ gboolean foreground_set = FALSE;
+ gboolean background_set = FALSE;
+ gint reverse_color;
+
+ // Default color
+ reverse_color = GPOINTER_TO_INT( g_object_get_data(G_OBJECT(default_tag), "reverse-color") );
+ g_object_get(default_tag, "foreground-set", &foreground_set, "background-set", &background_set, NULL);
+ if(foreground_set)
+ g_object_get(default_tag, "foreground-gdk", reverse_color ? background:foreground, NULL);
+ if(background_set)
+ g_object_get(default_tag, "background-gdk", reverse_color ? foreground:background, NULL);
+
+ // Player defined color
+ reverse_color = GPOINTER_TO_INT( g_object_get_data(G_OBJECT(tag), "reverse-color") );
+ g_object_get(tag, "foreground-set", &foreground_set, "background-set", &background_set, NULL);
+ if(foreground_set)
+ g_object_get(tag, "foreground-gdk", reverse_color ? background:foreground, NULL);
+ if(background_set)
+ g_object_get(tag, "background-gdk", reverse_color ? foreground:background, NULL);
+
+ // GLK defined color
+ reverse_color = GPOINTER_TO_INT( g_object_get_data(G_OBJECT(glk_tag), "reverse-color") );
+ g_object_get(glk_tag, "foreground-set", &foreground_set, "background-set", &background_set, NULL);
+ if(foreground_set)
+ g_object_get(glk_tag, "foreground-gdk", reverse_color ? background:foreground, NULL);
+ if(background_set)
+ g_object_get(glk_tag, "background-gdk", reverse_color ? foreground:background, NULL);
+
+}
+
+/* Determine the current colors used to render the text for a given stream.
+ * This can be set in a number of places */
+void
+style_stream_colors(strid_t str, GdkColor **foreground, GdkColor **background)
+{
+ VALID_STREAM(str, return);
+ g_return_if_fail(str->window != NULL);
+ g_return_if_fail(str->window->type != wintype_TextBuffer || str->window->type != wintype_TextGrid);
+
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(str->window->widget) );
+ GtkTextTagTable *tags = gtk_text_buffer_get_tag_table(buffer);
+ GtkTextTag* default_tag = gtk_text_tag_table_lookup(tags, "default");
+ GtkTextTag* tag = gtk_text_tag_table_lookup(tags, str->style);
+ GtkTextTag* glk_tag = gtk_text_tag_table_lookup(tags, str->glk_style);
+
+ style_cascade_colors(tag, glk_tag, default_tag, foreground, background);
+
+ gboolean foreground_set, background_set;
+
+ // Windows can have zcolors defined
+ if(str->window->zcolor) {
+ g_object_get(str->window->zcolor, "foreground-set", &foreground_set, "background-set", &background_set, NULL);
+ if(foreground_set)
+ g_object_get(str->window->zcolor, "foreground-gdk", foreground, NULL);
+ if(background_set)
+ g_object_get(str->window->zcolor, "background-gdk", background, NULL);
+ }
+}