summaryrefslogtreecommitdiffstats
path: root/screen-write.c
diff options
context:
space:
mode:
authornicm <nicm>2020-04-15 16:11:23 +0000
committernicm <nicm>2020-04-15 16:11:23 +0000
commit1e72f5ea4356a102e12c0b5325d4af824899d39c (patch)
tree34420459415756a4ca1127fa9064a8b32df53330 /screen-write.c
parentc7883d5c872a56c5342092f81e87e0742713b4de (diff)
Use mode-style for selected items, like choose modes. GitHub issue 2166.
Diffstat (limited to 'screen-write.c')
-rw-r--r--screen-write.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/screen-write.c b/screen-write.c
index 43cb42b4..b2f9e223 100644
--- a/screen-write.c
+++ b/screen-write.c
@@ -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;
}
}