]> granicus.if.org Git - nethack/commitdiff
better feedback for '& m' and '? f m'
authorPatR <rankin@nethack.org>
Mon, 13 Jun 2022 11:41:31 +0000 (04:41 -0700)
committerPatR <rankin@nethack.org>
Mon, 13 Jun 2022 11:41:31 +0000 (04:41 -0700)
For the description of what a keystroke does, augment 'm' (or whatever
key has been bound to #reqmenu) to replace the default description
|m      prefix: request menu or modify command (#reqmenu).
with
|m      movement prefix: move without autopickup and without attacking
|m      non-movement prefix: request menu or modify command (#reqmenu).

The text is delivered by pline so tty will issue --More-- between the
two lines.

src/cmd.c
src/pager.c

index 0e20aa7eb1b1279a688f31c839376a07fec73aae..3c27ed945427630fdfab966461e9e5084a495cbc 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 cmd.c   $NHDT-Date: 1655114986 2022/06/13 10:09:46 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.572 $ */
+/* NetHack 3.7 cmd.c   $NHDT-Date: 1655120485 2022/06/13 11:41:25 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.573 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2487,6 +2487,11 @@ struct ext_func_tab extcmdlist[] = {
               doremring, 0, NULL },
     { C('a'), "repeat", "repeat a previous command",
               do_repeat, IFBURIED | GENERALCMD, NULL },
+    /* "modify command" is a vague description for use as no-autopickup,
+       no-attack movement as well as miscellaneous non-movement things;
+       key2extcmddesc() constructs a more explicit two line description
+       for display by the '&' command and expects to find "prefix:" as
+       the start of the text here */
     { 'm',    "reqmenu", "prefix: request menu or modify command",
               do_reqmenu, PREFIXCMD, NULL },
     { C('_'), "retravel", "travel to previously selected travel location",
@@ -2824,7 +2829,19 @@ key2extcmddesc(uchar key)
     /* finally, check whether 'key' is a command */
     if (g.Cmd.commands[key] && (txt = g.Cmd.commands[key]->ef_txt) != 0) {
         Sprintf(key2cmdbuf, "%s (#%s)", g.Cmd.commands[key]->ef_desc, txt);
-        /* special case: 'txt' for '#' is "#" and showing that as
+
+        /* special case: for reqmenu prefix (normally 'm'), replace
+           "prefix: request menu or modify command (#reqmenu)"
+           with two-line "movement prefix:...\nnon-movement prefix:..." */
+        if (!strncmpi(key2cmdbuf, "prefix:", 7) && !strcmpi(txt, "reqmenu"))
+            (void) strsubst(key2cmdbuf, "prefix:",
+                     /* relies on implicit concatenation of literal strings */
+                            "movement prefix:"
+                            " move without autopickup and without attacking"
+                            "\n"
+                            "non-movement prefix:"); /* and rest of buf */
+
+        /* another special case: 'txt' for '#' is "#" and showing that as
            "perform an extended command (##)" looks silly; strip "(##)" off */
         return strsubst(key2cmdbuf, " (##)", "");
     }
index dac6ada1662ceea7368cbdddf317a8a42e30bbe3..d5542463e0ea232d1161a65a9899b9fd77a4b41a 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 pager.c $NHDT-Date: 1642630920 2022/01/19 22:22:00 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.210 $ */
+/* NetHack 3.7 pager.c $NHDT-Date: 1655120486 2022/06/13 11:41:26 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.225 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2018. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2249,9 +2249,16 @@ dowhatdoes(void)
 #endif
     reslt = dowhatdoes_core(q, bufr);
     if (reslt) {
+        char *p = index(reslt, '\n'); /* 'm' prefix has two lines of output */
+
         if (q == '&' || q == '?')
             whatdoes_help();
+        if (p)
+            *p = '\0';
         pline("%s", reslt);
+        if (p)
+            /* cheat by knowing how dowhatdoes_core() handles key portion */
+            pline("%8.8s%s", reslt, p + 1);
     } else {
         pline("No such command '%s', char code %d (0%03o or 0x%02x).",
               visctrl(q), (uchar) q, (uchar) q, (uchar) q);