MCPcopy Index your code
hub / github.com/NetHack/NetHack / dohelp

Function dohelp

src/pager.c:2856–2899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2854};
2855
2856DISABLE_WARNING_FORMAT_NONLITERAL
2857
2858/* the #help command */
2859int
2860dohelp(void)
2861{
2862 winid tmpwin = create_nhwindow(NHW_MENU);
2863 char helpbuf[QBUFSZ], tmpbuf[QBUFSZ];
2864 int i, n;
2865 menu_item *selected;
2866 anything any;
2867 int sel;
2868 int clr = NO_COLOR;
2869
2870 any = cg.zeroany; /* zero all bits */
2871 start_menu(tmpwin, MENU_BEHAVE_STANDARD);
2872
2873 for (i = 0; help_menu_items[i].text; i++) {
2874 if (!wizard && help_menu_items[i].f == dispfile_debughelp)
2875 continue;
2876 if (sysopt.hideusage && help_menu_items[i].f == dispfile_usagehelp)
2877 continue;
2878
2879 if (help_menu_items[i].text[0] == '%') {
2880 Sprintf(helpbuf, help_menu_items[i].text, PORT_ID);
2881 } else if (help_menu_items[i].f == dispfile_optmenu) {
2882 Sprintf(helpbuf, help_menu_items[i].text, setopt_cmd(tmpbuf));
2883 } else {
2884 Strcpy(helpbuf, help_menu_items[i].text);
2885 }
2886 any.a_int = i + 1;
2887 add_menu(tmpwin, &nul_glyphinfo, &any, 0, 0, ATR_NONE, clr,
2888 helpbuf, MENU_ITEMFLAGS_NONE);
2889 }
2890 end_menu(tmpwin, "Select one item:");
2891 n = select_menu(tmpwin, PICK_ONE, &selected);
2892 destroy_nhwindow(tmpwin);
2893 if (n > 0) {
2894 sel = selected[0].item.a_int - 1;
2895 free((genericptr_t) selected);
2896 (void) (*help_menu_items[sel].f)();
2897 }
2898 return ECMD_OK;
2899}
2900
2901RESTORE_WARNING_FORMAT_NONLITERAL
2902

Callers 1

onWMCommandFunction · 0.85

Calls 3

setopt_cmdFunction · 0.85
add_menuFunction · 0.85
select_menuFunction · 0.85

Tested by

no test coverage detected