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

Function menu_select

win/X11/winmenu.c:131–174  ·  view source on GitHub ↗

* Menu callback. */ ARGSUSED */

Source from the content-addressed store, hash-verified

129 */
130/* ARGSUSED */
131static void
132menu_select(Widget w, XtPointer client_data, XtPointer call_data)
133{
134 struct menu_info_t *menu_info;
135 long how_many;
136 x11_menu_item *curr = (x11_menu_item *) client_data;
137 struct xwindow *wp;
138 Arg args[2];
139
140 nhUse(call_data);
141
142 if (!curr)
143 return;
144
145 wp = &window_list[curr->window];
146
147 menu_info = wp->menu_information;
148 how_many = menu_info->counting ? menu_info->menu_count : -1L;
149 reset_menu_count(menu_info);
150
151 /* if the menu is not active or don't have an identifier, try again */
152 if (!menu_info->is_active || curr->identifier.a_void == 0) {
153 X11_nhbell();
154 return;
155 }
156
157 /* if we've reached here, we've found our selected item */
158 if (menu_info->how != PICK_ONE || !curr->preselected)
159 curr->selected = !curr->selected;
160 curr->preselected = FALSE;
161 if (curr->selected) {
162 curr->str[2] = (how_many != -1L) ? '#' : '+';
163 curr->pick_count = how_many;
164 } else {
165 curr->str[2] = '-';
166 curr->pick_count = -1L;
167 }
168
169 XtSetArg(args[0], nhStr(XtNlabel), curr->str);
170 XtSetValues(w, args, ONE);
171
172 if (menu_info->how == PICK_ONE)
173 menu_popdown(wp);
174}
175
176/*
177 * Called when menu window is deleted.

Callers

nothing calls this directly

Calls 3

X11_nhbellFunction · 0.85
menu_popdownFunction · 0.85
reset_menu_countFunction · 0.50

Tested by

no test coverage detected