tty ^P message recall
Extend 'putstr(WIN_MESSAGE, attribute, string)'s attribute so that
'custompline(SUPPRESS_HISTORY, ...)' can work with ^P's message
history like DUMPLOG history, in order to keep autodescribe feedback
and intermediate prompts for multi-digit count ('Count: 12', 'Count:
123') prompts out of recall history. The old autodescribe behavior
could easily push all real messages out of the recall buffer when
moving the cursor around for getpos, and the count behavior looked
silly for a four or five digit gold count if you set the msg_window
option to 'full' or 'combination' and viewed them all at once.
Other interfaces may want to follow suit, but this doesn't force them
to make any changes. I added a hook for "urgent messages" that might
be rendered in bold or red or some such and/or override the use of
ESC at --More-- from suppressing further messages, but there aren't
any custompline(URGENT_MESSAGE, ...) calls (potentially "You die...",
for instance) to exercise it. Other people have implemented similar
feature it different ways and I'm not sure whether this one is really
the way to go since the core needs to categorize each message that it
deems to be urgent. MSG_TYPE:stop may be sufficent, although MSG_TYPE
matching can entail a lot of regexp execution overhead at run-time.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 topl.c $NHDT-Date: 1540934784 2018/10/30 21:26:24 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.38 $ */
|
||||
/* NetHack 3.6 topl.c $NHDT-Date: 1549327499 2019/02/05 00:44:59 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.43 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
STATIC_DCL void FDECL(redotoplin, (const char *));
|
||||
STATIC_DCL void FDECL(topl_putsym, (CHAR_P));
|
||||
STATIC_DCL void NDECL(remember_topl);
|
||||
STATIC_DCL void FDECL(removetopl, (int));
|
||||
STATIC_DCL void FDECL(msghistory_snapshot, (BOOLEAN_P));
|
||||
STATIC_DCL void FDECL(free_msghistory_snapshot, (BOOLEAN_P));
|
||||
@@ -144,7 +143,23 @@ const char *str;
|
||||
more();
|
||||
}
|
||||
|
||||
STATIC_OVL void
|
||||
/* for use by tty_putstr() */
|
||||
void
|
||||
show_topl(str)
|
||||
const char *str;
|
||||
{
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
|
||||
if (!(cw->flags & WIN_STOP)) {
|
||||
cw->curx = cw->cury = 0;
|
||||
home();
|
||||
cl_end();
|
||||
addtopl(str);
|
||||
}
|
||||
}
|
||||
|
||||
/* used by update_topl(); also by tty_putstr() */
|
||||
void
|
||||
remember_topl()
|
||||
{
|
||||
register struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
@@ -231,7 +246,8 @@ register const char *bp;
|
||||
/* If there is room on the line, print message on same line */
|
||||
/* But messages like "You die..." deserve their own line */
|
||||
n0 = strlen(bp);
|
||||
if ((ttyDisplay->toplin == 1 || (cw->flags & WIN_STOP)) && cw->cury == 0
|
||||
if ((ttyDisplay->toplin == 1 || (cw->flags & WIN_STOP))
|
||||
&& cw->cury == 0
|
||||
&& n0 + (int) strlen(toplines) + 3 < CO - 8 /* room for --More-- */
|
||||
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
|
||||
Strcat(toplines, " ");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1545705819 2018/12/25 02:43:39 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.190 $ */
|
||||
/* NetHack 3.6 wintty.c $NHDT-Date: 1549327503 2019/02/05 00:45:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.193 $ */
|
||||
/* Copyright (c) David Cohrs, 1991 */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -96,7 +96,7 @@ struct window_procs tty_procs = {
|
||||
| WC2_HILITE_STATUS | WC2_HITPOINTBAR | WC2_FLUSH_STATUS
|
||||
| WC2_RESET_STATUS
|
||||
#endif
|
||||
| WC2_DARKGRAY),
|
||||
| WC2_DARKGRAY | WC2_SUPPRESS_HIST),
|
||||
tty_init_nhwindows, tty_player_selection, tty_askname, tty_get_nh_event,
|
||||
tty_exit_nhwindows, tty_suspend_nhwindows, tty_resume_nhwindows,
|
||||
tty_create_nhwindow, tty_clear_nhwindow, tty_display_nhwindow,
|
||||
@@ -2574,13 +2574,29 @@ const char *str;
|
||||
print_vt_code2(AVTC_SELECT_WINDOW, window);
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
case NHW_MESSAGE: {
|
||||
int suppress_history = (attr & ATR_NOHISTORY);
|
||||
|
||||
/* in case we ever support display attributes for topline
|
||||
messages, clear flag mask leaving only display attr */
|
||||
/*attr &= ~(ATR_URGENT | ATR_NOHISTORY);*/
|
||||
|
||||
/* really do this later */
|
||||
#if defined(USER_SOUNDS) && defined(WIN32CON)
|
||||
play_sound_for_message(str);
|
||||
#endif
|
||||
update_topl(str);
|
||||
if (!suppress_history) {
|
||||
/* normal output; add to current top line if room, else flush
|
||||
whatever is there to history and then write this */
|
||||
update_topl(str);
|
||||
} else {
|
||||
/* put anything already on top line into history */
|
||||
remember_topl();
|
||||
/* write to top line without remembering what we're writing */
|
||||
show_topl(str);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#ifndef STATUS_HILITES
|
||||
case NHW_STATUS:
|
||||
ob = &cw->data[cw->cury][j = cw->curx];
|
||||
|
||||
Reference in New Issue
Block a user