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

Function race_key

win/X11/winmisc.c:222–263  ·  view source on GitHub ↗

ARGSUSED */

Source from the content-addressed store, hash-verified

220
221/* ARGSUSED */
222void
223race_key(Widget w, XEvent *event, String *params, Cardinal *num_params)
224{
225 char ch, *mark;
226 char racechars[QBUFSZ];
227 int i;
228
229 nhUse(w);
230 nhUse(params);
231 nhUse(num_params);
232
233 (void) memset(racechars, '\0', sizeof racechars); /* for strchr() */
234 for (i = 0; races[i].noun; ++i) {
235 ch = lowc(*races[i].noun);
236 /* this supports at most two races with the same first letter */
237 if (strchr(racechars, ch))
238 ch = highc(ch);
239 racechars[i] = ch;
240 }
241 ch = key_event_to_char((XKeyEvent *) event);
242 if (ch == '\0') { /* don't accept nul char/modifier event */
243 /* don't beep */
244 return;
245 }
246 mark = strchr(racechars, ch);
247 if (!mark)
248 mark = strchr(racechars, lowc(ch));
249 if (!mark)
250 mark = strchr(racechars, highc(ch));
251 if (!mark) {
252 if (strchr(ps_randchars, ch))
253 ps_selected = PS_RANDOM;
254 else if (strchr(ps_quitchars, ch))
255 ps_selected = PS_QUIT;
256 else {
257 X11_nhbell(); /* no such race */
258 return;
259 }
260 } else
261 ps_selected = (int) (mark - racechars);
262 exit_x_event = TRUE;
263}
264
265/* ARGSUSED */
266void

Callers

nothing calls this directly

Calls 4

highcFunction · 0.85
key_event_to_charFunction · 0.85
X11_nhbellFunction · 0.85
lowcFunction · 0.50

Tested by

no test coverage detected