From 190c90e95edbab27d83c6699215cca262ca0e345 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 4 Feb 2019 16:46:04 -0800 Subject: [PATCH 1/3] 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. --- include/hack.h | 3 ++- include/winprocs.h | 16 +++++++++++----- include/wintty.h | 4 +++- include/wintype.h | 18 +++++++++++------- src/cmd.c | 6 ++---- src/pline.c | 27 +++++++++++++++++++++++---- win/tty/topl.c | 24 ++++++++++++++++++++---- win/tty/wintty.c | 24 ++++++++++++++++++++---- 8 files changed, 92 insertions(+), 30 deletions(-) diff --git a/include/hack.h b/include/hack.h index 6dfedf762..f686f7a4a 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 hack.h $NHDT-Date: 1547514631 2019/01/15 01:10:31 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.101 $ */ +/* NetHack 3.6 hack.h $NHDT-Date: 1549327459 2019/02/05 00:44:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.102 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -402,6 +402,7 @@ enum explosion_types { #define PLINE_NOREPEAT 1 #define OVERRIDE_MSGTYPE 2 #define SUPPRESS_HISTORY 4 +#define URGENT_MESSAGE 8 /* Macros for messages referring to hands, eyes, feet, etc... */ enum bodypart_types { diff --git a/include/winprocs.h b/include/winprocs.h index 85ece4a7d..26512c8ce 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 winprocs.h $NHDT-Date: 1502141230 2017/08/07 21:27:10 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.38 $ */ +/* NetHack 3.6 winprocs.h $NHDT-Date: 1549327479 2019/02/05 00:44:39 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.46 $ */ /* Copyright (c) David Cohrs, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -213,14 +213,20 @@ extern #define WC2_DARKGRAY 0x0020L /* 06 use bold black for black glyphs */ #define WC2_HITPOINTBAR 0x0040L /* 07 show bar representing hit points */ #define WC2_FLUSH_STATUS 0x0080L /* 08 call status_update(BL_FLUSH) - after updating status window fields */ -#define WC2_RESET_STATUS 0x0100L /* 09 call status_update(BL_RESET) to indicate - draw everything */ + * after updating status window fields */ +#define WC2_RESET_STATUS 0x0100L /* 09 call status_update(BL_RESET) to + * indicate 'draw everything' */ #define WC2_TERM_SIZE 0x0200L /* 10 support setting terminal size */ #define WC2_WINDOWBORDERS 0x0400L /* 11 display borders on nh windows */ #define WC2_PETATTR 0x0800L /* 12 attributes for hilite_pet */ #define WC2_GUICOLOR 0x1000L /* 13 display colours outside map win */ - /* 19 free bits */ +/* pline() can overload the display attributes argument passed to putstr() + with one or more flags and at most one of bold/blink/inverse/&c */ +#define WC2_URGENT_MESG 0x2000L /* 14 putstr(WIN_MESSAGE) supports urgency + * via non-display attribute flag */ +#define WC2_SUPPRESS_HIST 0x4000L /* 15 putstr(WIN_MESSAGE) supports history + * suppression via non-disp attr */ + /* 17 free bits */ #define ALIGN_LEFT 1 #define ALIGN_RIGHT 2 diff --git a/include/wintty.h b/include/wintty.h index 99b560d82..f7e5b0611 100644 --- a/include/wintty.h +++ b/include/wintty.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintty.h $NHDT-Date: 1433806583 2015/06/08 23:36:23 $ $NHDT-Branch: master $:$NHDT-Revision: 1.24 $ */ +/* NetHack 3.6 wintty.h $NHDT-Date: 1549327485 2019/02/05 00:44:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.32 $ */ /* Copyright (c) David Cohrs, 1991,1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -164,6 +164,8 @@ E int FDECL(has_color, (int color)); /* ### topl.c ### */ +E void FDECL(show_topl, (const char *)); +E void NDECL(remember_topl); E void FDECL(addtopl, (const char *)); E void NDECL(more); E void FDECL(update_topl, (const char *)); diff --git a/include/wintype.h b/include/wintype.h index 3bb82347d..26afbca3f 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 wintype.h $NHDT-Date: 1461028538 2016/04/19 01:15:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.16 $ */ +/* NetHack 3.6 wintype.h $NHDT-Date: 1549327486 2019/02/05 00:44:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.19 $ */ /* Copyright (c) David Cohrs, 1991 */ /* NetHack may be freely redistributed. See license for details. */ @@ -74,12 +74,16 @@ typedef struct mi { #define NHW_TEXT 5 /* attribute types for putstr; the same as the ANSI value, for convenience */ -#define ATR_NONE 0 -#define ATR_BOLD 1 -#define ATR_DIM 2 -#define ATR_ULINE 4 -#define ATR_BLINK 5 -#define ATR_INVERSE 7 +#define ATR_NONE 0 +#define ATR_BOLD 1 +#define ATR_DIM 2 +#define ATR_ULINE 4 +#define ATR_BLINK 5 +#define ATR_INVERSE 7 +/* not a display attribute but passed to putstr() as an attribute; + can be masked with one regular display attribute */ +#define ATR_URGENT 16 +#define ATR_NOHISTORY 32 /* nh_poskey() modifier types */ #define CLICK_1 1 diff --git a/src/cmd.c b/src/cmd.c index 5b77eb1a4..c3166bd6a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1548978603 2019/01/31 23:50:03 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.330 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1549327488 2019/02/05 00:44:48 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.331 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -5572,9 +5572,7 @@ boolean historical; /* whether to include in message history: True => yes */ Sprintf(qbuf, "Count: %ld", cnt); backspaced = FALSE; } - /* bypassing pline() keeps intermediate prompt out of - DUMPLOG message history */ - putstr(WIN_MESSAGE, 0, qbuf); + custompline(SUPPRESS_HISTORY, "%s", qbuf); mark_synch(); } } diff --git a/src/pline.c b/src/pline.c index ebde8b145..d7db3f43d 100644 --- a/src/pline.c +++ b/src/pline.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 pline.c $NHDT-Date: 1541719974 2018/11/08 23:32:54 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.69 $ */ +/* NetHack 3.6 pline.c $NHDT-Date: 1549327495 2019/02/05 00:44:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.73 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -9,6 +9,7 @@ static unsigned pline_flags = 0; static char prevmsg[BUFSZ]; +static void FDECL(putmesg, (const char *)); static char *FDECL(You_buf, (int)); #if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__)) static void FDECL(execplinehandler, (const char *)); @@ -61,6 +62,23 @@ dumplogfreemessages() } #endif +/* keeps windowprocs usage out of pline() */ +static void +putmesg(line) +const char *line; +{ + int attr = ATR_NONE; + + if ((pline_flags & URGENT_MESSAGE) != 0 + && (windowprocs.wincap2 & WC2_URGENT_MESG) != 0) + attr |= ATR_URGENT; + if ((pline_flags & SUPPRESS_HISTORY) != 0 + && (windowprocs.wincap2 & WC2_SUPPRESS_HIST) != 0) + attr |= ATR_NOHISTORY; + + putstr(WIN_MESSAGE, attr, line); +} + /* Note that these declarations rely on knowledge of the internals * of the variable argument handling stuff in "tradstdc.h" */ @@ -156,8 +174,9 @@ VA_DECL(const char *, line) no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE; if ((pline_flags & OVERRIDE_MSGTYPE) == 0) { msgtyp = msgtype_type(line, no_repeat); - if (msgtyp == MSGTYP_NOSHOW - || (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg))) + if ((pline_flags & URGENT_MESSAGE) == 0 + && (msgtyp == MSGTYP_NOSHOW + || (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))) /* FIXME: we need a way to tell our caller that this message * was suppressed so that caller doesn't set iflags.last_msg * for something that hasn't been shown, otherwise a subsequent @@ -173,7 +192,7 @@ VA_DECL(const char *, line) if (u.ux) flush_screen(1); /* %% */ - putstr(WIN_MESSAGE, 0, line); + putmesg(line); #if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__)) execplinehandler(line); diff --git a/win/tty/topl.c b/win/tty/topl.c index 5233e1525..15ed6097f 100644 --- a/win/tty/topl.c +++ b/win/tty/topl.c @@ -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, " "); diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 0cdb63ab5..939a32552 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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]; From 18cea92a59ea3f597d10e76a0fae02be94eefe28 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 4 Feb 2019 16:52:37 -0800 Subject: [PATCH 2/3] tty ^P fixes entry Left this out of previous commit. --- doc/fixes36.2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index ea3ce46a2..f7107ad90 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.245 $ $NHDT-Date: 1549157810 2019/02/03 01:36:50 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.246 $ $NHDT-Date: 1549327954 2019/02/05 00:52:34 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -479,6 +479,8 @@ tty: support BL_RESET in status_update to force an update to all status fields tty: stop hitpointbar from jumping to 100% health at zero hit points tty: try harder to prevent a disconnected terminal (SIGHUP) from running amok and using up all available CPU time +tty: suppress intermediate 'Count: 123' prompt and getpos autodescribe + feedback from being included in ^P message recall MacOSX: add curses window port MacOSX: add Xcode project to sys/unixNetHack.xcodeproj MacOSX: add Xcode supporting files README.xcode and XCode.xcconfig From 7042e5fdef175cce6d1000fe08aa89790c1c42d9 Mon Sep 17 00:00:00 2001 From: nhmall Date: Mon, 4 Feb 2019 20:02:53 -0500 Subject: [PATCH 3/3] another contributed Amiga bit, missing line continuations in Makefile --- sys/amiga/Makefile.ami | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/amiga/Makefile.ami b/sys/amiga/Makefile.ami index b96adb3bc..14b12986a 100644 --- a/sys/amiga/Makefile.ami +++ b/sys/amiga/Makefile.ami @@ -1606,9 +1606,9 @@ $(I)global.h: $(I)coord.h $(I)pcconf.h $(I)amiconf.h -setdate $(I)global.h -wait 2 -$(I)hack.h: $(I)config.h $(I)context.h $(I)trap.h $(I)decl.h $(I)dungeon.h - $(I)monsym.h $(I)mkroom.h $(I)objclass.h $(I)flag.h $(I)rm.h - $(I)vision.h $(I)display.h $(I)wintype.h $(I)engrave.h +$(I)hack.h: $(I)config.h $(I)context.h $(I)trap.h $(I)decl.h $(I)dungeon.h \ + $(I)monsym.h $(I)mkroom.h $(I)objclass.h $(I)flag.h $(I)rm.h \ + $(I)vision.h $(I)display.h $(I)wintype.h $(I)engrave.h \ $(I)rect.h $(I)region.h $(I)trampoli.h $(I)sys.h -setdate $(I)hack.h -wait 2