| @@ -438,71 +438,26 @@ screen_write_menu(struct screen_write_ct | | | @@ -438,71 +438,26 @@ screen_write_menu(struct screen_write_ct |
438 | gc.attr |= GRID_ATTR_DIM; | | 438 | gc.attr |= GRID_ATTR_DIM; |
439 | format_draw(ctx, &gc, menu->width, name, NULL); | | 439 | format_draw(ctx, &gc, menu->width, name, NULL); |
440 | gc.attr &= ~GRID_ATTR_DIM; | | 440 | gc.attr &= ~GRID_ATTR_DIM; |
441 | } else | | 441 | } else |
442 | format_draw(ctx, &gc, menu->width, name, NULL); | | 442 | format_draw(ctx, &gc, menu->width, name, NULL); |
443 | if (choice >= 0 && i == (u_int)choice) | | 443 | if (choice >= 0 && i == (u_int)choice) |
444 | gc.attr &= ~GRID_ATTR_REVERSE; | | 444 | gc.attr &= ~GRID_ATTR_REVERSE; |
445 | } | | 445 | } |
446 | } | | 446 | } |
447 | | | 447 | |
448 | screen_write_set_cursor(ctx, cx, cy); | | 448 | screen_write_set_cursor(ctx, cx, cy); |
449 | } | | 449 | } |
450 | | | 450 | |
451 | /* Draw a menu on screen. */ | | | |
452 | void | | | |
453 | screen_write_menu(struct screen_write_ctx *ctx, struct menu *menu, int choice) | | | |
454 | { | | | |
455 | struct screen *s = ctx->s; | | | |
456 | struct grid_cell gc; | | | |
457 | u_int cx, cy, i, j; | | | |
458 | const char *name; | | | |
459 | | | | |
460 | cx = s->cx; | | | |
461 | cy = s->cy; | | | |
462 | | | | |
463 | memcpy(&gc, &grid_default_cell, sizeof gc); | | | |
464 | | | | |
465 | screen_write_box(ctx, menu->width + 4, menu->count + 2); | | | |
466 | screen_write_cursormove(ctx, cx + 2, cy, 0); | | | |
467 | format_draw(ctx, &gc, menu->width, menu->title, NULL); | | | |
468 | | | | |
469 | for (i = 0; i < menu->count; i++) { | | | |
470 | name = menu->items[i].name; | | | |
471 | if (name == NULL) { | | | |
472 | screen_write_cursormove(ctx, cx, cy + 1 + i, 0); | | | |
473 | screen_write_hline(ctx, menu->width + 4, 1, 1); | | | |
474 | } else { | | | |
475 | if (choice >= 0 && i == (u_int)choice && *name != '-') | | | |
476 | gc.attr |= GRID_ATTR_REVERSE; | | | |
477 | screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0); | | | |
478 | for (j = 0; j < menu->width; j++) | | | |
479 | screen_write_putc(ctx, &gc, ' '); | | | |
480 | screen_write_cursormove(ctx, cx + 2, cy + 1 + i, 0); | | | |
481 | if (*name == '-') { | | | |
482 | name++; | | | |
483 | gc.attr |= GRID_ATTR_DIM; | | | |
484 | format_draw(ctx, &gc, menu->width, name, NULL); | | | |
485 | gc.attr &= ~GRID_ATTR_DIM; | | | |
486 | } else | | | |
487 | format_draw(ctx, &gc, menu->width, name, NULL); | | | |
488 | if (choice >= 0 && i == (u_int)choice) | | | |
489 | gc.attr &= ~GRID_ATTR_REVERSE; | | | |
490 | } | | | |
491 | } | | | |
492 | | | | |
493 | screen_write_set_cursor(ctx, cx, cy); | | | |
494 | } | | | |
495 | | | | |
496 | /* Draw a box on screen. */ | | 451 | /* Draw a box on screen. */ |
497 | void | | 452 | void |
498 | screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny) | | 453 | screen_write_box(struct screen_write_ctx *ctx, u_int nx, u_int ny) |
499 | { | | 454 | { |
500 | struct screen *s = ctx->s; | | 455 | struct screen *s = ctx->s; |
501 | struct grid_cell gc; | | 456 | struct grid_cell gc; |
502 | u_int cx, cy, i; | | 457 | u_int cx, cy, i; |
503 | | | 458 | |
504 | cx = s->cx; | | 459 | cx = s->cx; |
505 | cy = s->cy; | | 460 | cy = s->cy; |
506 | | | 461 | |
507 | memcpy(&gc, &grid_default_cell, sizeof gc); | | 462 | memcpy(&gc, &grid_default_cell, sizeof gc); |
508 | gc.attr |= GRID_ATTR_CHARSET; | | 463 | gc.attr |= GRID_ATTR_CHARSET; |