1
0
mirror of https://github.com/tmux/tmux.git synced 2025-03-22 21:08:49 +00:00

added the function 'menu_draw_cb'

This commit is contained in:
0x31nf4l7 2025-01-25 09:33:28 +01:00
parent 6ab268c7bb
commit 68cacd26f8

26
menu.c
View File

@ -437,6 +437,30 @@ chosen:
return (1);
}
void
menu_resize_cb(struct client *c, void *data) {
int nx, ny, w, h;
struct tty *tty = &c->tty;
struct menu_data *md = data;
w = md->menu->width + 4;
h = md->menu->count + 2;
nx = tty->sx / 2 - w/2;
ny = tty->sy / 2 - h/2;
if (nx + w >= tty->sx || ny + h >= tty->sy) {
c->overlay_resize = NULL;
server_client_clear_overlay(c);
return;
}
md->px = nx;
md->py = ny;
menu_draw_cb(c, data, NULL);
}
static void
menu_set_style(struct client *c, struct grid_cell *gc, const char *style,
const char *option)
@ -550,6 +574,6 @@ menu_display(struct menu *menu, int flags, int starting_choice,
if (md == NULL)
return (-1);
server_client_set_overlay(c, 0, NULL, menu_mode_cb, menu_draw_cb,
menu_key_cb, menu_free_cb, NULL, md);
menu_key_cb, menu_free_cb, menu_resize_cb, md);
return (0);
}