=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.151 retrieving revision 1.152 diff -c -r1.151 -r1.152 *** src/usr.bin/tmux/screen-write.c 2019/04/18 11:07:28 1.151 --- src/usr.bin/tmux/screen-write.c 2019/05/10 14:12:47 1.152 *************** *** 1,4 **** ! /* $OpenBSD: screen-write.c,v 1.151 2019/04/18 11:07:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen-write.c,v 1.152 2019/05/10 14:12:47 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 399,404 **** --- 399,442 ---- } screen_write_set_cursor(ctx, cx, cy + ny - 1); screen_write_putc(ctx, &gc, bottom ? 'v' : 'x'); + + screen_write_set_cursor(ctx, cx, cy); + } + + /* Draw a menu on screen. */ + void + screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, int choice) + { + struct screen *s = ctx->s; + struct grid_cell gc; + u_int cx, cy, i, j; + + cx = s->cx; + cy = s->cy; + + memcpy(&gc, &grid_default_cell, sizeof gc); + + screen_write_box(ctx, menu->width + 4, menu->count + 2); + screen_write_cursormove(ctx, cx + 2, cy, 0); + format_draw(ctx, &gc, menu->width, menu->title, NULL); + + for (i = 0; i < menu->count; i++) { + if (menu->items[i].name == NULL) { + screen_write_cursormove(ctx, cx, cy + 1 + i, 0); + screen_write_hline(ctx, menu->width + 4, 1, 1); + } else { + if (choice >= 0 && i == (u_int)choice) + gc.attr |= GRID_ATTR_REVERSE; + screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0); + for (j = 0; j < menu->width; j++) + screen_write_putc(ctx, &gc, ' '); + screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0); + format_draw(ctx, &gc, menu->width, menu->items[i].name, + NULL); + if (choice >= 0 && i == (u_int)choice) + gc.attr &= ~GRID_ATTR_REVERSE; + } + } screen_write_set_cursor(ctx, cx, cy); }