summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/window.c')
-rw-r--r--usr.bin/tmux/window.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index 68f7dad2efa..53cefa34eba 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.177 2017/01/07 15:28:13 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.178 2017/01/12 00:19:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -464,12 +464,12 @@ window_redraw_active_switch(struct window *w, struct window_pane *wp)
* 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_PALETTE_HAS(w->active, w->active->colgc.fg) ||
- WINDOW_PANE_PALETTE_HAS(w->active, w->active->colgc.bg) ||
+ 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))
w->active->flags |= PANE_REDRAW;
- if (WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.fg) ||
- WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.bg) ||
+ 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))
wp->flags |= PANE_REDRAW;
}
@@ -1517,3 +1517,23 @@ winlink_shuffle_up(struct session *s, struct winlink *wl)
return (idx);
}
+
+int
+window_pane_get_palette(const struct window_pane *wp, int c)
+{
+ int new;
+
+ if (wp == NULL || wp->palette == NULL)
+ return (-1);
+
+ new = -1;
+ if (c < 8)
+ new = wp->palette[c];
+ else if (c >= 90 && c <= 97)
+ new = wp->palette[7 + c - 90];
+ else if (c & COLOUR_FLAG_256)
+ new = wp->palette[c & ~COLOUR_FLAG_256];
+ if (new == 0)
+ return (-1);
+ return (new);
+}