diff --git a/options-table.c b/options-table.c index 25f8c7c7..6fa41750 100644 --- a/options-table.c +++ b/options-table.c @@ -1239,7 +1239,7 @@ const struct options_table_entry options_table[] = { { .name = "floating-pane-border-style", .type = OPTIONS_TABLE_STRING, - .scope = OPTIONS_TABLE_WINDOW, + .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, .default_str = "default", .flags = OPTIONS_TABLE_IS_STYLE, .separator = ",", @@ -1250,7 +1250,7 @@ const struct options_table_entry options_table[] = { { .name = "floating-pane-style", .type = OPTIONS_TABLE_STRING, - .scope = OPTIONS_TABLE_WINDOW, + .scope = OPTIONS_TABLE_WINDOW|OPTIONS_TABLE_PANE, .default_str = "default", .flags = OPTIONS_TABLE_IS_STYLE, .separator = ",", diff --git a/screen-redraw.c b/screen-redraw.c index 3862e066..d53d7155 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -603,11 +603,9 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp, border_option = "pane-active-border-style"; else border_option = "pane-border-style"; - style_apply(&gc, w->options, border_option, ft); + style_apply(&gc, wp->options, border_option, ft); if (wp->flags & PANE_FLOATING) - style_add(&gc, w->options, "floating-pane-border-style", ft); - if (options_get_only(wp->options, border_option) != NULL) - style_add(&gc, wp->options, border_option, ft); + style_add(&gc, wp->options, "floating-pane-border-style", ft); fmt = options_get_string(wp->options, "pane-border-format"); expanded = format_expand_time(ft, fmt); @@ -874,7 +872,6 @@ screen_redraw_draw_borders_style(struct screen_redraw_ctx *ctx, u_int x, { struct client *c = ctx->c; struct session *s = c->session; - struct window *w = s->curw->window; struct window_pane *active = server_client_get_pane(c); struct grid_cell *gc; const char *border_option; @@ -893,11 +890,7 @@ screen_redraw_draw_borders_style(struct screen_redraw_ctx *ctx, u_int x, if (!*flag) { ft = format_create_defaults(NULL, c, s, s->curw, wp); - - style_apply(gc, w->options, border_option, ft); - if (options_get_only(wp->options, border_option) != NULL) - style_add(gc, wp->options, border_option, ft); - + style_apply(gc, wp->options, border_option, ft); format_free(ft); *flag = 1; } diff --git a/tty.c b/tty.c index 761bd27c..6c654ef3 100644 --- a/tty.c +++ b/tty.c @@ -3199,62 +3199,46 @@ tty_window_default_style(struct grid_cell *gc, struct window_pane *wp) gc->bg = wp->palette.bg; } +static void +tty_style_changed(struct window_pane *wp) +{ + struct options *oo = wp->options; + struct format_tree *ft; + + log_debug("%%%u: style changed", wp->id); + wp->flags &= ~PANE_STYLECHANGED; + + ft = format_create(NULL, NULL, FORMAT_PANE|wp->id, FORMAT_NOJOBS); + format_defaults(ft, NULL, NULL, NULL, wp); + + tty_window_default_style(&wp->cached_active_gc, wp); + style_add(&wp->cached_active_gc, oo, "window-active-style", ft); + if (wp->flags & PANE_FLOATING) + style_add(&wp->cached_active_gc, oo, "floating-pane-style", ft); + + tty_window_default_style(&wp->cached_gc, wp); + style_add(&wp->cached_gc, oo, "window-style", ft); + if (wp->flags & PANE_FLOATING) + style_add(&wp->cached_active_gc, oo, "floating-pane-style", ft); + + format_free(ft); +} + void tty_default_colours(struct grid_cell *gc, struct window_pane *wp) { - struct window *w = wp->window; - struct options *wo = w->options; - struct format_tree *ft; + if (wp->flags & PANE_STYLECHANGED) + tty_style_changed (wp); memcpy(gc, &grid_default_cell, sizeof *gc); - - if (wp->flags & PANE_STYLECHANGED) { - log_debug("%%%u: style changed", wp->id); - wp->flags &= ~PANE_STYLECHANGED; - - ft = format_create(NULL, NULL, FORMAT_PANE|wp->id, - FORMAT_NOJOBS); - format_defaults(ft, NULL, NULL, NULL, wp); - - /* Window-level baseline. */ - tty_window_default_style(&wp->cached_active_gc, wp); - style_add(&wp->cached_active_gc, wo, "window-active-style", ft); - /* Floating pane window default overrides window baseline. */ - if (wp->flags & PANE_FLOATING) - style_add(&wp->cached_active_gc, wo, - "floating-pane-style", ft); - /* Per-pane override (set via new-pane -s or select-pane -P). */ - if (options_get_only(wp->options, "window-active-style") != NULL) - style_add(&wp->cached_active_gc, wp->options, - "window-active-style", ft); - - /* Window-level baseline. */ - tty_window_default_style(&wp->cached_gc, wp); - style_add(&wp->cached_gc, wo, "window-style", ft); - /* Floating pane window default overrides window baseline. */ - if (wp->flags & PANE_FLOATING) - style_add(&wp->cached_gc, wo, "floating-pane-style", ft); - /* Per-pane override (set via new-pane -s or select-pane -P). */ - if (options_get_only(wp->options, "window-style") != NULL) - style_add(&wp->cached_gc, wp->options, - "window-style", ft); - - format_free(ft); - } - - if (gc->fg == 8) { - if (wp == wp->window->active && wp->cached_active_gc.fg != 8) - gc->fg = wp->cached_active_gc.fg; - else - gc->fg = wp->cached_gc.fg; - } - - if (gc->bg == 8) { - if (wp == wp->window->active && wp->cached_active_gc.bg != 8) - gc->bg = wp->cached_active_gc.bg; - else - gc->bg = wp->cached_gc.bg; - } + if (wp == wp->window->active && wp->cached_active_gc.fg != 8) + gc->fg = wp->cached_active_gc.fg; + else + gc->fg = wp->cached_gc.fg; + if (wp == wp->window->active && wp->cached_active_gc.bg != 8) + gc->bg = wp->cached_active_gc.bg; + else + gc->bg = wp->cached_gc.bg; } void