]> granicus.if.org Git - nethack/commitdiff
tty_display_file()
authorPatR <rankin@nethack.org>
Tue, 21 Feb 2023 22:00:31 +0000 (14:00 -0800)
committerPatR <rankin@nethack.org>
Tue, 21 Feb 2023 22:00:31 +0000 (14:00 -0800)
For the !defined(DEF_PAGER) config, if the file to be displayed
can't be opened, refresh the screen after complaining about that
rather than when no complaint is issued.

doc/fixes3-7-0.txt
win/tty/wintty.c

index faf65a68e69cb2b104d8dcdbb914f82bd4563978..00d0d11c20f3b11dfbbc375e7eefe0c75a5a028f 100644 (file)
@@ -1541,6 +1541,9 @@ tty: changes to support utf8 resulted in lines of text windows being shown
 tty: changes to support TTY_PERM_INVENT resulted in blank inventory menu when
        using the 'i' command while carrying only gold; didn't matter whether
        or not TTY_PERM_INVENT was enabled during build
+tty: for the !DEF_PAGER configuration, redraw screen properly if attempting
+       to display a file fails and tty_display_file()'s caller requests
+       feedback for that situation
 Unix: after lua changes to Makefiles, 'make spotless' for dat subdirectory
        left some generated data files which should have been deleted
 Windows: new tile additions in win/share did not trigger the creation of a new
index 242c10322ef00a0d743c35d1864d11a7e3c827de..7945fc201df239899f0dc45a6eeda44549764d97 100644 (file)
@@ -2284,12 +2284,16 @@ tty_putstr(winid window, int attr, const char *str)
         }
         break;
     }
+    return;
 }
 
 void
-tty_display_file(const char *fname, boolean complain)
+tty_display_file(
+    const char *fname, /* name of file to display */
+    boolean complain)  /* whether to report problem if file can't be opened */
 {
 #ifdef DEF_PAGER /* this implies that UNIX is defined */
+    /* FIXME:  this won't work if fname is inside a dlb container */
     {
         /* use external pager; this may give security problems */
         int fd = open(fname, O_RDONLY);
@@ -2297,7 +2301,7 @@ tty_display_file(const char *fname, boolean complain)
         if (fd < 0) {
             if (complain)
                 pline("Cannot open %s.", fname);
-            else
+            else /* [is this refresh actually necessary?] */
                 docrt();
             return;
         }
@@ -2337,10 +2341,11 @@ tty_display_file(const char *fname, boolean complain)
                 tty_mark_synch();
                 tty_raw_print("");
                 perror(fname);
-                tty_wait_synch();
+                tty_wait_synch(); /* "Hit <space> to continue: " */
+                if (u.ux) /* if hero is on map, refresh the screen */
+                    docrt();
                 pline("Cannot open \"%s\".", fname);
-            } else if (u.ux)
-                docrt();
+            }
         } else {
             winid datawin = tty_create_nhwindow(NHW_TEXT);
             boolean empty = TRUE;
@@ -2376,6 +2381,7 @@ tty_display_file(const char *fname, boolean complain)
         }
     }
 #endif /* DEF_PAGER */
+    return;
 }
 
 void