tty prompting fix and DUMPLOG of prompts+answers

Update DUMPLOG's message history to include player responses to
most queries.  For tty, both getlin() and yn_function().  For other
interfaces, only yn_function() is covered.  (It's intercepted by a
core routine that can take care of the logging; getlin() isn't.)
Also includes saved messages from previous session(s), for the
interfaces which support that (tty), to fill out the logging when
a game ends shortly after a save/restore cycle.

The tty interface was using pline() to display prompt strings.
Having 'MSGTYPE=hide "#"' or 'MSGTYPE=hide "yn"' in .nethackrc
would suppress many prompt strings (in the two examples mentioned,
entering extended commands or the vast majority of yes/no questions,
respectively) and generally lead to substantial confusion even if
done intentionally, so switch to putstr(WIN_MESSAGE) instead.
This commit is contained in:
PatR
2017-03-20 19:11:48 -07:00
parent a03d20d7ab
commit 82620d16f5
6 changed files with 102 additions and 24 deletions
+33 -7
View File
@@ -14,6 +14,7 @@
#include "func_tab.h"
char morc = 0; /* tell the outside world what char you chose */
STATIC_VAR boolean suppress_history;
STATIC_DCL boolean FDECL(ext_cmd_getlin_hook, (char *));
typedef boolean FDECL((*getlin_hook_proc), (char *));
@@ -35,6 +36,7 @@ tty_getlin(query, bufp)
const char *query;
register char *bufp;
{
suppress_history = FALSE;
hooked_tty_getlin(query, bufp, (getlin_hook_proc) 0);
}
@@ -48,13 +50,20 @@ 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++;
pline("%s ", query);
/*
* 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);
*obufp = 0;
for (;;) {
(void) fflush(stdout);
@@ -82,6 +91,7 @@ getlin_hook_proc hook;
if (c == '\020') { /* ctrl-P */
if (iflags.prevmsg_window != 's') {
int sav = ttyDisplay->inread;
ttyDisplay->inread = 0;
(void) tty_doprev_message();
ttyDisplay->inread = sav;
@@ -136,9 +146,9 @@ getlin_hook_proc hook;
#endif /* not NEWAUTOCOMP */
break;
} else if (' ' <= (unsigned char) c && c != '\177'
/* avoid isprint() - some people don't have it
' ' is not always a printing char */
&& (bufp - obufp < BUFSZ - 1 && bufp - obufp < COLNO)) {
/* avoid isprint() - some people don't have it
' ' is not always a printing char */
#ifdef NEWAUTOCOMP
char *i = eos(bufp);
@@ -166,7 +176,7 @@ getlin_hook_proc hook;
#endif /* NEWAUTOCOMP */
}
} else if (c == kill_char || c == '\177') { /* Robert Viduya */
/* this test last - @ might be the kill_char */
/* this test last - @ might be the kill_char */
#ifndef NEWAUTOCOMP
while (bufp != obufp) {
bufp--;
@@ -185,6 +195,17 @@ getlin_hook_proc hook;
ttyDisplay->toplin = 2; /* nonempty, no --More-- required */
ttyDisplay->inread--;
clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */
if (suppress_history) {
/* prevent next message from pushing current query+answer into
tty message history */
*toplines = '\0';
#ifdef DUMPLOG
} else {
/* needed because we've bypassed pline() */
dumplogmsg(toplines);
#endif
}
}
void
@@ -267,9 +288,14 @@ tty_get_ext_cmd()
if (iflags.extmenu)
return extcmd_via_menu();
/* maybe a runtime option? */
/* hooked_tty_getlin("#", buf, flags.cmd_comp ? ext_cmd_getlin_hook :
* (getlin_hook_proc) 0); */
suppress_history = TRUE;
/* maybe a runtime option?
* hooked_tty_getlin("#", buf,
* (flags.cmd_comp && !in_doagain)
* ? ext_cmd_getlin_hook
* : (getlin_hook_proc) 0);
*/
hooked_tty_getlin("#", buf, in_doagain ? (getlin_hook_proc) 0
: ext_cmd_getlin_hook);
(void) mungspaces(buf);