simplify color config
This commit is contained in:
parent
db512e6515
commit
c1ca040f4f
27
termite.c
27
termite.c
|
@ -332,17 +332,30 @@ static void load_config(GtkWindow *window, VteTerminal *vte,
|
||||||
|
|
||||||
GdkColor foreground, background, cursor, palette[16];
|
GdkColor foreground, background, cursor, 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;
|
gsize length;
|
||||||
gchar **palette_s = g_key_file_get_string_list(config, "colors", "palette", &length, &error);
|
gchar **pair = g_key_file_get_string_list(config, "colors", color_names[i], &length, &error);
|
||||||
IGNORE_ON_ERROR(error) {
|
if (error) {
|
||||||
if (length == 16) {
|
fail = true;
|
||||||
for (unsigned i = 0; i < 16; i++) {
|
g_clear_error(&error);
|
||||||
gdk_color_parse(palette_s[i], &palette[i]);
|
break;
|
||||||
}
|
}
|
||||||
|
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);
|
vte_terminal_set_colors(vte, NULL, NULL, palette, 16);
|
||||||
}
|
}
|
||||||
g_strfreev(palette_s);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *foreground_color = g_key_file_get_string(config, "colors", "foreground", &error);
|
gchar *foreground_color = g_key_file_get_string(config, "colors", "foreground", &error);
|
||||||
IGNORE_ON_ERROR(error) {
|
IGNORE_ON_ERROR(error) {
|
||||||
|
|
27
termite.cfg
27
termite.cfg
|
@ -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;
|
|
||||||
|
|
Loading…
Reference in New Issue