]> granicus.if.org Git - nethack/commitdiff
maybe fix #H5264 - screen clears on prompting
authorPatR <rankin@nethack.org>
Thu, 30 Mar 2017 21:14:38 +0000 (14:14 -0700)
committerPatR <rankin@nethack.org>
Thu, 30 Mar 2017 21:14:38 +0000 (14:14 -0700)
I couldn't reproduce the reported problem of the "In what direction?"
being issued after the screen was cleared, but bypassing pline() in
favor of putstr(WIN_MESSAGE) for tty prompts did also bypass
  if (vision_full_recalc) vision_recalc(0);
  if (u.ux) flush_screen(1);
done in pline().  Inadvertent loss of the latter could conceivably be
responsible for the problem.  If so, the escape code used by cl_end()
may be broken for somebody's termcap or terminfo setup since clearing
to the end of the line in the message window shouldn't erase the rest
of the screen.

Regardless, the prompting change also bypassed the ability to show
the prompt with raw_printf() if the display wasn't fully intialized
yet, so some change to the revised prompting was necessary anyway.

Switching back from putstr(WIN_MESSAGE) to pline() resulted in
duplicated entries in DUMPLOG message history, one with bare prompt
followed by another with response appended, so more tweaking was
needed.  The result is use of new custompline() instead of normal
pline().  custompline() accepts some message handling flags to give
more control over pline()'s behavior.  It's a more general variation
of Norep() but its caller needs to specify an extra argument.

doc/fixes36.1
include/extern.h
include/hack.h
src/pline.c
win/tty/getline.c
win/tty/topl.c

index 63c80b848da82b829ff5b5c5d0e03290544c8326..7fa058915a41a8dffddf03e7983039c0c34c452a 100644 (file)
@@ -402,6 +402,7 @@ DUMPLOG: RIP tombstone was printed for characters who survived (ascended,
        escaped dungeon, quit, trickery or panic)
 artifact creation violated illiterate conduct when artifact name was assigned,
        behavior intended only for creating Sting or Orcrist via naming
+tty: revert to pline() for issuing prompts (override MSGTYPE=hide differently)
 
 
 Platform- and/or Interface-Specific Fixes
index fb3b7dfa42b6512bb1d357e49b1794c46d762dda..82765df78b248864ed664f587a209684fb1197b0 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 extern.h        $NHDT-Date: 1489192904 2017/03/11 00:41:44 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.583 $ */
+/* NetHack 3.6 extern.h        $NHDT-Date: 1490908458 2017/03/30 21:14:18 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.585 $ */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1806,6 +1806,7 @@ E void FDECL(dumplogmsg, (const char *));
 E void NDECL(dumplogfreemessages);
 #endif
 E void VDECL(pline, (const char *, ...)) PRINTF_F(1, 2);
+E void VDECL(custompline, (unsigned, const char *, ...)) PRINTF_F(2, 3);
 E void VDECL(Norep, (const char *, ...)) PRINTF_F(1, 2);
 E void NDECL(free_youbuf);
 E void VDECL(You, (const char *, ...)) PRINTF_F(1, 2);
index bf2273b2b8133191e3e5889372b0c1ec0fbde1e6..b7cf512c74b3cab3db102fc16f68e27f903af7a9 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 hack.h  $NHDT-Date: 1451683048 2016/01/01 21:17:28 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.68 $ */
+/* NetHack 3.6 hack.h  $NHDT-Date: 1490908464 2017/03/30 21:14:24 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.76 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -359,6 +359,12 @@ enum explosion_types {
 #define XKILL_NOCORPSE  2
 #define XKILL_NOCONDUCT 4
 
+/* pline_flags; mask values for custompline()'s first argument */
+/* #define PLINE_ORDINARY 0 */
+#define PLINE_NOREPEAT   1
+#define OVERRIDE_MSGTYPE 2
+#define SUPPRESS_HISTORY 4
+
 /* Macros for messages referring to hands, eyes, feet, etc... */
 enum bodypart_types {
     ARM = 0,
index 2a473625b5357b6e992ccafeba1592eb250e24f7..118ed82eec5a887634fdb68915f127af03f70fba 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 pline.c $NHDT-Date: 1489192905 2017/03/11 00:41:45 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.57 $ */
+/* NetHack 3.6 pline.c $NHDT-Date: 1490908465 2017/03/30 21:14:25 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.58 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -6,7 +6,7 @@
                                        */
 #include "hack.h"
 
-static boolean no_repeat = FALSE;
+static unsigned pline_flags = 0;
 static char prevmsg[BUFSZ];
 
 static char *FDECL(You_buf, (int));
@@ -98,7 +98,8 @@ VA_DECL(const char *, line)
 {       /* start of vpline() or of nested block in USE_OLDARG's pline() */
     char pbuf[3 * BUFSZ];
     int ln;
-    xchar msgtyp;
+    int msgtyp;
+    boolean no_repeat;
     /* Do NOT use VA_START and VA_END in here... see above */
 
     if (!line || !*line)
@@ -134,18 +135,23 @@ VA_DECL(const char *, line)
         return;
     }
 
+    msgtyp = MSGTYP_NORMAL;
+    no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
 #ifdef DUMPLOG
     /* We hook here early to have options-agnostic output.
      * Unfortunately, that means Norep() isn't honored (general issue) and
      * that short lines aren't combined into one longer one (tty behavior).
      */
-    dumplogmsg(line);
+    if ((pline_flags & SUPPRESS_HISTORY) == 0)
+        dumplogmsg(line);
 #endif
+    if ((pline_flags & OVERRIDE_MSGTYPE) != 0) {
+        msgtyp = msgtype_type(line, no_repeat);
+        if (msgtyp == MSGTYP_NOSHOW
+            || (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
+            return;
+    }
 
-    msgtyp = msgtype_type(line, no_repeat);
-    if (msgtyp == MSGTYP_NOSHOW
-        || (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
-        return;
     if (vision_full_recalc)
         vision_recalc(0);
     if (u.ux)
@@ -170,15 +176,31 @@ VA_DECL(const char *, line)
 #endif
 }
 
+/* pline() variant which can override MSGTYPE handling or suppress
+   message history (tty interface uses pline() to issue prompts and
+   they shouldn't be blockable via MSGTYPE=hide) */
+/*VARARGS2*/
+void custompline
+VA_DECL2(unsigned, pflags, const char *, line)
+{
+    VA_START(line);
+    VA_INIT(line, const char *);
+    pline_flags = pflags;
+    vpline(line, VA_ARGS);
+    pline_flags = 0;
+    VA_END();
+    return;
+}
+
 /*VARARGS1*/
 void Norep
 VA_DECL(const char *, line)
 {
     VA_START(line);
     VA_INIT(line, const char *);
-    no_repeat = TRUE;
+    pline_flags = PLINE_NOREPEAT;
     vpline(line, VA_ARGS);
-    no_repeat = FALSE;
+    pline_flags = 0;
     VA_END();
     return;
 }
index 8d61aabfe5df727cb1183a98b2e8315d8ec2db1e..f3dd6cbf2f0ec64a50ab339b3a762c30fb4f0878 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 getline.c       $NHDT-Date: 1432512813 2015/05/25 00:13:33 $  $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
+/* NetHack 3.6 getline.c       $NHDT-Date: 1490908467 2017/03/30 21:14:27 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.31 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -50,20 +50,13 @@ getlin_hook_proc hook;
     register int c;
     struct WinDesc *cw = wins[WIN_MESSAGE];
     boolean doprev = 0;
-    char tmpbuf[BUFSZ]; /* [QBUFSZ+1] should suffice */
 
     if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
         more();
     cw->flags &= ~WIN_STOP;
     ttyDisplay->toplin = 3; /* special prompt state */
     ttyDisplay->inread++;
-    /*
-     * This used to use pline("%s ", query), but that made getline
-     * prompts be susceptible to suppression via the MSGTYPE mechanism.
-     * Having 'MSGTYPE=hide "# "' was particularly confusing.
-     */
-    Sprintf(tmpbuf, "%s ", query);
-    tty_putstr(WIN_MESSAGE, 0, tmpbuf);
+    custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query);
     *obufp = 0;
     for (;;) {
         (void) fflush(stdout);
index cefc08f958609cb881d7b5e1c9ccebd079b30978..c4a778eef58ef07e51b926baf3cab4ee1a3561d4 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 topl.c  $NHDT-Date: 1463787697 2016/05/20 23:41:37 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.33 $ */
+/* NetHack 3.6 topl.c  $NHDT-Date: 1490908468 2017/03/30 21:14:28 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.36 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -385,14 +385,12 @@ char def;
         /* not pline("%s ", prompt);
            trailing space is wanted here in case of reprompt */
         Strcat(prompt, " ");
-        /* pline("%s", prompt); -- see comment in hooked_tty_getlin() */
-        tty_putstr(WIN_MESSAGE, 0, prompt);
+        custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s", prompt);
     } else {
         /* no restriction on allowed response, so always preserve case */
         /* preserve_case = TRUE; -- moot since we're jumping to the end */
-        /* pline("%s ", query); -- see above about tty_getlin() */
         Sprintf(prompt, "%s ", query);
-        tty_putstr(WIN_MESSAGE, 0, prompt);
+        custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s", prompt);
         q = readchar();
         goto clean_up;
     }