From 3278d7e0c1e8ca4a0c6d083dd43e0e3e536041b6 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 18 Nov 2022 17:54:17 -0800 Subject: [PATCH] control of command-line usage entry in '?' menu Instead of using a compile-time macro to suppress inclusion of the menu entry to show UNIX command-line usage in the help menu, use a sysconf setting instead. Default is HIDEUSAGE=0, to include the entry for command-line usage. Set HIDEUSAGE=1 to exclude that. Does not affect 'nethack --usage' if player actually has access to the command-line. --- dat/usagehlp | 4 ++-- doc/Guidebook.mn | 3 +++ doc/Guidebook.tex | 4 ++++ include/config.h | 11 +++-------- include/sys.h | 6 +++++- src/files.c | 3 +++ src/pager.c | 9 +++------ src/sys.c | 4 ++++ sys/unix/sysconf | 5 +++++ 9 files changed, 32 insertions(+), 17 deletions(-) diff --git a/dat/usagehlp b/dat/usagehlp index a6a4b6b77..5abbcac46 100644 --- a/dat/usagehlp +++ b/dat/usagehlp @@ -69,8 +69,8 @@ nethack --windowtype:Iii nethack -n don't show the 'news' file is one is present in nethack's directory. -nethack --nethackrc:File - use File instead of the default run-time configuration file (which is +nethack --nethackrc:RC-file + use RC-file instead of the default run-time configuration file (which is usually '~/.nethackrc'); the file name should include full path unless located in nethack's directory; nethack --no-nethackrc diff --git a/doc/Guidebook.mn b/doc/Guidebook.mn index 3c7b51887..6cc68c2d4 100644 --- a/doc/Guidebook.mn +++ b/doc/Guidebook.mn @@ -5765,6 +5765,9 @@ POINTSMIN\ =\ Minimum number of points to get an entry in the score file. PERS_IS_UID\ =\ 0 or 1 to use user names or numeric userids, respectively, to identify unique people for the score file. .lp +HIDEUSAGE\ =\ 0 or 1 to control whether the help menu entry for command +line usage is shown or suppressed. +.lp MAX_STATUENAME_RANK\ =\ Maximum number of score file entries to use for random statue names (default is 10). .lp diff --git a/doc/Guidebook.tex b/doc/Guidebook.tex index f139a0549..d5daebd71 100644 --- a/doc/Guidebook.tex +++ b/doc/Guidebook.tex @@ -6371,6 +6371,10 @@ Minimum number of points to get an entry in the score file. 0 or 1 to use user names or numeric userids, respectively, to identify unique people for the score file. %.lp +\item[\ib{HIDEUSAGE}] +0 or 1 to control whether the help menu entry for command +line usage is shown or suppressed. +%.lp \item[\ib{MAX\verb+_+STATUENAME\verb+_+RANK}] Maximum number of score file entries to use for random statue names (default is 10). diff --git a/include/config.h b/include/config.h index f518340cc..211afa134 100644 --- a/include/config.h +++ b/include/config.h @@ -202,6 +202,9 @@ * PERS_IS_UID (0 or 1 - person is name or (numeric) userid) * Can force incubi/succubi behavior to be toned down to nymph-like: * SEDUCE (0 or 1 - runtime disable/enable SEDUCE option) + * Can hide the entry for displaying command line usage from + * the help menu if players don't have access to command lines: + * HIDEUSAGE (0 or 1 - runtime show/hide command line usage) * The following options pertain to crash reporting: * GREPPATH (the path to the system grep(1) utility) * GDBPATH (the path to the system gdb(1) program) @@ -421,14 +424,6 @@ */ #endif /* CHDIR */ -/* - * Define HIDE_USAGE to keep the "description of command line" out of - * the help menu if players have no access to a command line or if that - * is radically different from the description for UNIX in dat/usagehlp - * (a better solution for that would be a separate file and different - * value for USAGEHELP in global.h). - */ -/* #define HIDE_USAGE */ /* */ /* * Section 3: Definitions that may vary with system type. diff --git a/include/sys.h b/include/sys.h index 8caa39b43..38d4eba5a 100644 --- a/include/sys.h +++ b/include/sys.h @@ -50,8 +50,12 @@ struct sysopt { /* enable accessibility options */ int accessibility; #ifdef WIN32 - int portable_device_paths; /* nethack configuration for a portable device */ + int portable_device_paths; /* nethack config for a portable device */ #endif + + /* nethack's interactive help menu */ + int hideusage; /* 0: include 'command-line usage' entry in help menu; + * 1: suppress it */ }; extern struct sysopt sysopt; diff --git a/src/files.c b/src/files.c index 3fc074db9..00de5203f 100644 --- a/src/files.c +++ b/src/files.c @@ -2577,6 +2577,9 @@ parse_config_line(char *origbuf) } sysopt.seduce = n; sysopt_seduce_set(sysopt.seduce); + } else if (in_sysconf && match_varname(buf, "HIDEUSAGE", 9)) { + n = !!atoi(bufp); + sysopt.hideusage = n; } else if (in_sysconf && match_varname(buf, "MAXPLAYERS", 10)) { n = atoi(bufp); /* XXX to get more than 25, need to rewrite all lock code */ diff --git a/src/pager.c b/src/pager.c index dc323cd80..07d81ce4b 100644 --- a/src/pager.c +++ b/src/pager.c @@ -32,9 +32,7 @@ static void dispfile_optionfile(void); static void dispfile_optmenu(void); static void dispfile_license(void); static void dispfile_debughelp(void); -#ifndef HIDE_USAGE static void dispfile_usagehelp(void); -#endif static void hmenu_doextversion(void); static void hmenu_dohistory(void); static void hmenu_dowhatis(void); @@ -2358,13 +2356,11 @@ dispfile_debughelp(void) display_file(DEBUGHELP, TRUE); } -#ifndef HIDE_USAGE static void dispfile_usagehelp(void) { display_file(USAGEHELP, TRUE); } -#endif static void hmenu_doextversion(void) @@ -2423,9 +2419,7 @@ static const struct { { dokeylist, "Full list of keyboard commands." }, { hmenu_doextlist, "List of extended commands." }, { domenucontrols, "List menu control keys." }, -#ifndef HIDE_USAGE { dispfile_usagehelp, "Description of NetHack's command line." }, -#endif { dispfile_license, "The NetHack license." }, { docontact, "Support information." }, #ifdef PORT_HELP @@ -2455,6 +2449,9 @@ dohelp(void) for (i = 0; help_menu_items[i].text; i++) { if (!wizard && help_menu_items[i].f == dispfile_debughelp) continue; + if (sysopt.hideusage && help_menu_items[i].f == dispfile_usagehelp) + continue; + if (help_menu_items[i].text[0] == '%') { Sprintf(helpbuf, help_menu_items[i].text, PORT_ID); } else if (help_menu_items[i].f == dispfile_optmenu) { diff --git a/src/sys.c b/src/sys.c index 100749a8c..74538a63e 100644 --- a/src/sys.c +++ b/src/sys.c @@ -81,6 +81,10 @@ sys_early_init(void) #ifdef WIN32 sysopt.portable_device_paths = 0; #endif + + /* help menu */ + sysopt.hideusage = 0; + return; } diff --git a/sys/unix/sysconf b/sys/unix/sysconf index 9053c7236..c02b546e0 100644 --- a/sys/unix/sysconf +++ b/sys/unix/sysconf @@ -83,6 +83,11 @@ MAXPLAYERS=10 # numeric (1) user id. #PERS_IS_UID=1 +# Help menu control; 0 - include "command line usage" entry in help menu; +# 1 - suppress it from the menu. Does not affect 'nethack --usage' when +# player has access to the command line. +#HIDEUSAGE=0 + # Maximum number of score file entries to use for random statue names #MAX_STATUENAME_RANK=10