From 5f3970fcddf5da3519c61a334e96446df71010b5 Mon Sep 17 00:00:00 2001 From: Sebastian Ramacher Date: Tue, 9 Feb 2021 21:57:44 +0100 Subject: [PATCH] Add text colors for links (fixes #211) --- doc/configuration/options.rst | 8 ++++++++ zathura/config.c | 16 ++++++++++------ zathura/page-widget.c | 3 ++- zathura/zathura.h | 1 + 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/doc/configuration/options.rst b/doc/configuration/options.rst index 2f99d13..a0d297b 100644 --- a/doc/configuration/options.rst +++ b/doc/configuration/options.rst @@ -43,6 +43,14 @@ General settings :type: String :default: #9FBC00 +.. describe:: highlight-fg + + Defines the color that is for text when highlighting parts of the document + (e.g.: numbers for links) + + :type: String + :default: #FFFFFF + .. describe:: highlight-active-color Defines the color that is used to show the current selected highlighted diff --git a/zathura/config.c b/zathura/config.c index 567d3d8..285fca0 100644 --- a/zathura/config.c +++ b/zathura/config.c @@ -57,6 +57,8 @@ cb_color_change(girara_session_t* session, const char* name, const char* string_value = (const char*) value; if (g_strcmp0(name, "highlight-color") == 0) { parse_color(&zathura->ui.colors.highlight_color, string_value); + } else if (g_strcmp0(name, "highlight-fg") == 0) { + parse_color(&zathura->ui.colors.highlight_color_fg, string_value); } else if (g_strcmp0(name, "highlight-active-color") == 0) { parse_color(&zathura->ui.colors.highlight_color_active, string_value); } else if (g_strcmp0(name, "recolor-darkcolor") == 0) { @@ -209,15 +211,17 @@ config_load_default(zathura_t* zathura) int_value = 2000; girara_setting_add(gsession, "jumplist-size", &int_value, INT, false, _("Number of positions to remember in the jumplist"), cb_jumplist_change, NULL); - girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL); - girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL); - girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL); + girara_setting_add(gsession, "recolor-darkcolor", "#FFFFFF", STRING, false, _("Recoloring (dark color)"), cb_color_change, NULL); + girara_setting_add(gsession, "recolor-lightcolor", "#000000", STRING, false, _("Recoloring (light color)"), cb_color_change, NULL); + girara_setting_add(gsession, "highlight-color", NULL, STRING, false, _("Color for highlighting"), cb_color_change, NULL); girara_setting_set(gsession, "highlight-color", "#9FBC00"); - girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL); + girara_setting_add(gsession, "highlight-fg", NULL, STRING, false, _("Foreground color for highlighting"), cb_color_change, NULL); + girara_setting_set(gsession, "highlight-fg", "#000000"); + girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, _("Color for highlighting (active)"), cb_color_change, NULL); girara_setting_set(gsession, "highlight-active-color", "#00BC00"); - girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL); + girara_setting_add(gsession, "render-loading-bg", NULL, STRING, false, _("'Loading ...' background color"), cb_color_change, NULL); girara_setting_set(gsession, "render-loading-bg", "#FFFFFF"); - girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL); + girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL); girara_setting_set(gsession, "render-loading-fg", "#000000"); girara_setting_add(gsession, "index-fg", "#DDDDDD", STRING, true, _("Index mode foreground color"), NULL, NULL); diff --git a/zathura/page-widget.c b/zathura/page-widget.c index 373afeb..f38249a 100644 --- a/zathura/page-widget.c +++ b/zathura/page-widget.c @@ -587,7 +587,8 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) cairo_fill(cairo); /* draw text */ - cairo_set_source_rgba(cairo, 0, 0, 0, 1); + const GdkRGBA color_fg = priv->zathura->ui.colors.highlight_color_fg; + cairo_set_source_rgba(cairo, color_fg.red, color_fg.green, color_fg.blue, transparency); cairo_move_to(cairo, rectangle.x1 + 1, rectangle.y2 - 1); char* link_number = g_strdup_printf("%i", priv->links.offset + ++link_counter); cairo_show_text(cairo, link_number); diff --git a/zathura/zathura.h b/zathura/zathura.h index c2165a7..ea0f038 100644 --- a/zathura/zathura.h +++ b/zathura/zathura.h @@ -107,6 +107,7 @@ struct zathura_s struct { GdkRGBA highlight_color; /**< Color for highlighting */ + GdkRGBA highlight_color_fg; /**< Color for highlighting (foreground) */ GdkRGBA highlight_color_active; /** Color for highlighting */ GdkRGBA render_loading_bg; /**< Background color for render "Loading..." */ GdkRGBA render_loading_fg; /**< Foreground color for render "Loading..." */