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

Function tty_get_ext_cmd

win/tty/getline.c:291–326  ·  view source on GitHub ↗

* Read in an extended command, doing command line completion. We * stop when we have found enough characters to make a unique command. */

Source from the content-addressed store, hash-verified

289 * stop when we have found enough characters to make a unique command.
290 */
291int
292tty_get_ext_cmd(void)
293{
294 char buf[BUFSZ];
295 int nmatches;
296 int *ecmatches = 0;
297 boolean (*no_hook)(char *base) = (boolean (*)(char *)) 0;
298 char extcmd_char[2];
299
300 if (iflags.extmenu)
301 return extcmd_via_menu();
302
303 suppress_history = TRUE;
304 /* maybe a runtime option?
305 * hooked_tty_getlin("#", buf,
306 * (flags.cmd_comp && !gi.in_doagain)
307 * ? ext_cmd_getlin_hook
308 * : (getlin_hook_proc) 0);
309 */
310 extcmd_char[0] = extcmd_initiator(), extcmd_char[1] = '\0';
311 buf[0] = '\0';
312 hooked_tty_getlin(extcmd_char, buf,
313 !gi.in_doagain ? ext_cmd_getlin_hook : no_hook);
314 (void) mungspaces(buf);
315
316 nmatches = (buf[0] == '\0' || buf[0] == '\033') ? -1
317 : extcmds_match(buf, ECM_IGNOREAC | ECM_EXACTMATCH, &ecmatches);
318 if (nmatches != 1) {
319 if (nmatches != -1)
320 pline("%s%.60s: unknown extended command.",
321 visctrl(extcmd_char[0]), buf);
322 return -1;
323 }
324
325 return ecmatches[0];
326}
327
328#endif /* TTY_GRAPHICS */
329

Callers

nothing calls this directly

Calls 7

extcmd_via_menuFunction · 0.85
extcmd_initiatorFunction · 0.85
hooked_tty_getlinFunction · 0.85
mungspacesFunction · 0.85
extcmds_matchFunction · 0.85
visctrlFunction · 0.85
plineFunction · 0.50

Tested by

no test coverage detected