diff options
author | nicm <nicm> | 2021-08-11 20:49:55 +0000 |
---|---|---|
committer | nicm <nicm> | 2021-08-11 20:49:55 +0000 |
commit | 7eea3d7ab850bb8fbeeccbb4b0fe84b9274965af (patch) | |
tree | 7967e985cb56c93a0fd80dfebe01079c4dbdd43e /options.c | |
parent | 01fd4b997e3a0a74ea57d6830cf97f98ea2c2a7c (diff) | |
download | rtmux-7eea3d7ab850bb8fbeeccbb4b0fe84b9274965af.tar.gz rtmux-7eea3d7ab850bb8fbeeccbb4b0fe84b9274965af.tar.bz2 rtmux-7eea3d7ab850bb8fbeeccbb4b0fe84b9274965af.zip |
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.
Diffstat (limited to 'options.c')
-rw-r--r-- | options.c | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -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); |