summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/menu.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2020-05-16 15:34:09 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2020-05-16 15:34:09 +0000
commit4633d6cc30c3bc4cce058d05a6e56cda04b2809c (patch)
tree7da56026c544ed497fb5352daa19f11fb832f832 /usr.bin/tmux/menu.c
parentb78f4f49539dce722e833fd1edd5441c115a97f8 (diff)
Do not hoke into struct window_pane from the tty code and instead set
everything up in tty_ctx. Provide a way to initialize the tty_ctx from a callback and use it to let popups draw directly through input_parse in the same way as panes do, rather than forcing a full redraw on every change.
Diffstat (limited to 'usr.bin/tmux/menu.c')
-rw-r--r--usr.bin/tmux/menu.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/usr.bin/tmux/menu.c b/usr.bin/tmux/menu.c
index 5acd4ad6441..a8b4ded58d5 100644
--- a/usr.bin/tmux/menu.c
+++ b/usr.bin/tmux/menu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: menu.c,v 1.26 2020/05/16 15:06:03 nicm Exp $ */
+/* $OpenBSD: menu.c,v 1.27 2020/05/16 15:34:08 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -130,14 +130,12 @@ menu_free(struct menu *menu)
free(menu);
}
-static int
+static struct screen *
menu_mode_cb(struct client *c, __unused u_int *cx, __unused u_int *cy)
{
struct menu_data *md = c->overlay_data;
- if (~md->flags & MENU_NOMOUSE)
- return (MODE_MOUSE_ALL);
- return (0);
+ return (&md->s);
}
static void
@@ -153,13 +151,15 @@ menu_draw_cb(struct client *c, __unused struct screen_redraw_ctx *ctx0)
style_apply(&gc, c->session->curw->window->options, "mode-style", NULL);
- screen_write_start(&ctx, NULL, s);
+ screen_write_start(&ctx, s);
screen_write_clearscreen(&ctx, 8);
screen_write_menu(&ctx, menu, md->choice, &gc);
screen_write_stop(&ctx);
- for (i = 0; i < screen_size_y(&md->s); i++)
- tty_draw_line(tty, NULL, s, 0, i, menu->width + 4, px, py + i);
+ for (i = 0; i < screen_size_y(&md->s); i++) {
+ tty_draw_line(tty, s, 0, i, menu->width + 4, px, py + i,
+ &grid_default_cell, NULL);
+ }
}
static void
@@ -349,6 +349,8 @@ menu_display(struct menu *menu, int flags, struct cmdq_item *item, u_int px,
if (fs != NULL)
cmd_find_copy_state(&md->fs, fs);
screen_init(&md->s, menu->width + 4, menu->count + 2, 0);
+ if (~md->flags & MENU_NOMOUSE)
+ md->s.mode |= MODE_MOUSE_ALL;
md->px = px;
md->py = py;