Drop having a separate type for style options and make them all strings,

which allows formats to be expanded. Any styles without a '#{' are still
validated when they are set but any with a '#{' are not. Formats are not
expanded usefully in many cases yet, that will be changed later.

To make this work, a few other changes:

- set-option -a with a style option automatically appends a ",".

- OSC 10 and 11 don't set the window-style option anymore, instead the
  fg and bg are stored in the pane struct and act as the defaults that
  can be overridden by window-style.

- status-fg and -bg now override status-style instead of trying to keep
  them in sync.
This commit is contained in:
nicm
2020-05-16 15:01:30 +00:00
parent 0487029fc5
commit f03b61131b
18 changed files with 514 additions and 350 deletions

29
input.c
View File

@ -1861,8 +1861,10 @@ input_csi_dispatch_winops(struct input_ctx *ictx)
case 0:
case 2:
screen_pop_title(sctx->s);
if (wp != NULL)
if (wp != NULL) {
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
break;
}
break;
@ -2253,8 +2255,10 @@ input_exit_osc(struct input_ctx *ictx)
switch (option) {
case 0:
case 2:
if (screen_set_title(sctx->s, p) && wp != NULL)
server_status_window(ictx->wp->window);
if (screen_set_title(sctx->s, p) && wp != NULL) {
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
break;
case 4:
input_osc_4(ictx, p);
@ -2262,8 +2266,10 @@ input_exit_osc(struct input_ctx *ictx)
case 7:
if (utf8_isvalid(p)) {
screen_set_path(sctx->s, p);
if (wp != NULL)
if (wp != NULL) {
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
}
break;
case 10:
@ -2314,8 +2320,10 @@ input_exit_apc(struct input_ctx *ictx)
return;
log_debug("%s: \"%s\"", __func__, ictx->input_buf);
if (screen_set_title(sctx->s, ictx->input_buf) && wp != NULL)
if (screen_set_title(sctx->s, ictx->input_buf) && wp != NULL) {
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
}
/* Rename string started. */
@ -2355,6 +2363,7 @@ input_exit_rename(struct input_ctx *ictx)
}
window_set_name(wp->window, ictx->input_buf);
options_set_number(wp->window->options, "automatic-rename", 0);
server_redraw_window_borders(wp->window);
server_status_window(wp->window);
}
@ -2486,7 +2495,6 @@ input_osc_10(struct input_ctx *ictx, const char *p)
{
struct window_pane *wp = ictx->wp;
u_int r, g, b;
char tmp[16];
if (wp == NULL)
return;
@ -2495,9 +2503,7 @@ input_osc_10(struct input_ctx *ictx, const char *p)
if (!input_osc_parse_colour(p, &r, &g, &b))
goto bad;
xsnprintf(tmp, sizeof tmp, "fg=#%02x%02x%02x", r, g, b);
options_set_style(wp->options, "window-style", 1, tmp);
options_set_style(wp->options, "window-active-style", 1, tmp);
wp->fg = colour_join_rgb(r, g, b);
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
return;
@ -2512,7 +2518,6 @@ input_osc_11(struct input_ctx *ictx, const char *p)
{
struct window_pane *wp = ictx->wp;
u_int r, g, b;
char tmp[16];
if (wp == NULL)
return;
@ -2521,9 +2526,7 @@ input_osc_11(struct input_ctx *ictx, const char *p)
if (!input_osc_parse_colour(p, &r, &g, &b))
goto bad;
xsnprintf(tmp, sizeof tmp, "bg=#%02x%02x%02x", r, g, b);
options_set_style(wp->options, "window-style", 1, tmp);
options_set_style(wp->options, "window-active-style", 1, tmp);
wp->bg = colour_join_rgb(r, g, b);
wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED);
return;