Merge branch 'obsd-master'

pull/2172/head
Thomas Adam 2020-04-15 18:01:27 +01:00
commit ebeb457385
3 changed files with 20 additions and 14 deletions

6
menu.c
View File

@ -149,10 +149,14 @@ menu_draw_cb(struct client *c, __unused struct screen_redraw_ctx *ctx0)
struct menu *menu = md->menu;
struct screen_write_ctx ctx;
u_int i, px = md->px, py = md->py;
struct grid_cell gc;
memcpy(&gc, &grid_default_cell, sizeof gc);
style_apply(&gc, c->session->curw->window->options, "mode-style");
screen_write_start(&ctx, NULL, s);
screen_write_clearscreen(&ctx, 8);
screen_write_menu(&ctx, menu, md->choice);
screen_write_menu(&ctx, menu, md->choice, &gc);
screen_write_stop(&ctx);
for (i = 0; i < screen_size_y(&md->s); i++)

View File

@ -409,21 +409,23 @@ screen_write_vline(struct screen_write_ctx *ctx, u_int ny, int top, int bottom)
/* Draw a menu on screen. */
void
screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, int choice)
screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu,
int choice, const struct grid_cell *choice_gc)
{
struct screen *s = ctx->s;
struct grid_cell gc;
struct grid_cell default_gc;
const struct grid_cell *gc = &default_gc;
u_int cx, cy, i, j;
const char *name;
cx = s->cx;
cy = s->cy;
memcpy(&gc, &grid_default_cell, sizeof gc);
memcpy(&default_gc, &grid_default_cell, sizeof default_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);
format_draw(ctx, &default_gc, menu->width, menu->title, NULL);
for (i = 0; i < menu->count; i++) {
name = menu->items[i].name;
@ -432,20 +434,19 @@ screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, int choice)
screen_write_hline(ctx, menu->width + 4, 1, 1);
} else {
if (choice >= 0 && i == (u_int)choice && *name != '-')
gc.attr |= GRID_ATTR_REVERSE;
gc = choice_gc;
screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0);
for (j = 0; j < menu->width; j++)
screen_write_putc(ctx, &gc, ' ');
screen_write_putc(ctx, gc, ' ');
screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0);
if (*name == '-') {
name++;
gc.attr |= GRID_ATTR_DIM;
format_draw(ctx, &gc, menu->width, name, NULL);
gc.attr &= ~GRID_ATTR_DIM;
default_gc.attr |= GRID_ATTR_DIM;
format_draw(ctx, gc, menu->width, name, NULL);
default_gc.attr &= ~GRID_ATTR_DIM;
} else
format_draw(ctx, &gc, menu->width, name, NULL);
if (choice >= 0 && i == (u_int)choice)
gc.attr &= ~GRID_ATTR_REVERSE;
format_draw(ctx, gc, menu->width, name, NULL);
gc = &default_gc;
}
}

3
tmux.h
View File

@ -2384,7 +2384,8 @@ void screen_write_fast_copy(struct screen_write_ctx *, struct screen *,
u_int, u_int, u_int, u_int);
void screen_write_hline(struct screen_write_ctx *, u_int, int, int);
void screen_write_vline(struct screen_write_ctx *, u_int, int, int);
void screen_write_menu(struct screen_write_ctx *, struct menu *, int);
void screen_write_menu(struct screen_write_ctx *, struct menu *, int,
const struct grid_cell *);
void screen_write_box(struct screen_write_ctx *, u_int, u_int);
void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int,
u_int);