MCPcopy Create free account
hub / github.com/NetHack/NetHack / handler_menustyle

Function handler_menustyle

src/options.c:5543–5583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5541#endif
5542
5543staticfn int
5544handler_menustyle(void)
5545{
5546 winid tmpwin;
5547 anything any;
5548 boolean chngd;
5549 int i, n, old_menu_style = flags.menu_style;
5550 char buf[BUFSZ], sep = iflags.menu_tab_sep ? '\t' : ' ';
5551 menu_item *style_pick = (menu_item *) 0;
5552 int clr = NO_COLOR;
5553
5554 tmpwin = create_nhwindow(NHW_MENU);
5555 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
5556 any = cg.zeroany;
5557 for (i = 0; i < SIZE(menutype); i++) {
5558 Sprintf(buf, "%-12.12s%c%.60s", menutype[i][0], sep, menutype[i][1]);
5559 any.a_int = i + 1;
5560 add_menu(tmpwin, &nul_glyphinfo, &any, *buf, 0, ATR_NONE, clr, buf,
5561 (i == flags.menu_style) ? MENU_ITEMFLAGS_SELECTED
5562 : MENU_ITEMFLAGS_NONE);
5563 /* second line is prefixed by spaces that "c - " would use */
5564 Sprintf(buf, "%4s%-12.12s%c%.60s", "", "", sep, menutype[i][2]);
5565 add_menu_str(tmpwin, buf);
5566 }
5567 end_menu(tmpwin, "Select menustyle:");
5568 n = select_menu(tmpwin, PICK_ONE, &style_pick);
5569 if (n > 0) {
5570 i = style_pick[0].item.a_int - 1;
5571 /* if there are two picks, use the one that wasn't pre-selected */
5572 if (n > 1 && i == old_menu_style)
5573 i = style_pick[1].item.a_int - 1;
5574 flags.menu_style = i;
5575 free((genericptr_t) style_pick);
5576 }
5577 destroy_nhwindow(tmpwin);
5578 chngd = (flags.menu_style != old_menu_style);
5579 if (chngd || flags.verbose)
5580 pline("'menustyle' %s \"%s\".", chngd ? "changed to" : "is still",
5581 menutype[(int) flags.menu_style][0]);
5582 return optn_ok;
5583}
5584
5585staticfn int
5586handler_align_misc(int optidx)

Callers 1

optfn_menustyleFunction · 0.85

Calls 4

add_menuFunction · 0.85
add_menu_strFunction · 0.85
select_menuFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected