use a menu to ask a specific response to a query. returns TRUE if the menu was shown to the user. puts the response char into res. */
| 5416 | returns TRUE if the menu was shown to the user. |
| 5417 | puts the response char into res. */ |
| 5418 | staticfn boolean |
| 5419 | yn_function_menu( |
| 5420 | const char *query, |
| 5421 | const char *resp, |
| 5422 | char def, |
| 5423 | char *res) |
| 5424 | { |
| 5425 | if (yn_menuable_resp(resp)) { |
| 5426 | winid win = create_nhwindow(NHW_MENU); |
| 5427 | menu_item *sel; |
| 5428 | int n; |
| 5429 | char keybuf[QBUFSZ]; |
| 5430 | |
| 5431 | start_menu(win, MENU_BEHAVE_STANDARD); |
| 5432 | if (resp == rightleftchars) { |
| 5433 | yn_func_menu_opt(win, 'r', "Right", def); |
| 5434 | yn_func_menu_opt(win, 'l', "Left", def); |
| 5435 | } else if (resp == hidespinchars) { |
| 5436 | yn_func_menu_opt(win, 'h', "Hide", def); |
| 5437 | yn_func_menu_opt(win, 's', "Spin a web", def); |
| 5438 | } else { |
| 5439 | yn_func_menu_opt(win, 'y', "Yes", def); |
| 5440 | yn_func_menu_opt(win, 'n', "No", def); |
| 5441 | } |
| 5442 | if (resp == ynaqchars) |
| 5443 | yn_func_menu_opt(win, 'a', "All", def); |
| 5444 | if (resp == ynqchars || resp == ynaqchars || resp == hidespinchars) |
| 5445 | yn_func_menu_opt(win, 'q', "Quit", def); |
| 5446 | end_menu(win, query); |
| 5447 | n = select_menu(win, PICK_ONE, &sel); |
| 5448 | destroy_nhwindow(win); |
| 5449 | if (n > 0) { |
| 5450 | *res = sel[0].item.a_char; |
| 5451 | /* two were selected? use the one that wasn't the default */ |
| 5452 | if (n > 1 && *res == def) |
| 5453 | *res = sel[1].item.a_char; |
| 5454 | free((genericptr_t) sel); |
| 5455 | } else { |
| 5456 | *res = def; |
| 5457 | } |
| 5458 | pline("%s %s", query, key2txt(*res, keybuf)); |
| 5459 | clear_nhwindow(WIN_MESSAGE); |
| 5460 | return TRUE; |
| 5461 | } |
| 5462 | return FALSE; |
| 5463 | } |
| 5464 | |
| 5465 | /* |
| 5466 | * Parameter validator for generic yes/no function to prevent |
no test coverage detected