Break the colour palette into a struct rather than just a single array

and use that to support the OSC palette-setting sequences in popups.
Also add a pane-colours array option to specify the defaults. GitHub
issue 2815.
This commit is contained in:
nicm
2021-08-11 20:49:55 +00:00
parent 01fd4b997e
commit 7eea3d7ab8
12 changed files with 352 additions and 239 deletions

View File

@ -402,7 +402,7 @@ options_array_clear(struct options_entry *o)
return;
RB_FOREACH_SAFE(a, options_array, &o->value.array, a1)
options_array_free(o, a);
options_array_free(o, a);
}
union options_value *
@ -425,6 +425,7 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
struct options_array_item *a;
char *new;
struct cmd_parse_result *pr;
long long number;
if (!OPTIONS_IS_ARRAY(o)) {
if (cause != NULL)
@ -479,6 +480,20 @@ options_array_set(struct options_entry *o, u_int idx, const char *value,
return (0);
}
if (o->tableentry->type == OPTIONS_TABLE_COLOUR) {
if ((number = colour_fromstring(value)) == -1) {
xasprintf(cause, "bad colour: %s", value);
return (-1);
}
a = options_array_item(o, idx);
if (a == NULL)
a = options_array_new(o, idx);
else
options_value_free(o, &a->value);
a->value.number = number;
return (0);
}
if (cause != NULL)
*cause = xstrdup("wrong array type");
return (-1);
@ -1113,6 +1128,10 @@ options_push_changes(const char *name)
RB_FOREACH(wp, window_pane_tree, &all_window_panes)
wp->flags |= PANE_STYLECHANGED;
}
if (strcmp(name, "pane-colours") == 0) {
RB_FOREACH(wp, window_pane_tree, &all_window_panes)
colour_palette_from_option(&wp->palette, wp->options);
}
if (strcmp(name, "pane-border-status") == 0) {
RB_FOREACH(w, windows, &windows)
layout_fix_panes(w, NULL);