]> granicus.if.org Git - nethack/commitdiff
curses message suppression
authorPatR <rankin@nethack.org>
Sun, 31 Mar 2019 22:34:46 +0000 (15:34 -0700)
committerPatR <rankin@nethack.org>
Sun, 31 Mar 2019 22:34:46 +0000 (15:34 -0700)
The curses interface was using 'moves' as if it meant "moves" rather
than "turns".  Typing ESC at >> (curses' terser version of --More--)
prompt would suppress messages for the rest of the current turn rather
than just the rest of the current move.  So if the hero got an extra
move due to being Fast, there would be no feedback during that move.

doc/fixes36.2
win/curses/cursdial.c
win/curses/cursmain.c
win/curses/cursmesg.c

index 5ee1657c4654b2e97364b3d7b5ad8f096d3e1e29..c1490f5fc1f1edce062f9bcf3b42d6b19dfe496c 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.293 $ $NHDT-Date: 1554045807 2019/03/31 15:23:27 $
+$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.294 $ $NHDT-Date: 1554071680 2019/03/31 22:34:40 $
 
 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,
@@ -529,6 +529,9 @@ curses: popup window to show ^P output was removed from screen but never
 curses: preserve ^P message history across save/restore
 curses: highlighting of status conditions was broken by the fix for timing out
        of temporary highlights setting off unnecessary status updates
+curses: if player pressed ESC at More>> prompt to suppress remaining messages
+       for the current move and then hero got another move on the same turn,
+       messages and most prompts would stay suppressed during that extra move
 vms: add compile of isaac64.c to Makefile.src and vmsbuild.com
 vms+curses: add compile support but it is known to fail to build
 
index af337f8588ede3a83b60062677811d01f2059dba..deee077fd9a03986d328e42fea8e0dd955d8b3d0 100644 (file)
@@ -17,6 +17,8 @@
 #define strncasecmp strncmpi
 #endif
 
+extern long curs_mesg_suppress_turn; /* from cursmesg.c */
+
 /*
  * Note:
  *
@@ -120,6 +122,10 @@ curses_line_input_dialog(const char *prompt, char *answer, int buffer)
     int height = prompt_height;
     char input[BUFSZ];
 
+    /* if messages were being suppressed for the remainder of the turn,
+       re-activate them now that input is being requested */
+    curs_mesg_suppress_turn = -1;
+
     if (buffer >= (int) sizeof input)
          buffer = (int) sizeof input - 1;
     maxwidth = term_cols - 2;
@@ -201,6 +207,10 @@ curses_character_input_dialog(const char *prompt, const char *choices,
     boolean any_choice = FALSE;
     boolean accept_count = FALSE;
 
+    /* if messages were being suppressed for the remainder of the turn,
+       re-activate them now that input is being requested */
+    curs_mesg_suppress_turn = -1;
+
     if (invent || (moves > 1)) {
         curses_get_window_size(MAP_WIN, &map_height, &map_width);
     } else {
index 8dba85a931bd6964a0483be702eae3493f23c7ed..c3cceb1f7090f7763714f725db3d0581a14fb45e 100644 (file)
@@ -9,6 +9,8 @@
 #include "color.h"
 #include "wincurs.h"
 
+extern long curs_mesg_suppress_turn; /* from cursmesg.c */
+
 /* Public functions for curses NetHack interface */
 
 /* Interface definition, for windows.c */
@@ -687,6 +689,9 @@ curses_nhgetch()
 {
     int ch;
 
+    /* if messages are being suppressed, reenable them */
+    curs_mesg_suppress_turn = -1;
+
     curses_prehousekeeping();
     ch = curses_read_char();
     curses_posthousekeeping();
index 57cc5636b815a12ce4d26f02619fc63533925613..c3d0aa5651ff077196a42cd7c1cab376ec410cb8 100644 (file)
@@ -9,6 +9,10 @@
 #include "cursmesg.h"
 #include <ctype.h>
 
+/* player can type ESC at More>> prompt to avoid seeing more messages
+   for the current move; but hero might get more than one move per turn,
+   so the input routines need to be able to cancel this */
+long curs_mesg_suppress_turn = -1; /* also used in cursdial.c && cursmain.c */
 
 /* Message window routines for curses interface */
 
@@ -46,16 +50,13 @@ curses_message_win_puts(const char *message, boolean recursed)
     boolean border = curses_window_has_border(MESSAGE_WIN);
     int message_length = strlen(message);
     int border_space = 0;
-    static long suppress_turn = -1;
 
-#if 1
+#if 0
     /*
-     * Handled by core's use of putstr(WIN_MESSAGE,ATR_NOHISTORY,message)
-     * for intermediate counts, but get_count() also uses putmsghistory()
-     * for the final count, to remember that without showing it.  But
-     * curses is using genl_putmsghistory() which just delivers the text
-     * via a normal pline().  This hides that at cost of not having it
-     * in ^P recall and being out of sync with DUMPLOG's message history.
+     * This was useful when curses used genl_putmsghistory() but is not
+     * needed now that it has its own curses_putmsghistory() that's
+     * capable of putting something into the ^P recall history without
+     * displaying it at the same time.
      */
     if (strncmp("Count:", message, 6) == 0) {
         curses_count_window(message);
@@ -63,8 +64,8 @@ curses_message_win_puts(const char *message, boolean recursed)
     }
 #endif
 
-    if (suppress_turn == moves) {
-        return;
+    if (curs_mesg_suppress_turn == moves) {
+        return; /* user has typed ESC to avoid seeing remaining messages. */
     }
 
     curses_get_window_size(MESSAGE_WIN, &height, &width);
@@ -105,7 +106,7 @@ curses_message_win_puts(const char *message, boolean recursed)
                 /* Pause until key is hit - Esc suppresses any further
                    messages that turn */
                 if (curses_more() == '\033') {
-                    suppress_turn = moves;
+                    curs_mesg_suppress_turn = moves;
                     return;
                 }
             } else {
@@ -156,6 +157,9 @@ curses_block(boolean noscroll) /* noscroll - blocking because of msgtype
     WINDOW *win = curses_get_nhwin(MESSAGE_WIN);
     const char *resp = " \r\n\033"; /* space, enter, esc */
 
+    /* if messages are being suppressed, reenable them */
+    curs_mesg_suppress_turn = -1;
+
     curses_get_window_size(MESSAGE_WIN, &height, &width);
     curses_toggle_color_attr(win, MORECOLOR, NONE, ON);
     mvwprintw(win, my, mx, ">>");