From: PatR Date: Tue, 21 Feb 2023 22:00:31 +0000 (-0800) Subject: tty_display_file() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecf247a2a6149832be98e1d03df191bb2373b751;p=nethack tty_display_file() 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. --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index faf65a68e..00d0d11c2 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 242c10322..7945fc201 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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 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