maybe fix #H5264 - screen clears on prompting

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.
This commit is contained in:
PatR
2017-03-30 14:14:38 -07:00
parent 82620d16f5
commit 6ba906b234
6 changed files with 47 additions and 26 deletions
+2 -9
View 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);
+3 -5
View 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;
}