MCPcopy Index your code
hub / github.com/NetHack/NetHack / handler_menu_colors

Function handler_menu_colors

src/options.c:6406–6499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6404}
6405
6406staticfn int
6407handler_menu_colors(void)
6408{
6409 winid tmpwin;
6410 anything any;
6411 char buf[BUFSZ];
6412 int opt_idx, nmc, mcclr, mcattr;
6413 char mcbuf[BUFSZ];
6414 int clr = NO_COLOR;
6415
6416 menucolors_again:
6417 nmc = count_menucolors();
6418 opt_idx = handle_add_list_remove("menucolor", nmc);
6419 if (opt_idx == 3) { /* done */
6420 menucolors_done:
6421 /* in case we've made a change which impacts current persistent
6422 inventory window; we don't track whether an actual changed
6423 occurred, so just assume there was one and that it matters;
6424 if we're wrong, a redundant update is cheap... */
6425 if (iflags.use_menu_color) {
6426 if (iflags.perm_invent)
6427 update_inventory();
6428
6429 }
6430 return optn_ok;
6431
6432 } else if (opt_idx == 0) { /* add new */
6433 mcbuf[0] = '\0';
6434 getlin("What new menucolor pattern?", mcbuf);
6435 if (*mcbuf == '\033')
6436 goto menucolors_done;
6437 if (*mcbuf
6438 && test_regex_pattern(mcbuf, "MENUCOLORS regex")
6439 && (mcclr = query_color((char *) 0, NO_COLOR)) != -1
6440 && (mcattr = query_attr((char *) 0, ATR_NONE)) != -1
6441 && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) {
6442 pline("Error adding the menu color.");
6443 wait_synch();
6444 }
6445 goto menucolors_again;
6446
6447 } else { /* list (1) or remove (2) */
6448 int pick_idx, pick_cnt;
6449 int mc_idx;
6450 unsigned ln;
6451 const char *sattr, *sclr;
6452 menu_item *pick_list = (menu_item *) 0;
6453 struct menucoloring *tmp = gm.menu_colorings;
6454 char clrbuf[QBUFSZ];
6455
6456 tmpwin = create_nhwindow(NHW_MENU);
6457 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
6458 any = cg.zeroany;
6459 mc_idx = 0;
6460 while (tmp) {
6461 sattr = attr2attrname(tmp->attr);
6462 sclr = strcpy(clrbuf, clr2colorname(tmp->color));
6463 (void) strNsubst(clrbuf, " ", "-", 0);

Callers 1

optfn_o_menu_colorsFunction · 0.85

Calls 15

count_menucolorsFunction · 0.85
handle_add_list_removeFunction · 0.85
update_inventoryFunction · 0.85
getlinFunction · 0.85
test_regex_patternFunction · 0.85
query_colorFunction · 0.85
query_attrFunction · 0.85
add_menu_coloring_parsedFunction · 0.85
wait_synchFunction · 0.85
attr2attrnameFunction · 0.85
clr2colornameFunction · 0.85
strNsubstFunction · 0.85

Tested by

no test coverage detected