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]; GdkColor foreground, background, cursor, palette[16];
gsize length; static const char *color_names[8] = {"black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"};
gchar **palette_s = g_key_file_get_string_list(config, "colors", "palette", &length, &error);
IGNORE_ON_ERROR(error) { bool fail = false;
if (length == 16) {
for (unsigned i = 0; i < 16; i++) { for (unsigned i = 0; i < 8; i++) {
gdk_color_parse(palette_s[i], &palette[i]); gsize length;
} gchar **pair = g_key_file_get_string_list(config, "colors", color_names[i], &length, &error);
vte_terminal_set_colors(vte, NULL, NULL, palette, 16); 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); gchar *foreground_color = g_key_file_get_string(config, "colors", "foreground", &error);

View File

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