simplify color config

This commit is contained in:
Daniel Micay 2012-06-07 15:22:28 -04:00
parent db512e6515
commit c1ca040f4f
2 changed files with 31 additions and 27 deletions

View File

@ -332,16 +332,29 @@ static void load_config(GtkWindow *window, VteTerminal *vte,
GdkColor foreground, background, cursor, palette[16];
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], &palette[i]);
}
vte_terminal_set_colors(vte, NULL, NULL, palette, 16);
static const char *color_names[8] = {"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"};
bool fail = false;
for (unsigned i = 0; i < 8; i++) {
gsize length;
gchar **pair = g_key_file_get_string_list(config, "colors", color_names[i], &length, &error);
if (error) {
fail = true;
g_clear_error(&error);
break;
}
g_strfreev(palette_s);
if (length != 2) {
fail = true;
break;
}
gdk_color_parse(pair[0], &palette[i]);
gdk_color_parse(pair[1], &palette[i+8]);
g_strfreev(pair);
}
if (!fail) {
vte_terminal_set_colors(vte, NULL, NULL, palette, 16);
}
gchar *foreground_color = g_key_file_get_string(config, "colors", "foreground", &error);

View File

@ -23,21 +23,12 @@ 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;
# color = normal;bold
black = #3f3f3f;#709080
red = #705050;#dca3a3
green = #60b48a;#c3bf9f
yellow = #dfaf8f;#f0dfaf
blue = #506070;#94bff3
magenta = #dc8cc3;#ec93d3
cyan = #8cd0d3;#93e0e3
white = #dcdccc;#ffffff