summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/popup.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-08-11 20:49:56 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-08-11 20:49:56 +0000
commita09f81c7ed125be3fd3535c31155c550973b3e55 (patch)
tree08cd9917d90f19f678922f3d0aa868a9b55389cf /usr.bin/tmux/popup.c
parent9dae6e90952aaca8ad34c186222d2ee05c4343e5 (diff)
Break the colour palette into a struct rather than just a single array
and use that to support the OSC palette-setting sequences in popups. Also add a pane-colours array option to specify the defaults. GitHub issue 2815.
Diffstat (limited to 'usr.bin/tmux/popup.c')
-rw-r--r--usr.bin/tmux/popup.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c
index 08b2fb248e2..34a06f50dfa 100644
--- a/usr.bin/tmux/popup.c
+++ b/usr.bin/tmux/popup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: popup.c,v 1.24 2021/08/05 09:43:51 nicm Exp $ */
+/* $OpenBSD: popup.c,v 1.25 2021/08/11 20:49:55 nicm Exp $ */
/*
* Copyright (c) 2020 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -33,6 +33,7 @@ struct popup_data {
int flags;
struct screen s;
+ struct colour_palette palette;
struct job *job;
struct input_ctx *ictx;
int status;
@@ -101,6 +102,7 @@ popup_init_ctx_cb(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx)
{
struct popup_data *pd = ctx->arg;
+ ttyctx->palette = &pd->palette;
ttyctx->redraw_cb = popup_redraw_cb;
ttyctx->set_client_cb = popup_set_client_cb;
ttyctx->arg = pd;
@@ -136,6 +138,8 @@ popup_draw_cb(struct client *c, __unused struct screen_redraw_ctx *ctx0)
struct screen s;
struct screen_write_ctx ctx;
u_int i, px = pd->px, py = pd->py;
+ struct colour_palette *palette = &pd->palette;
+ struct grid_cell gc;
screen_init(&s, pd->sx, pd->sy, 0);
screen_write_start(&ctx, &s);
@@ -150,11 +154,13 @@ popup_draw_cb(struct client *c, __unused struct screen_redraw_ctx *ctx0)
}
screen_write_stop(&ctx);
+ memcpy(&gc, &grid_default_cell, sizeof gc);
+ gc.fg = pd->palette.fg;
+ gc.bg = pd->palette.bg;
+
c->overlay_check = NULL;
- for (i = 0; i < pd->sy; i++){
- tty_draw_line(tty, &s, 0, i, pd->sx, px, py + i,
- &grid_default_cell, NULL);
- }
+ for (i = 0; i < pd->sy; i++)
+ tty_draw_line(tty, &s, 0, i, pd->sx, px, py + i, &gc, palette);
c->overlay_check = popup_check_cb;
}
@@ -180,6 +186,7 @@ popup_free_cb(struct client *c)
input_free(pd->ictx);
screen_free(&pd->s);
+ colour_palette_free(&pd->palette);
free(pd);
}
@@ -389,6 +396,8 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
pd->status = 128 + SIGHUP;
screen_init(&pd->s, sx - 2, sy - 2, 0);
+ colour_palette_init(&pd->palette);
+ colour_palette_from_option(&pd->palette, global_w_options);
pd->px = px;
pd->py = py;
@@ -403,7 +412,7 @@ popup_display(int flags, struct cmdq_item *item, u_int px, u_int py, u_int sx,
pd->job = job_run(shellcmd, argc, argv, s, cwd,
popup_job_update_cb, popup_job_complete_cb, NULL, pd,
JOB_NOWAIT|JOB_PTY|JOB_KEEPWRITE, pd->sx - 2, pd->sy - 2);
- pd->ictx = input_init(NULL, job_get_event(pd->job));
+ pd->ictx = input_init(NULL, job_get_event(pd->job), &pd->palette);
server_client_set_overlay(c, 0, popup_check_cb, popup_mode_cb,
popup_draw_cb, popup_key_cb, popup_free_cb, popup_resize_cb, pd);