summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/screen-write.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2014-01-28 23:07:10 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2014-01-28 23:07:10 +0000
commit3d20557ab2bf84a79842200cebf73e0088d2c606 (patch)
tree08a372710e90039b5b58ec70975c70f5802690ad /usr.bin/tmux/screen-write.c
parentc448b26f796e52041e31d0636bc57774612767bd (diff)
Allow replacing each of the many sets of separate foo-{fg,bg,attr}
options with a single foo-style option. For example: set -g status-fg yellow set -g status-bg red set -g status-attr blink Becomes: set -g status-style fg=yellow,bg=red,blink The -a flag to set can be used to add to rather than replace a style. So: set -g status-bg red Becomes: set -ag status-style bg=red Currently this is fully backwards compatible (all *-{fg,bg,attr} options remain) but the plan is to deprecate them over time. From Tiago Cunha.
Diffstat (limited to 'usr.bin/tmux/screen-write.c')
-rw-r--r--usr.bin/tmux/screen-write.c87
1 files changed, 2 insertions, 85 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 599472f938d..1d49428d5a8 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.67 2013/05/15 15:32:14 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.68 2014/01/28 23:07:09 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -248,7 +248,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
}
*last = '\0';
- screen_write_parsestyle(gc, &lgc, ptr);
+ style_parse(gc, &lgc, ptr);
ptr = last + 1;
continue;
}
@@ -288,89 +288,6 @@ screen_write_cnputs(struct screen_write_ctx *ctx,
free(msg);
}
-/* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */
-void
-screen_write_parsestyle(
- struct grid_cell *defgc, struct grid_cell *gc, const char *in)
-{
- const char delimiters[] = " ,";
- char tmp[32];
- int val;
- size_t end;
- u_char fg, bg, attr, flags;
-
- if (*in == '\0')
- return;
- if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
- return;
-
- fg = gc->fg;
- bg = gc->bg;
- attr = gc->attr;
- flags = gc->flags;
- do {
- end = strcspn(in, delimiters);
- if (end > (sizeof tmp) - 1)
- return;
- memcpy(tmp, in, end);
- tmp[end] = '\0';
-
- if (strcasecmp(tmp, "default") == 0) {
- fg = defgc->fg;
- bg = defgc->bg;
- attr = defgc->attr;
- flags &= ~(GRID_FLAG_FG256|GRID_FLAG_BG256);
- flags |=
- defgc->flags & (GRID_FLAG_FG256|GRID_FLAG_BG256);
- } else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
- if ((val = colour_fromstring(tmp + 3)) == -1)
- return;
- if (*in == 'f' || *in == 'F') {
- if (val != 8) {
- if (val & 0x100) {
- flags |= GRID_FLAG_FG256;
- val &= ~0x100;
- } else
- flags &= ~GRID_FLAG_FG256;
- fg = val;
- } else {
- fg = defgc->fg;
- flags &= ~GRID_FLAG_FG256;
- flags |= defgc->flags & GRID_FLAG_FG256;
- }
- } else if (*in == 'b' || *in == 'B') {
- if (val != 8) {
- if (val & 0x100) {
- flags |= GRID_FLAG_BG256;
- val &= ~0x100;
- } else
- flags &= ~GRID_FLAG_BG256;
- bg = val;
- } else {
- bg = defgc->bg;
- flags &= ~GRID_FLAG_BG256;
- flags |= defgc->flags & GRID_FLAG_BG256;
- }
- } else
- return;
- } else if (end > 2 && strncasecmp(tmp, "no", 2) == 0) {
- if ((val = attributes_fromstring(tmp + 2)) == -1)
- return;
- attr &= ~val;
- } else {
- if ((val = attributes_fromstring(tmp)) == -1)
- return;
- attr |= val;
- }
-
- in += end + strspn(in + end, delimiters);
- } while (*in != '\0');
- gc->fg = fg;
- gc->bg = bg;
- gc->attr = attr;
- gc->flags = flags;
-}
-
/* Copy from another screen. */
void
screen_write_copy(struct screen_write_ctx *ctx,