]> granicus.if.org Git - nethack/commitdiff
control of command-line usage entry in '?' menu
authorPatR <rankin@nethack.org>
Sat, 19 Nov 2022 01:54:17 +0000 (17:54 -0800)
committerPatR <rankin@nethack.org>
Sat, 19 Nov 2022 01:54:17 +0000 (17:54 -0800)
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
doc/Guidebook.mn
doc/Guidebook.tex
include/config.h
include/sys.h
src/files.c
src/pager.c
src/sys.c
sys/unix/sysconf

index a6a4b6b77fc85fe8b22ecbabeaa2786573220b45..5abbcac46814fb7d7b41d009229f9a3d5ffe7fa5 100644 (file)
@@ -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
index 3c7b51887ff1fad2caf1db3e9ff1a9671b5e0b06..6cc68c2d46702b254a1d56b126f5033957f30391 100644 (file)
@@ -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
index f139a0549a878a9a6abc54edd2e673b638696c70..d5daebd711c421ff330db016f69b5829b764311c 100644 (file)
@@ -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).
index f518340cc149b2627e0a8a7442a37ada4c71e993..211afa13478c2b6a05b2b6e500e6d7113b1aac84 100644 (file)
  *              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)
  */
 #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.
index 8caa39b43cc362e2a87e146ede131c4b1ea94b89..38d4eba5a90787bc13dc7759a258a9e2f34d0fee 100644 (file)
@@ -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;
index 3fc074db92bc4e8a831ff9dd33dd849a5258e92c..00de5203fbf2cea267e0214994ee650913422d1e 100644 (file)
@@ -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 */
index dc323cd8076ac077fc958c37b6390f559a807700..07d81ce4bad462711d8daa23087fab7834fc325f 100644 (file)
@@ -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) {
index 100749a8c6a47809253bd4f03a59ae71f4498079..74538a63e1954153e972a062fece592062d803e8 100644 (file)
--- 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;
 }
 
index 9053c723616f10203af5a7be3e7abd720be668d9..c02b546e0c66c80a64e192bace6f871914c99365 100644 (file)
@@ -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