aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2020-04-27 15:15:12 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2020-04-27 15:15:12 +0100
commit79b4d839521c154c39d7f86932f7dd4a7b870576 (patch)
tree3db3984808a7e08790ae459be218a3238d144c4f
parentc30e765c7b4659b472d2830bd2f114560a5205df (diff)
downloadrtmux-79b4d839521c154c39d7f86932f7dd4a7b870576.tar.gz
rtmux-79b4d839521c154c39d7f86932f7dd4a7b870576.tar.bz2
rtmux-79b4d839521c154c39d7f86932f7dd4a7b870576.zip
Use a grid cell not a style for the pane style.
-rw-r--r--grid.c23
-rw-r--r--style.c29
-rw-r--r--tmux.h8
-rw-r--r--tty.c24
-rw-r--r--window.c18
5 files changed, 39 insertions, 63 deletions
diff --git a/grid.c b/grid.c
index 0cef412b..81f3709c 100644
--- a/grid.c
+++ b/grid.c
@@ -211,19 +211,28 @@ grid_check_y(struct grid *gd, const char *from, u_int py)
return (0);
}
-/* Compare grid cells. Return 1 if equal, 0 if not. */
+/* Check if two styles are (visibly) the same. */
int
-grid_cells_equal(const struct grid_cell *gca, const struct grid_cell *gcb)
+grid_cells_look_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
{
- if (gca->fg != gcb->fg || gca->bg != gcb->bg)
+ if (gc1->fg != gc2->fg || gc1->bg != gc2->bg)
+ return (0);
+ if (gc1->attr != gc2->attr || gc1->flags != gc2->flags)
return (0);
- if (gca->attr != gcb->attr || gca->flags != gcb->flags)
+ return (1);
+}
+
+/* Compare grid cells. Return 1 if equal, 0 if not. */
+int
+grid_cells_equal(const struct grid_cell *gc1, const struct grid_cell *gc2)
+{
+ if (!grid_cells_look_equal(gc1, gc2))
return (0);
- if (gca->data.width != gcb->data.width)
+ if (gc1->data.width != gc2->data.width)
return (0);
- if (gca->data.size != gcb->data.size)
+ if (gc1->data.size != gc2->data.size)
return (0);
- return (memcmp(gca->data.data, gcb->data.data, gca->data.size) == 0);
+ return (memcmp(gc1->data.data, gc2->data.data, gc1->data.size) == 0);
}
/* Free one line. */
diff --git a/style.c b/style.c
index da3b4c78..2ac78e97 100644
--- a/style.c
+++ b/style.c
@@ -59,6 +59,7 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
return (0);
style_copy(&saved, sy);
+ log_debug("%s: %s", __func__, in);
do {
while (*in != '\0' && strchr(delimiters, *in) != NULL)
in++;
@@ -71,6 +72,7 @@ style_parse(struct style *sy, const struct grid_cell *base, const char *in)
memcpy(tmp, in, end);
tmp[end] = '\0';
+ log_debug("%s: %s", __func__, tmp);
if (strcasecmp(tmp, "default") == 0) {
sy->gc.fg = base->fg;
sy->gc.bg = base->bg;
@@ -285,30 +287,3 @@ style_copy(struct style *dst, struct style *src)
{
memcpy(dst, src, sizeof *dst);
}
-
-/* Check if two styles are (visibly) the same. */
-int
-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);
- if (sy1->fill != sy2->fill)
- return (0);
- if (sy1->align != sy2->align)
- return (0);
- return (1);
-}
-
-/* Is this style default? */
-int
-style_is_default(struct style *sy)
-{
- return (style_equal(sy, &style_default));
-}
diff --git a/tmux.h b/tmux.h
index 17e5a04b..e10710d1 100644
--- a/tmux.h
+++ b/tmux.h
@@ -930,8 +930,8 @@ struct window_pane {
struct input_ctx *ictx;
- struct style cached_style;
- struct style cached_active_style;
+ struct grid_cell cached_gc;
+ struct grid_cell cached_active_gc;
int *palette;
int pipe_fd;
@@ -2365,6 +2365,8 @@ int attributes_fromstring(const char *);
extern const struct grid_cell grid_default_cell;
void grid_empty_line(struct grid *, u_int, u_int);
int grid_cells_equal(const struct grid_cell *, const struct grid_cell *);
+int grid_cells_look_equal(const struct grid_cell *,
+ const struct grid_cell *);
struct grid *grid_create(u_int, u_int, u_int);
void grid_destroy(struct grid *);
int grid_compare(struct grid *, struct grid *);
@@ -2821,10 +2823,8 @@ int style_parse(struct style *,const struct grid_cell *,
const char *style_tostring(struct style *);
void style_apply(struct grid_cell *, struct options *,
const char *);
-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 *);
/* spawn.c */
struct winlink *spawn_window(struct spawn_context *, char **);
diff --git a/tty.c b/tty.c
index 016ce399..99b433ae 100644
--- a/tty.c
+++ b/tty.c
@@ -2690,27 +2690,19 @@ static void
tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
{
struct options *oo = wp->options;
- struct style *style, *active_style;
int c;
if (wp->flags & PANE_STYLECHANGED) {
wp->flags &= ~PANE_STYLECHANGED;
-
- active_style = options_get_style(oo, "window-active-style");
- style = options_get_style(oo, "window-style");
-
- style_copy(&wp->cached_active_style, active_style);
- style_copy(&wp->cached_style, style);
- } else {
- active_style = &wp->cached_active_style;
- style = &wp->cached_style;
+ style_apply(&wp->cached_active_gc, oo, "window-active-style");
+ style_apply(&wp->cached_gc, oo, "window-style");
}
if (gc->fg == 8) {
- if (wp == wp->window->active && active_style->gc.fg != 8)
- gc->fg = active_style->gc.fg;
+ if (wp == wp->window->active && wp->cached_active_gc.fg != 8)
+ gc->fg = wp->cached_active_gc.fg;
else
- gc->fg = style->gc.fg;
+ gc->fg = wp->cached_gc.fg;
if (gc->fg != 8) {
c = window_pane_get_palette(wp, gc->fg);
@@ -2720,10 +2712,10 @@ tty_default_colours(struct grid_cell *gc, struct window_pane *wp)
}
if (gc->bg == 8) {
- if (wp == wp->window->active && active_style->gc.bg != 8)
- gc->bg = active_style->gc.bg;
+ if (wp == wp->window->active && wp->cached_active_gc.bg != 8)
+ gc->bg = wp->cached_active_gc.bg;
else
- gc->bg = style->gc.bg;
+ gc->bg = wp->cached_gc.bg;
if (gc->bg != 8) {
c = window_pane_get_palette(wp, gc->bg);
diff --git a/window.c b/window.c
index 3bf9ef95..7cdbf6a7 100644
--- a/window.c
+++ b/window.c
@@ -495,8 +495,8 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
void
window_redraw_active_switch(struct window *w, struct window_pane *wp)
{
- struct style *sy1, *sy2;
- int c1, c2;
+ struct grid_cell *gc1, *gc2;
+ int c1, c2;
if (wp == w->active)
return;
@@ -506,18 +506,18 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
* If the active and inactive styles or palettes are different,
* need to redraw the panes.
*/
- sy1 = &wp->cached_style;
- sy2 = &wp->cached_active_style;
- if (!style_equal(sy1, sy2))
+ gc1 = &wp->cached_gc;
+ gc2 = &wp->cached_active_gc;
+ if (!grid_cells_look_equal(gc1, gc2))
wp->flags |= PANE_REDRAW;
else {
- c1 = window_pane_get_palette(wp, sy1->gc.fg);
- c2 = window_pane_get_palette(wp, sy2->gc.fg);
+ c1 = window_pane_get_palette(wp, gc1->fg);
+ c2 = window_pane_get_palette(wp, gc2->fg);
if (c1 != c2)
wp->flags |= PANE_REDRAW;
else {
- c1 = window_pane_get_palette(wp, sy1->gc.bg);
- c2 = window_pane_get_palette(wp, sy2->gc.bg);
+ c1 = window_pane_get_palette(wp, gc1->bg);
+ c2 = window_pane_get_palette(wp, gc2->bg);
if (c1 != c2)
wp->flags |= PANE_REDRAW;
}