]> granicus.if.org Git - nethack/commitdiff
more '&m'
authorPatR <rankin@nethack.org>
Tue, 21 Jun 2022 23:22:44 +0000 (16:22 -0700)
committerPatR <rankin@nethack.org>
Tue, 21 Jun 2022 23:22:44 +0000 (16:22 -0700)
For what a key does, when operating on 'm' which produces two lines
of output, append a command to the first line so that the combination
forms a complete sentence.  Also, expand on the explanattion of what
is going on in dowhatdoes().

src/pager.c

index d5542463e0ea232d1161a65a9899b9fd77a4b41a..b1c50873f66008965e7e1a3a185395b5bcb070a7 100644 (file)
@@ -2149,6 +2149,8 @@ dowhatdoes_core(char q, char *cbuf)
     if ((ec_desc = key2extcmddesc(q)) != NULL) {
         char keybuf[QBUFSZ];
 
+        /* note: if "%-8s" gets changed, the "%8.8s" in dowhatdoes() will
+           need a comparable change */
         Sprintf(buf, "%-8s%s.", key2txt(q, keybuf), ec_desc);
         Strcpy(cbuf, buf);
         return cbuf;
@@ -2253,12 +2255,19 @@ dowhatdoes(void)
 
         if (q == '&' || q == '?')
             whatdoes_help();
-        if (p)
-            *p = '\0';
-        pline("%s", reslt);
-        if (p)
+        if (!p) {
+            /* normal usage; 'reslt' starts with key, some indentation, and
+               then explanation followed by '.' for sentence punctuation */
+            pline("%s", reslt);
+        } else {
+            /* for 'm' prefix, where 'reslt' has an embedded newline to
+               indicate and separate two lines of output; we add a comma to
+               first line so that the combination is a complete sentence */
+            *p = '\0'; /* replace embedded newline with end of first line */
+            pline("%s,", reslt);
             /* 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);