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

Function tty_select_menu

win/tty/wintty.c:2774–2815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2772}
2773
2774int
2775tty_select_menu(winid window, int how, menu_item **menu_list)
2776{
2777 struct WinDesc *cw = 0;
2778 tty_menu_item *curr;
2779 menu_item *mi;
2780 int n, cancelled;
2781
2782 if (window == WIN_ERR || (cw = wins[window]) == (struct WinDesc *) 0
2783 || cw->type != NHW_MENU)
2784 ttywindowpanic();
2785
2786 if (cw->mbehavior == MENU_BEHAVE_PERMINV) {
2787 return 0;
2788 }
2789 *menu_list = (menu_item *) 0;
2790 cw->how = (short) how;
2791 morc = 0;
2792 tty_display_nhwindow(window, TRUE);
2793 cancelled = !!(cw->flags & WIN_CANCELLED);
2794 tty_dismiss_nhwindow(window); /* does not destroy window data */
2795
2796 if (cancelled) {
2797 n = -1;
2798 } else {
2799 for (n = 0, curr = cw->mlist; curr; curr = curr->next)
2800 if (curr->selected)
2801 n++;
2802 }
2803
2804 if (n > 0) {
2805 *menu_list = (menu_item *) alloc(n * sizeof(menu_item));
2806 for (mi = *menu_list, curr = cw->mlist; curr; curr = curr->next)
2807 if (curr->selected) {
2808 mi->item = curr->identifier;
2809 mi->count = curr->count;
2810 mi++;
2811 }
2812 }
2813
2814 return n;
2815}
2816
2817/* special hack for treating top line --More-- as a one item menu */
2818char

Callers

nothing calls this directly

Calls 3

tty_display_nhwindowFunction · 0.85
tty_dismiss_nhwindowFunction · 0.85
allocFunction · 0.50

Tested by

no test coverage detected