diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-16 15:19:05 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-05-16 15:19:05 +0000 |
commit | 3f33fb00a112af4bee22b475aa8aa7010c80bc79 (patch) | |
tree | 3f5bb952305d4459619895781b68b939065acbfe /usr.bin/tmux | |
parent | df569ff59fd7a7418ff76b05296918b00e0ef8bb (diff) |
Use formats for status-style and message-style.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/status.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index e47bed3651f..200190919c3 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.206 2020/05/16 15:18:17 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.207 2020/05/16 15:19:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -346,8 +346,15 @@ status_redraw(struct client *c) if (c->tty.sy == 0 || lines == 0) return (1); + /* Create format tree. */ + flags = FORMAT_STATUS; + if (c->flags & CLIENT_STATUSFORCE) + flags |= FORMAT_FORCE; + ft = format_create(c, NULL, FORMAT_NONE, flags); + format_defaults(ft, c, NULL, NULL, NULL); + /* Set up default colour. */ - style_apply(&gc, s->options, "status-style", NULL); + style_apply(&gc, s->options, "status-style", ft); fg = options_get_number(s->options, "status-fg"); if (fg != 8) gc.fg = fg; @@ -367,13 +374,6 @@ status_redraw(struct client *c) } screen_write_start(&ctx, NULL, &sl->screen); - /* Create format tree. */ - flags = FORMAT_STATUS; - if (c->flags & CLIENT_STATUSFORCE) - flags |= FORMAT_FORCE; - ft = format_create(c, NULL, FORMAT_NONE, flags); - format_defaults(ft, c, NULL, NULL, NULL); - /* Write the status lines. */ o = options_get(s->options, "status-format"); if (o == NULL) { @@ -490,6 +490,7 @@ status_message_redraw(struct client *c) size_t len; u_int lines, offset; struct grid_cell gc; + struct format_tree *ft; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); @@ -504,7 +505,9 @@ status_message_redraw(struct client *c) if (len > c->tty.sx) len = c->tty.sx; - style_apply(&gc, s->options, "message-style", NULL); + ft = format_create_defaults(NULL, c, NULL, NULL, NULL); + style_apply(&gc, s->options, "message-style", ft); + format_free(ft); screen_write_start(&ctx, NULL, sl->active); screen_write_fast_copy(&ctx, &sl->screen, 0, 0, c->tty.sx, lines - 1); @@ -636,6 +639,7 @@ status_prompt_redraw(struct client *c) u_int i, lines, offset, left, start, width; u_int pcursor, pwidth; struct grid_cell gc, cursorgc; + struct format_tree *ft; if (c->tty.sx == 0 || c->tty.sy == 0) return (0); @@ -646,10 +650,12 @@ status_prompt_redraw(struct client *c) lines = 1; screen_init(sl->active, c->tty.sx, lines, 0); + ft = format_create_defaults(NULL, c, NULL, NULL, NULL); if (c->prompt_mode == PROMPT_COMMAND) - style_apply(&gc, s->options, "message-command-style", NULL); + style_apply(&gc, s->options, "message-command-style", ft); else - style_apply(&gc, s->options, "message-style", NULL); + style_apply(&gc, s->options, "message-style", ft); + format_free(ft); memcpy(&cursorgc, &gc, sizeof cursorgc); cursorgc.attr ^= GRID_ATTR_REVERSE; |