shows menu of previous wishes, copies selected into buf, max BUFSZ len. buf is not modified, if nothing was selected. */
| 6272 | /* shows menu of previous wishes, copies selected into buf, max BUFSZ len. |
| 6273 | buf is not modified, if nothing was selected. */ |
| 6274 | staticfn void |
| 6275 | wish_history_menu(char *buf) |
| 6276 | { |
| 6277 | #ifdef DEBUG |
| 6278 | winid win; |
| 6279 | anything any; |
| 6280 | int i = 0, npick; |
| 6281 | menu_item *picks = (menu_item *) 0; |
| 6282 | int idx; |
| 6283 | |
| 6284 | win = create_nhwindow(NHW_MENU); |
| 6285 | start_menu(win, MENU_BEHAVE_STANDARD); |
| 6286 | any = cg.zeroany; |
| 6287 | |
| 6288 | for (i = MAX_WISH_HISTORY-1; i >= 0; i--) { |
| 6289 | idx = (wish_history_idx + i) % MAX_WISH_HISTORY; |
| 6290 | if (wish_history[idx]) { |
| 6291 | any.a_int = (i + 1); |
| 6292 | add_menu(win, &nul_glyphinfo, &any, '\0', 0, ATR_NONE, NO_COLOR, |
| 6293 | wish_history[idx], MENU_ITEMFLAGS_NONE); |
| 6294 | } |
| 6295 | } |
| 6296 | |
| 6297 | end_menu(win, "Wish what?"); |
| 6298 | npick = select_menu(win, PICK_ONE, &picks); |
| 6299 | destroy_nhwindow(win); |
| 6300 | if (npick > 0) { |
| 6301 | i = picks->item.a_int; |
| 6302 | i--; |
| 6303 | idx = (wish_history_idx + i) % MAX_WISH_HISTORY; |
| 6304 | |
| 6305 | if (wish_history[idx]) |
| 6306 | strcpy(buf, wish_history[idx]); |
| 6307 | } |
| 6308 | #endif /* DEBUG */ |
| 6309 | } |
| 6310 | |
| 6311 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 6312 |
no test coverage detected