summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-select-pane.c14
-rw-r--r--usr.bin/tmux/input.c6
-rw-r--r--usr.bin/tmux/options.c32
-rw-r--r--usr.bin/tmux/screen-write.c18
-rw-r--r--usr.bin/tmux/style.c156
-rw-r--r--usr.bin/tmux/tmux.h28
-rw-r--r--usr.bin/tmux/tty.c38
-rw-r--r--usr.bin/tmux/window.c22
8 files changed, 180 insertions, 134 deletions
diff --git a/usr.bin/tmux/cmd-select-pane.c b/usr.bin/tmux/cmd-select-pane.c
index 4b7fdfe3cf4..9f4ff5bb721 100644
--- a/usr.bin/tmux/cmd-select-pane.c
+++ b/usr.bin/tmux/cmd-select-pane.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-select-pane.c,v 1.46 2019/03/13 21:39:21 nicm Exp $ */
+/* $OpenBSD: cmd-select-pane.c,v 1.47 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -90,6 +90,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
struct window *w = wl->window;
struct session *s = item->target.s;
struct window_pane *wp = item->target.wp, *lastwp, *markedwp;
+ struct style *sy = &wp->style;
char *pane_title;
const char *style;
@@ -142,19 +143,16 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item)
}
if (args_has(self->args, 'P') || args_has(self->args, 'g')) {
- if (args_has(args, 'P')) {
- style = args_get(args, 'P');
- memcpy(&wp->colgc, &grid_default_cell,
- sizeof wp->colgc);
- if (style_parse(&grid_default_cell, &wp->colgc,
- style) == -1) {
+ if ((style = args_get(args, 'P')) != NULL) {
+ style_set(sy, &grid_default_cell);
+ if (style_parse(sy, &grid_default_cell, style) == -1) {
cmdq_error(item, "bad style: %s", style);
return (CMD_RETURN_ERROR);
}
wp->flags |= PANE_REDRAW;
}
if (args_has(self->args, 'g'))
- cmdq_print(item, "%s", style_tostring(&wp->colgc));
+ cmdq_print(item, "%s", style_tostring(sy));
return (CMD_RETURN_NORMAL);
}
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index c64d40d4b6c..c6eb27756ca 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.148 2019/03/14 06:33:43 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.149 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2340,7 +2340,7 @@ input_osc_10(struct input_ctx *ictx, const char *p)
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3)
goto bad;
- wp->colgc.fg = colour_join_rgb(r, g, b);
+ wp->style.gc.fg = colour_join_rgb(r, g, b);
wp->flags |= PANE_REDRAW;
return;
@@ -2359,7 +2359,7 @@ input_osc_11(struct input_ctx *ictx, const char *p)
if (sscanf(p, "rgb:%2x/%2x/%2x", &r, &g, &b) != 3)
goto bad;
- wp->colgc.bg = colour_join_rgb(r, g, b);
+ wp->style.gc.bg = colour_join_rgb(r, g, b);
wp->flags |= PANE_REDRAW;
return;
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index 0fbb6449b57..c03253ad7ae 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.36 2017/08/09 13:44:36 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.37 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -39,7 +39,7 @@ struct options_entry {
union {
char *string;
long long number;
- struct grid_cell style;
+ struct style style;
struct {
const char **array;
u_int arraysize;
@@ -177,8 +177,8 @@ options_default(struct options *oo, const struct options_table_entry *oe)
else if (oe->type == OPTIONS_TABLE_STRING)
o->string = xstrdup(oe->default_str);
else if (oe->type == OPTIONS_TABLE_STYLE) {
- memcpy(&o->style, &grid_default_cell, sizeof o->style);
- style_parse(&grid_default_cell, &o->style, oe->default_str);
+ style_set(&o->style, &grid_default_cell);
+ style_parse(&o->style, &grid_default_cell, oe->default_str);
} else
o->number = oe->default_num;
return (o);
@@ -504,7 +504,7 @@ options_get_number(struct options *oo, const char *name)
return (o->number);
}
-const struct grid_cell *
+struct style *
options_get_style(struct options *oo, const char *name)
{
struct options_entry *o;
@@ -576,17 +576,17 @@ options_set_style(struct options *oo, const char *name, int append,
const char *value)
{
struct options_entry *o;
- struct grid_cell gc;
+ struct style sy;
if (*name == '@')
fatalx("user option %s must be a string", name);
o = options_get_only(oo, name);
if (o != NULL && append && OPTIONS_IS_STYLE(o))
- memcpy(&gc, &o->style, sizeof gc);
+ style_copy(&sy, &o->style);
else
- memcpy(&gc, &grid_default_cell, sizeof gc);
- if (style_parse(&grid_default_cell, &gc, value) == -1)
+ style_set(&sy, &grid_default_cell);
+ if (style_parse(&sy, &grid_default_cell, value) == -1)
return (NULL);
if (o == NULL) {
o = options_default(oo, options_parent_table_entry(oo, name));
@@ -596,7 +596,7 @@ options_set_style(struct options *oo, const char *name, int append,
if (!OPTIONS_IS_STYLE(o))
fatalx("option %s is not a style", name);
- memcpy(&o->style, &gc, sizeof o->style);
+ style_copy(&o->style, &sy);
return (o);
}
@@ -657,11 +657,11 @@ options_style_update_new(struct options *oo, struct options_entry *o)
new = options_set_style(oo, newname, 0, "default");
if (strstr(o->name, "-bg") != NULL)
- new->style.bg = o->number;
+ new->style.gc.bg = o->number;
else if (strstr(o->name, "-fg") != NULL)
- new->style.fg = o->number;
+ new->style.gc.fg = o->number;
else if (strstr(o->name, "-attr") != NULL)
- new->style.attr = o->number;
+ new->style.gc.attr = o->number;
}
void
@@ -674,13 +674,13 @@ options_style_update_old(struct options *oo, struct options_entry *o)
xsnprintf(newname, sizeof newname, "%.*s-bg", size, o->name);
if (options_get(oo, newname) != NULL)
- options_set_number(oo, newname, o->style.bg);
+ options_set_number(oo, newname, o->style.gc.bg);
xsnprintf(newname, sizeof newname, "%.*s-fg", size, o->name);
if (options_get(oo, newname) != NULL)
- options_set_number(oo, newname, o->style.fg);
+ options_set_number(oo, newname, o->style.gc.fg);
xsnprintf(newname, sizeof newname, "%.*s-attr", size, o->name);
if (options_get(oo, newname) != NULL)
- options_set_number(oo, newname, o->style.attr);
+ options_set_number(oo, newname, o->style.gc.attr);
}
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 7173a9087fc..431891a4e07 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.147 2019/03/12 20:02:47 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.148 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -327,15 +327,15 @@ void
screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
const struct grid_cell *gcp, const char *fmt, ...)
{
- struct grid_cell gc;
- struct utf8_data *ud = &gc.data;
+ struct style sy;
+ struct utf8_data *ud = &sy.gc.data;
va_list ap;
char *msg;
u_char *ptr, *last;
size_t left, size = 0;
enum utf8_state more;
- memcpy(&gc, gcp, sizeof gc);
+ style_set(&sy, gcp);
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
@@ -352,7 +352,7 @@ screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
}
*last = '\0';
- style_parse(gcp, &gc, ptr);
+ style_parse(&sy, gcp, ptr);
ptr = last + 1;
continue;
}
@@ -370,22 +370,22 @@ screen_write_cnputs(struct screen_write_ctx *ctx, ssize_t maxlen,
continue;
if (maxlen > 0 && size + ud->width > (size_t)maxlen) {
while (size < (size_t)maxlen) {
- screen_write_putc(ctx, &gc, ' ');
+ screen_write_putc(ctx, &sy.gc, ' ');
size++;
}
break;
}
size += ud->width;
- screen_write_cell(ctx, &gc);
+ screen_write_cell(ctx, &sy.gc);
} else {
if (maxlen > 0 && size + 1 > (size_t)maxlen)
break;
if (*ptr == '\001')
- gc.attr ^= GRID_ATTR_CHARSET;
+ sy.gc.attr ^= GRID_ATTR_CHARSET;
else if (*ptr > 0x1f && *ptr < 0x7f) {
size++;
- screen_write_putc(ctx, &gc, *ptr);
+ screen_write_putc(ctx, &sy.gc, *ptr);
}
ptr++;
}
diff --git a/usr.bin/tmux/style.c b/usr.bin/tmux/style.c
index 57828691ac8..b28883fb50c 100644
--- a/usr.bin/tmux/style.c
+++ b/usr.bin/tmux/style.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: style.c,v 1.14 2017/03/22 07:16:54 nicm Exp $ */
+/* $OpenBSD: style.c,v 1.15 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -23,27 +23,40 @@
#include "tmux.h"
-/* Parse an embedded style of the form "fg=colour,bg=colour,bright,...". */
+/* Mask for bits not included in style. */
+#define STYLE_ATTR_MASK (~GRID_ATTR_CHARSET)
+
+/* Default style. */
+static struct style style_default = {
+ { 0, 0, 8, 8, { { ' ' }, 0, 1, 1 } }
+};
+
+/*
+ * Parse an embedded style of the form "fg=colour,bg=colour,bright,...".
+ * Note that this adds onto the given style, so it must have been initialized
+ * alredy.
+ */
int
-style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
- const char *in)
+style_parse(struct style *sy, const struct grid_cell *base, const char *in)
{
- struct grid_cell savedgc;
- const char delimiters[] = " ,";
- char tmp[32];
- int val, fg, bg, attr, flags;
- size_t end;
+ struct grid_cell *gc = &sy->gc;
+ struct grid_cell saved;
+ const char delimiters[] = " ,";
+ char tmp[32];
+ int value, fg, bg, attr, flags;
+ size_t end;
if (*in == '\0')
return (0);
if (strchr(delimiters, in[strlen(in) - 1]) != NULL)
return (-1);
- memcpy(&savedgc, gc, sizeof savedgc);
+ memcpy(&saved, base, sizeof saved);
fg = gc->fg;
bg = gc->bg;
attr = gc->attr;
flags = gc->flags;
+
do {
end = strcspn(in, delimiters);
if (end > (sizeof tmp) - 1)
@@ -52,39 +65,40 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
tmp[end] = '\0';
if (strcasecmp(tmp, "default") == 0) {
- fg = defgc->fg;
- bg = defgc->bg;
- attr = defgc->attr;
- flags = defgc->flags;
+ fg = base->fg;
+ bg = base->bg;
+ attr = base->attr;
+ flags = base->flags;
} else if (end > 3 && strncasecmp(tmp + 1, "g=", 2) == 0) {
- if ((val = colour_fromstring(tmp + 3)) == -1)
+ if ((value = colour_fromstring(tmp + 3)) == -1)
goto error;
if (*in == 'f' || *in == 'F') {
- if (val != 8)
- fg = val;
+ if (value != 8)
+ fg = value;
else
- fg = defgc->fg;
+ fg = base->fg;
} else if (*in == 'b' || *in == 'B') {
- if (val != 8)
- bg = val;
+ if (value != 8)
+ bg = value;
else
- bg = defgc->bg;
+ bg = base->bg;
} else
goto error;
} else if (strcasecmp(tmp, "none") == 0)
attr = 0;
else if (end > 2 && strncasecmp(tmp, "no", 2) == 0) {
- if ((val = attributes_fromstring(tmp + 2)) == -1)
+ if ((value = attributes_fromstring(tmp + 2)) == -1)
goto error;
- attr &= ~val;
+ attr &= ~value;
} else {
- if ((val = attributes_fromstring(tmp)) == -1)
+ if ((value = attributes_fromstring(tmp)) == -1)
goto error;
- attr |= val;
+ attr |= value;
}
in += end + strspn(in + end, delimiters);
} while (*in != '\0');
+
gc->fg = fg;
gc->bg = bg;
gc->attr = attr;
@@ -93,33 +107,35 @@ style_parse(const struct grid_cell *defgc, struct grid_cell *gc,
return (0);
error:
- memcpy(gc, &savedgc, sizeof *gc);
+ memcpy(gc, &saved, sizeof *gc);
return (-1);
}
/* Convert style to a string. */
const char *
-style_tostring(struct grid_cell *gc)
+style_tostring(struct style *sy)
{
- int off = 0, comma = 0;
- static char s[256];
+ struct grid_cell *gc = &sy->gc;
+ int off = 0;
+ const char *comma = "";
+ static char s[256];
*s = '\0';
if (gc->fg != 8) {
- off += xsnprintf(s, sizeof s, "fg=%s", colour_tostring(gc->fg));
- comma = 1;
+ off += xsnprintf(s + off, sizeof s - off, "%sfg=%s",
+ comma, colour_tostring(gc->fg));
+ comma = ",";
}
-
if (gc->bg != 8) {
off += xsnprintf(s + off, sizeof s - off, "%sbg=%s",
- comma ? "," : "", colour_tostring(gc->bg));
- comma = 1;
+ comma, colour_tostring(gc->bg));
+ comma = ",";
}
-
if (gc->attr != 0 && gc->attr != GRID_ATTR_CHARSET) {
xsnprintf(s + off, sizeof s - off, "%s%s",
- comma ? "," : "", attributes_tostring(gc->attr));
+ comma, attributes_tostring(gc->attr));
+ comma = ",";
}
if (*s == '\0')
@@ -131,38 +147,64 @@ style_tostring(struct grid_cell *gc)
void
style_apply(struct grid_cell *gc, struct options *oo, const char *name)
{
- const struct grid_cell *gcp;
+ struct style *sy;
memcpy(gc, &grid_default_cell, sizeof *gc);
- gcp = options_get_style(oo, name);
- gc->fg = gcp->fg;
- gc->bg = gcp->bg;
- gc->attr |= gcp->attr;
+ sy = options_get_style(oo, name);
+ gc->fg = sy->gc.fg;
+ gc->bg = sy->gc.bg;
+ gc->attr |= sy->gc.attr;
}
/* Apply a style, updating if default. */
void
style_apply_update(struct grid_cell *gc, struct options *oo, const char *name)
{
- const struct grid_cell *gcp;
-
- gcp = options_get_style(oo, name);
- if (gcp->fg != 8)
- gc->fg = gcp->fg;
- if (gcp->bg != 8)
- gc->bg = gcp->bg;
- if (gcp->attr != 0)
- gc->attr |= gcp->attr;
+ struct style *sy;
+
+ sy = options_get_style(oo, name);
+ if (sy->gc.fg != 8)
+ gc->fg = sy->gc.fg;
+ if (sy->gc.bg != 8)
+ gc->bg = sy->gc.bg;
+ if (sy->gc.attr != 0)
+ gc->attr |= sy->gc.attr;
+}
+
+/* Initialize style from cell. */
+void
+style_set(struct style *sy, const struct grid_cell *gc)
+{
+ memset(sy, 0, sizeof *sy);
+ memcpy(&sy->gc, gc, sizeof sy->gc);
+}
+
+/* Copy style. */
+void
+style_copy(struct style *dst, struct style *src)
+{
+ memcpy(dst, src, sizeof *dst);
}
/* Check if two styles are the same. */
int
-style_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
+style_equal(struct style *sy1, struct style *sy2)
+{
+ struct grid_cell *gc1 = &sy1->gc;
+ struct grid_cell *gc2 = &sy2->gc;
+
+ if (gc1->fg != gc2->fg)
+ return (0);
+ if (gc1->bg != gc2->bg)
+ return (0);
+ if ((gc1->attr & STYLE_ATTR_MASK) != (gc2->attr & STYLE_ATTR_MASK))
+ return (0);
+ return (1);
+}
+
+/* Is this style default? */
+int
+style_is_default(struct style *sy)
{
- return (gc1->fg == gc2->fg &&
- gc1->bg == gc2->bg &&
- (gc1->flags & ~GRID_FLAG_PADDING) ==
- (gc2->flags & ~GRID_FLAG_PADDING) &&
- (gc1->attr & ~GRID_ATTR_CHARSET) ==
- (gc2->attr & ~GRID_ATTR_CHARSET));
+ return (style_equal(sy, &style_default));
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index f00af5548fe..d779309b26c 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.863 2019/03/14 09:50:09 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.864 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -634,6 +634,11 @@ struct grid {
struct grid_line *linedata;
};
+/* Style option. */
+struct style {
+ struct grid_cell gc;
+};
+
/* Hook data structures. */
struct hook {
const char *name;
@@ -778,8 +783,7 @@ struct window_pane {
struct input_ctx *ictx;
- struct grid_cell colgc;
-
+ struct style style;
int *palette;
int pipe_fd;
@@ -847,8 +851,8 @@ struct window {
struct options *options;
- struct grid_cell style;
- struct grid_cell active_style;
+ struct style style;
+ struct style active_style;
u_int references;
TAILQ_HEAD(, winlink) winlinks;
@@ -1649,7 +1653,7 @@ struct options_entry *options_match_get(struct options *, const char *, int *,
int, int *);
const char *options_get_string(struct options *, const char *);
long long options_get_number(struct options *, const char *);
-const struct grid_cell *options_get_style(struct options *, const char *);
+struct style *options_get_style(struct options *, const char *);
struct options_entry * printflike(4, 5) options_set_string(struct options *,
const char *, int, const char *, ...);
struct options_entry *options_set_number(struct options *, const char *,
@@ -2420,14 +2424,16 @@ __dead void printflike(1, 2) fatal(const char *, ...);
__dead void printflike(1, 2) fatalx(const char *, ...);
/* style.c */
-int style_parse(const struct grid_cell *,
- struct grid_cell *, const char *);
-const char *style_tostring(struct grid_cell *);
+int style_parse(struct style *,const struct grid_cell *,
+ const char *);
+const char *style_tostring(struct style *);
void style_apply(struct grid_cell *, struct options *,
const char *);
void style_apply_update(struct grid_cell *, struct options *,
const char *);
-int style_equal(const struct grid_cell *,
- const struct grid_cell *);
+int style_equal(struct style *, struct style *);
+void style_set(struct style *, const struct grid_cell *);
+void style_copy(struct style *, struct style *);
+int style_is_default(struct style *);
#endif /* TMUX_H */
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 54222b6bee0..4868b4ceb69 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.317 2019/03/14 09:50:09 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.318 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2498,28 +2498,28 @@ tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
{
struct window *w = wp->window;
struct options *oo = w->options;
- const struct grid_cell *agc, *pgc, *wgc;
+ struct style *active, *pane, *window;
int c;
if (w->flags & WINDOW_STYLECHANGED) {
w->flags &= ~WINDOW_STYLECHANGED;
- agc = options_get_style(oo, "window-active-style");
- memcpy(&w->active_style, agc, sizeof w->active_style);
- wgc = options_get_style(oo, "window-style");
- memcpy(&w->style, wgc, sizeof w->style);
+ active = options_get_style(oo, "window-active-style");
+ style_copy(&w->active_style, active);
+ window = options_get_style(oo, "window-style");
+ style_copy(&w->style, window);
} else {
- agc = &w->active_style;
- wgc = &w->style;
+ active = &w->active_style;
+ window = &w->style;
}
- pgc = &wp->colgc;
+ pane = &wp->style;
if (gc->fg == 8) {
- if (pgc->fg != 8)
- gc->fg = pgc->fg;
- else if (wp == w->active && agc->fg != 8)
- gc->fg = agc->fg;
+ if (pane->gc.fg != 8)
+ gc->fg = pane->gc.fg;
+ else if (wp == w->active && active->gc.fg != 8)
+ gc->fg = active->gc.fg;
else
- gc->fg = wgc->fg;
+ gc->fg = window->gc.fg;
if (gc->fg != 8) {
c = window_pane_get_palette(wp, gc->fg);
@@ -2529,12 +2529,12 @@ tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
}
if (gc->bg == 8) {
- if (pgc->bg != 8)
- gc->bg = pgc->bg;
- else if (wp == w->active && agc->bg != 8)
- gc->bg = agc->bg;
+ if (pane->gc.bg != 8)
+ gc->bg = pane->gc.bg;
+ else if (wp == w->active && active->gc.bg != 8)
+ gc->bg = active->gc.bg;
else
- gc->bg = wgc->bg;
+ gc->bg = window->gc.bg;
if (gc->bg != 8) {
c = window_pane_get_palette(wp, gc->bg);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index ab62b905a8b..ccc9c5a6d2c 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.220 2019/03/14 09:50:09 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.221 2019/03/14 09:53:52 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -470,7 +470,7 @@ window_set_active_pane(struct window *w, struct window_pane *wp)
void
window_redraw_active_switch(struct window *w, struct window_pane *wp)
{
- const struct grid_cell *gc;
+ struct style *sy;
if (wp == w->active)
return;
@@ -479,21 +479,21 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
* If window-style and window-active-style are the same, we don't need
* to redraw panes when switching active panes.
*/
- gc = options_get_style(w->options, "window-active-style");
- if (style_equal(gc, options_get_style(w->options, "window-style")))
+ sy = options_get_style(w->options, "window-active-style");
+ if (style_equal(sy, options_get_style(w->options, "window-style")))
return;
/*
* If the now active or inactive pane do not have a custom style or if
* the palette is different, they need to be redrawn.
*/
- if (window_pane_get_palette(w->active, w->active->colgc.fg) != -1 ||
- window_pane_get_palette(w->active, w->active->colgc.bg) != -1 ||
- style_equal(&grid_default_cell, &w->active->colgc))
+ if (window_pane_get_palette(w->active, w->active->style.gc.fg) != -1 ||
+ window_pane_get_palette(w->active, w->active->style.gc.bg) != -1 ||
+ style_is_default(&w->active->style))
w->active->flags |= PANE_REDRAW;
- if (window_pane_get_palette(wp, wp->colgc.fg) != -1 ||
- window_pane_get_palette(wp, wp->colgc.bg) != -1 ||
- style_equal(&grid_default_cell, &wp->colgc))
+ if (window_pane_get_palette(wp, wp->style.gc.fg) != -1 ||
+ window_pane_get_palette(wp, wp->style.gc.bg) != -1 ||
+ style_is_default(&wp->style))
wp->flags |= PANE_REDRAW;
}
@@ -826,7 +826,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
wp->saved_grid = NULL;
- memcpy(&wp->colgc, &grid_default_cell, sizeof wp->colgc);
+ style_set(&wp->style, &grid_default_cell);
screen_init(&wp->base, sx, sy, hlimit);
wp->screen = &wp->base;