diff options
Diffstat (limited to 'lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c')
-rw-r--r-- | lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c | 67 |
1 files changed, 28 insertions, 39 deletions
diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c b/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c index 3898e30..d5b2f5e 100644 --- a/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c +++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript-formats.c @@ -203,47 +203,12 @@ gtk_experiment_transcript_set_interactive_format(GtkExperimentTranscript *trans, const gchar *format_str, gboolean with_markup) { - static PangoAttrList *default_attribs = NULL; - GtkExperimentTranscriptFormat *fmt = &trans->priv->interactive_format; - gchar *pattern; - gboolean res = TRUE; - if (default_attribs == NULL) { - PangoAttribute *attrib; - PangoFontDescription *font; - PangoColor color; - - default_attribs = pango_attr_list_new(); + gchar *pattern; + PangoAttribute *attrib; -#ifdef DEFAULT_INTERACTIVE_FORMAT_FONT - font = pango_font_description_from_string(DEFAULT_INTERACTIVE_FORMAT_FONT); - if (font != NULL) { - attrib = pango_attr_font_desc_new(font); - attrib->end_index = 1; - pango_attr_list_insert(default_attribs, attrib); - pango_font_description_free(font); - } -#endif -#ifdef DEFAULT_INTERACTIVE_FORMAT_FGCOLOR - if (pango_color_parse(&color, DEFAULT_INTERACTIVE_FORMAT_FGCOLOR)) { - attrib = pango_attr_foreground_new(color.red, - color.green, - color.blue); - attrib->end_index = 1; - pango_attr_list_insert(default_attribs, attrib); - } -#endif -#ifdef DEFAULT_INTERACTIVE_FORMAT_BGCOLOR - if (pango_color_parse(&color, DEFAULT_INTERACTIVE_FORMAT_BGCOLOR)) { - attrib = pango_attr_background_new(color.red, - color.green, - color.blue); - attrib->end_index = 1; - pango_attr_list_insert(default_attribs, attrib); - } -#endif - } + gboolean res = TRUE; gtk_experiment_transcript_free_format(fmt); fmt->regexp = NULL; @@ -260,10 +225,34 @@ gtk_experiment_transcript_set_interactive_format(GtkExperimentTranscript *trans, } /* else if (!with_markup) */ - fmt->attribs = pango_attr_list_copy(default_attribs); + fmt->attribs = pango_attr_list_new(); if (fmt->attribs == NULL) goto redraw; + if (trans->interactive_format.default_font != NULL) { + attrib = pango_attr_font_desc_new(trans->interactive_format.default_font); + attrib->end_index = 1; + pango_attr_list_insert(fmt->attribs, attrib); + } + if (trans->interactive_format.default_text_color != NULL) { + GdkColor *color = trans->interactive_format.default_text_color; + + attrib = pango_attr_foreground_new(color->red, + color->green, + color->blue); + attrib->end_index = 1; + pango_attr_list_insert(fmt->attribs, attrib); + } + if (trans->interactive_format.default_bg_color != NULL) { + GdkColor *color = trans->interactive_format.default_bg_color; + + attrib = pango_attr_background_new(color->red, + color->green, + color->blue); + attrib->end_index = 1; + pango_attr_list_insert(fmt->attribs, attrib); + } + pattern = g_strconcat("(", format_str, ")", NULL); fmt->regexp = g_regex_new(pattern, FORMAT_REGEX_COMPILE_FLAGS, 0, NULL); g_free(pattern); |