From f96ea8689d8860bac295c371b9d43f63974df637 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Thu, 7 Jun 2012 15:01:40 -0400 Subject: [PATCH] use config file to set colors --- config.h | 19 ------------------- termite.c | 14 ++++++++++---- termite.cfg | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/config.h b/config.h index 0108c5c..65f36da 100644 --- a/config.h +++ b/config.h @@ -5,25 +5,6 @@ static const char *url_regex = "(ftp|http)s?://[-a-zA-Z0-9.?$%&/=_~#.,:;+]*"; // 0.0: opaque, 1.0: transparent //#define TRANSPARENCY 0.2 -static const char *palette_s[16] = { - "#3f3f3f", // black - "#705050", // red - "#60b48a", // green - "#dfaf8f", // yellow - "#506070", // blue - "#dc8cc3", // magenta - "#8cd0d3", // cyan - "#dcdccc", // white - "#709080", // bright black - "#dca3a3", // bright red - "#c3bf9f", // bright green - "#f0dfaf", // bright yellow - "#94bff3", // bright blue - "#ec93d3", // bright magenta - "#93e0e3", // bright cyan - "#ffffff", // bright white -}; - static const char *term = "vte-256color"; // keybindings diff --git a/termite.c b/termite.c index 4ef59f4..2d196df 100644 --- a/termite.c +++ b/termite.c @@ -334,12 +334,18 @@ static void load_config(GtkWindow *window, VteTerminal *vte, g_free(icon_name); } - for (unsigned i = 0; i < 16; i++) { - gdk_color_parse(palette_s[i], &colors->palette[i]); + gsize length; + gchar **palette_s = g_key_file_get_string_list(config, "colors", "palette", &length, &error); + IGNORE_ON_ERROR(error) { + if (length == 16) { + for (unsigned i = 0; i < 16; i++) { + gdk_color_parse(palette_s[i], &colors->palette[i]); + } + vte_terminal_set_colors(vte, NULL, NULL, colors->palette, 16); + } + g_strfreev(palette_s); } - vte_terminal_set_colors(vte, NULL, NULL, colors->palette, 16); - gchar *foreground_color = g_key_file_get_string(config, "colors", "foreground", &error); IGNORE_ON_ERROR(error) { if (gdk_color_parse(foreground_color, &colors->foreground)) { diff --git a/termite.cfg b/termite.cfg index 2689fd3..1f39bce 100644 --- a/termite.cfg +++ b/termite.cfg @@ -22,3 +22,22 @@ cursor_shape = BLOCK foreground = #dcdccc background = #3f3f3f cursor = #dcdccc + +# black +# red +# green +# yellow +# blue +# magenta +# cyan +# white +# bright black +# bright red +# bright green +# bright yellow +# bright blue +# bright magenta +# bright cyan +# white + +palette = #3f3f3f;#705050;#60b48a;#dfaf8f;#506070;#dc8cc3;#8cd0d3;#dcdccc;#709080;#dca3a3;#c3bf9f;#f0dfaf;#94bff3;#ec93d3;#93e0e3;#ffffff;