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

Function ext_cmd_getlin_hook

win/tty/getline.c:271–285  ·  view source on GitHub ↗

* Implement extended command completion by using this hook into * tty_getlin. Check the characters already typed, if they uniquely * identify an extended command, expand the string to the whole * command. * * Return TRUE if we've extended the string at base. Otherwise return FALSE. * Assumptions: * * + we don't change the characters that are already in base * + base has enough

Source from the content-addressed store, hash-verified

269 * + base has enough room to hold our string
270 */
271static boolean
272ext_cmd_getlin_hook(char *base)
273{
274 int *ecmatches;
275 int nmatches = extcmds_match(base, ECM_NOFLAGS, &ecmatches);
276
277 if (nmatches == 1) {
278 struct ext_func_tab *ec = extcmds_getentry(ecmatches[0]);
279
280 Strcpy(base, ec->ef_txt);
281 return TRUE;
282 }
283
284 return FALSE; /* didn't match anything */
285}
286
287/*
288 * Read in an extended command, doing command line completion. We

Callers

nothing calls this directly

Calls 2

extcmds_matchFunction · 0.85
extcmds_getentryFunction · 0.85

Tested by

no test coverage detected