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.
This commit is contained in:
PatR
2023-02-21 14:00:31 -08:00
parent 998b5af644
commit ecf247a2a6
2 changed files with 14 additions and 5 deletions

View 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 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 using the 'i' command while carrying only gold; didn't matter whether
or not TTY_PERM_INVENT was enabled during build 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 Unix: after lua changes to Makefiles, 'make spotless' for dat subdirectory
left some generated data files which should have been deleted 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 Windows: new tile additions in win/share did not trigger the creation of a new

View File

@@ -2284,12 +2284,16 @@ tty_putstr(winid window, int attr, const char *str)
} }
break; break;
} }
return;
} }
void 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 */ #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 */ /* use external pager; this may give security problems */
int fd = open(fname, O_RDONLY); int fd = open(fname, O_RDONLY);
@@ -2297,7 +2301,7 @@ tty_display_file(const char *fname, boolean complain)
if (fd < 0) { if (fd < 0) {
if (complain) if (complain)
pline("Cannot open %s.", fname); pline("Cannot open %s.", fname);
else else /* [is this refresh actually necessary?] */
docrt(); docrt();
return; return;
} }
@@ -2337,10 +2341,11 @@ tty_display_file(const char *fname, boolean complain)
tty_mark_synch(); tty_mark_synch();
tty_raw_print(""); tty_raw_print("");
perror(fname); 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); pline("Cannot open \"%s\".", fname);
} else if (u.ux) }
docrt();
} else { } else {
winid datawin = tty_create_nhwindow(NHW_TEXT); winid datawin = tty_create_nhwindow(NHW_TEXT);
boolean empty = TRUE; boolean empty = TRUE;
@@ -2376,6 +2381,7 @@ tty_display_file(const char *fname, boolean complain)
} }
} }
#endif /* DEF_PAGER */ #endif /* DEF_PAGER */
return;
} }
void void