summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authornicm <nicm>2017-01-07 15:28:13 +0000
committernicm <nicm>2017-01-07 15:28:13 +0000
commit314e933914de4096c40e623c793049d26484d53a (patch)
tree8de850ef5c15384a8b2400af496200a235ed16ff /window.c
parentcae0fbbe8c7cc16ac38aa8149ef9b4e2a54bce0e (diff)
Add support for the OSC 4 and OSC 104 palette setting escape sequences,
from S Gilles.
Diffstat (limited to 'window.c')
-rw-r--r--window.c59
1 files changed, 50 insertions, 9 deletions
diff --git a/window.c b/window.c
index 1d4ba266..57df3a12 100644
--- a/window.c
+++ b/window.c
@@ -447,24 +447,30 @@ 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 *agc, *wgc;
+ const struct grid_cell *gc;
if (wp == w->active)
return;
/*
* If window-style and window-active-style are the same, we don't need
- * to redraw panes when switching active panes. Otherwise, if the
- * active or inactive pane do not have a custom style, they will need
- * to be redrawn.
+ * to redraw panes when switching active panes.
*/
- agc = options_get_style(w->options, "window-active-style");
- wgc = options_get_style(w->options, "window-style");
- if (style_equal(agc, wgc))
+ gc = options_get_style(w->options, "window-active-style");
+ if (style_equal(gc, options_get_style(w->options, "window-style")))
return;
- if (style_equal(&grid_default_cell, &w->active->colgc))
+
+ /*
+ * 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) ||
+ style_equal(&grid_default_cell, &w->active->colgc))
w->active->flags |= PANE_REDRAW;
- if (style_equal(&grid_default_cell, &wp->colgc))
+ if (WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.fg) ||
+ WINDOW_PANE_PALETTE_HAS(wp, wp->colgc.bg) ||
+ style_equal(&grid_default_cell, &wp->colgc))
wp->flags |= PANE_REDRAW;
}
@@ -829,6 +835,7 @@ window_pane_destroy(struct window_pane *wp)
free((void *)wp->cwd);
free(wp->shell);
cmd_free_argv(wp->argc, wp->argv);
+ free(wp->palette);
free(wp);
}
@@ -1092,6 +1099,40 @@ window_pane_alternate_off(struct window_pane *wp, struct grid_cell *gc,
wp->flags |= PANE_REDRAW;
}
+void
+window_pane_set_palette(struct window_pane *wp, u_int n, int colour)
+{
+ if (n > 0xff)
+ return;
+
+ if (wp->palette == NULL)
+ wp->palette = xcalloc(0x100, sizeof *wp->palette);
+
+ wp->palette[n] = colour;
+ wp->flags |= PANE_REDRAW;
+}
+
+void
+window_pane_unset_palette(struct window_pane *wp, u_int n)
+{
+ if (n > 0xff || wp->palette == NULL)
+ return;
+
+ wp->palette[n] = 0;
+ wp->flags |= PANE_REDRAW;
+}
+
+void
+window_pane_reset_palette(struct window_pane *wp)
+{
+ if (wp->palette == NULL)
+ return;
+
+ free(wp->palette);
+ wp->palette = NULL;
+ wp->flags |= PANE_REDRAW;
+}
+
static void
window_pane_mode_timer(__unused int fd, __unused short events, void *arg)
{