summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2021-08-12 00:01:26 +0100
committerThomas Adam <thomas@xteddy.org>2021-08-12 00:01:26 +0100
commit44ada9cd67e46676eaf0f9a19a681ddc1f898682 (patch)
treea56e87ba5007caaedbe33d5a8841bad715ba6582 /window.c
parente9d49161e0510b8b2eccbe33195789937d25796f (diff)
parent7eea3d7ab850bb8fbeeccbb4b0fe84b9274965af (diff)
Merge branch 'obsd-master' into master
Diffstat (limited to 'window.c')
-rw-r--r--window.c70
1 files changed, 11 insertions, 59 deletions
diff --git a/window.c b/window.c
index f21a4d5f..ce02df9e 100644
--- a/window.c
+++ b/window.c
@@ -485,6 +485,14 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify)
return (1);
}
+static int
+window_pane_get_palette(struct window_pane *wp, int c)
+{
+ if (wp == NULL)
+ return (-1);
+ return (colour_palette_get(&wp->palette, c));
+}
+
void
window_redraw_active_switch(struct window *w, struct window_pane *wp)
{
@@ -862,9 +870,6 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
wp->fd = -1;
- wp->fg = 8;
- wp->bg = 8;
-
TAILQ_INIT(&wp->modes);
TAILQ_INIT (&wp->resize_queue);
@@ -874,6 +879,7 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit)
wp->pipe_fd = -1;
+ colour_palette_init(&wp->palette);
screen_init(&wp->base, sx, sy, hlimit);
wp->screen = &wp->base;
@@ -926,7 +932,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);
+ colour_palette_free(&wp->palette);
free(wp);
}
@@ -978,7 +984,7 @@ window_pane_set_event(struct window_pane *wp)
wp->event = bufferevent_new(wp->fd, window_pane_read_callback,
NULL, window_pane_error_callback, wp);
- wp->ictx = input_init(wp, wp->event);
+ wp->ictx = input_init(wp, wp->event, &wp->palette);
bufferevent_enable(wp->event, EV_READ|EV_WRITE);
}
@@ -1010,60 +1016,6 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy)
wme->mode->resize(wme, sx, sy);
}
-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;
-}
-
-int
-window_pane_get_palette(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[8 + c - 90];
- else if (c & COLOUR_FLAG_256)
- new = wp->palette[c & ~COLOUR_FLAG_256];
- if (new == 0)
- return (-1);
- return (new);
-}
-
int
window_pane_set_mode(struct window_pane *wp, struct window_pane *swp,
const struct window_mode *mode, struct cmd_find_state *fs,