| 6328 | } |
| 6329 | |
| 6330 | staticfn int |
| 6331 | handler_autopickup_exception(void) |
| 6332 | { |
| 6333 | winid tmpwin; |
| 6334 | anything any; |
| 6335 | int i; |
| 6336 | int opt_idx, numapes = 0; |
| 6337 | char apebuf[2 + BUFSZ]; /* so &apebuf[1] is BUFSZ long for getlin() */ |
| 6338 | struct autopickup_exception *ape; |
| 6339 | int clr = NO_COLOR; |
| 6340 | |
| 6341 | ape_again: |
| 6342 | numapes = count_apes(); |
| 6343 | opt_idx = handle_add_list_remove("autopickup exception", numapes); |
| 6344 | if (opt_idx == 3) { /* done */ |
| 6345 | return TRUE; |
| 6346 | } else if (opt_idx == 0) { /* add new */ |
| 6347 | /* EDIT_GETLIN: assume user doesn't user want previous |
| 6348 | exception used as default input string for this one... */ |
| 6349 | apebuf[0] = apebuf[1] = '\0'; |
| 6350 | getlin("What new autopickup exception pattern?", &apebuf[1]); |
| 6351 | mungspaces(&apebuf[1]); /* regularize whitespace */ |
| 6352 | if (apebuf[1] == '\033') |
| 6353 | return TRUE; |
| 6354 | if (apebuf[1]) { |
| 6355 | apebuf[0] = '\"'; |
| 6356 | /* guarantee room for \" prefix and \"\0 suffix; |
| 6357 | -2 is good enough for apebuf[] but -3 makes |
| 6358 | sure the whole thing fits within normal BUFSZ */ |
| 6359 | apebuf[sizeof apebuf - 2] = '\0'; |
| 6360 | Strcat(apebuf, "\""); |
| 6361 | add_autopickup_exception(apebuf); |
| 6362 | } |
| 6363 | goto ape_again; |
| 6364 | } else { /* list (1) or remove (2) */ |
| 6365 | int pick_idx, pick_cnt; |
| 6366 | menu_item *pick_list = (menu_item *) 0; |
| 6367 | |
| 6368 | tmpwin = create_nhwindow(NHW_MENU); |
| 6369 | start_menu(tmpwin, MENU_BEHAVE_STANDARD); |
| 6370 | if (numapes) { |
| 6371 | ape = ga.apelist; |
| 6372 | any = cg.zeroany; |
| 6373 | add_menu_heading(tmpwin, |
| 6374 | "Always pickup '<'; never pickup '>'"); |
| 6375 | for (i = 0; i < numapes && ape; i++) { |
| 6376 | any.a_void = (opt_idx == 1) ? 0 : ape; |
| 6377 | /* length of pattern plus quotes (plus '<'/'>') is |
| 6378 | less than BUFSZ */ |
| 6379 | Sprintf(apebuf, "\"%c%s\"", ape->grab ? '<' : '>', |
| 6380 | ape->pattern); |
| 6381 | add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, |
| 6382 | ATR_NONE, clr, apebuf, MENU_ITEMFLAGS_NONE); |
| 6383 | ape = ape->next; |
| 6384 | } |
| 6385 | } |
| 6386 | Sprintf(apebuf, "%s autopickup exceptions", |
| 6387 | (opt_idx == 1) ? "List of" : "Remove which"); |
no test coverage detected