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

Function handler_change_autocompletions

src/cmd.c:2448–2515  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2446}
2447
2448void
2449handler_change_autocompletions(void)
2450{
2451 winid win;
2452 anything any;
2453 int i, n;
2454 menu_item *picks = (menu_item *) 0;
2455 int clr = NO_COLOR;
2456 struct ext_func_tab *ec;
2457 char buf[BUFSZ];
2458
2459 win = create_nhwindow(NHW_MENU);
2460 start_menu(win, MENU_BEHAVE_STANDARD);
2461 any = cg.zeroany;
2462
2463 for (i = 0; i < extcmdlist_length; i++) {
2464 ec = &extcmdlist[i];
2465
2466 if ((ec->flags & (INTERNALCMD|CMD_NOT_AVAILABLE)) != 0)
2467 continue;
2468 if (strlen(ec->ef_txt) < 2)
2469 continue;
2470
2471 any.a_int = (i + 1);
2472 Sprintf(buf, "%c %s: %s",
2473 (ec->flags & AUTOCOMP_ADJ) ? '*' : ' ',
2474 ec->ef_txt, ec->ef_desc);
2475 add_menu(win, &nul_glyphinfo, &any, '\0', 0, ATR_NONE, clr, buf,
2476 (ec->flags & AUTOCOMPLETE)
2477 ? MENU_ITEMFLAGS_SELECTED :
2478 MENU_ITEMFLAGS_NONE);
2479 }
2480
2481 end_menu(win, "Which commands autocomplete?");
2482 n = select_menu(win, PICK_ANY, &picks);
2483 if (n >= 0) {
2484 int j;
2485
2486 for (i = 0; i < extcmdlist_length; i++) {
2487 boolean setit = FALSE;
2488
2489 ec = &extcmdlist[i];
2490
2491 if ((ec->flags & (INTERNALCMD|CMD_NOT_AVAILABLE)) != 0)
2492 continue;
2493 if (strlen(ec->ef_txt) < 2)
2494 continue;
2495
2496 Sprintf(buf, "%s", ec->ef_txt);
2497
2498 for (j = 0; j < n; ++j) {
2499 if (ec == &extcmdlist[(picks[j].item.a_int - 1)]) {
2500 parseautocomplete(buf, TRUE);
2501 setit = TRUE;
2502 break;
2503 }
2504 }
2505

Callers 1

optfn_o_autocompleteFunction · 0.85

Calls 3

add_menuFunction · 0.85
select_menuFunction · 0.85
parseautocompleteFunction · 0.85

Tested by

no test coverage detected