revise curses_raw_print()

For curses, behave like tty by keeping a count of messages issued via
raw_print, then if that is non-zero issue a prompt and require the
player to acknowledge them before it erases the screen.  Mainly so
that complaints during RC file processing will be seen.

For tty, force getret() to be an unconditional routine instead of
sometimes a routine, sometimes a macro which calls another routine.
This commit is contained in:
PatR
2024-05-17 14:38:17 -07:00
parent 80fb8c77d3
commit d5546d3384
5 changed files with 44 additions and 17 deletions
+3
View File
@@ -2097,6 +2097,9 @@ curses: change petattr attributes, dropping support for curses-only ones
curses: swap the grey and no-color color initialization curses: swap the grey and no-color color initialization
curses: allow changing default colors with the 'palette' config option curses: allow changing default colors with the 'palette' config option
(only if compiled with CHANGE_COLOR) (only if compiled with CHANGE_COLOR)
curses: if messages have been issued during start-up (for instance, warnings
about issues in run-time config file), prompt user to press <return>
so that they can be read before curses erases the screen
macOS: Xcode project was failing to build if the path to the NetHack source macOS: Xcode project was failing to build if the path to the NetHack source
tree contained a space; the issue was within some shell script code tree contained a space; the issue was within some shell script code
contained within the project contained within the project
+2 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 flag.h $NHDT-Date: 1707122958 2024/02/05 08:49:18 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.236 $ */ /* NetHack 3.7 flag.h $NHDT-Date: 1715979826 2024/05/17 21:03:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.246 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */ /*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -257,6 +257,7 @@ struct instance_flags {
int override_ID; /* true to force full identification of objects */ int override_ID; /* true to force full identification of objects */
int parse_config_file_src; /* hack for parse_config_line() */ int parse_config_file_src; /* hack for parse_config_line() */
int purge_monsters; /* # of dead monsters still on fmon list */ int purge_monsters; /* # of dead monsters still on fmon list */
int raw_printed; /* count of messages issued before window_inited */
int suppress_price; /* controls doname() for unpaid objects */ int suppress_price; /* controls doname() for unpaid objects */
unsigned terrainmode; /* for getpos()'s autodescribe during #terrain */ unsigned terrainmode; /* for getpos()'s autodescribe during #terrain */
#define TER_MAP 0x01U #define TER_MAP 0x01U
+2
View File
@@ -206,6 +206,8 @@ void
def_raw_print(const char *s) def_raw_print(const char *s)
{ {
puts(s); puts(s);
if (*s)
iflags.raw_printed++;
} }
staticfn staticfn
+26 -4
View File
@@ -207,6 +207,12 @@ curses_init_nhwindows(
#endif #endif
#endif #endif
/* if anything has already been output by nethack (for instance, warnings
about RC file issues), let the player acknowlege it before initscr()
erases the screen */
if (iflags.raw_printed)
curses_wait_synch();
#ifdef XCURSES #ifdef XCURSES
base_term = Xinitscr(*argcp, argv); base_term = Xinitscr(*argcp, argv);
#else #else
@@ -853,6 +859,23 @@ wait_synch() -- Wait until all pending output is complete (*flush*() for
void void
curses_wait_synch(void) curses_wait_synch(void)
{ {
if (iflags.raw_printed) {
int chr;
/*
* If any message has been issued via raw_print(), make the user
* acknowledge it. This might take place before initscr() so
* access to curses is limited. [Despite that, there's probably
* a more curses-specific way to handle this. FIXME?]
*/
(void) fprintf(stdout, "\nPress <return> to continue: ");
(void) fflush(stdout);
do {
chr = fgetc(stdin);
} while (chr > 0 && chr != C('j') && chr != C('m') && chr != '\033');
iflags.raw_printed = 0;
}
if (iflags.window_inited) { if (iflags.window_inited) {
if (curses_got_output()) if (curses_got_output())
(void) curses_more(); (void) curses_more();
@@ -1001,12 +1024,11 @@ curses_raw_print(const char *str)
if (iflags.window_inited) { if (iflags.window_inited) {
curses_message_win_puts(str, FALSE); curses_message_win_puts(str, FALSE);
} else { return;
puts(str);
} }
#else
puts(str);
#endif #endif
puts(str);
iflags.raw_printed++;
} }
/* /*
+11 -12
View File
@@ -1,4 +1,4 @@
/* NetHack 3.7 wintty.c $NHDT-Date: 1708290310 2024/02/18 21:05:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.386 $ */ /* NetHack 3.7 wintty.c $NHDT-Date: 1715979847 2024/05/17 21:04:07 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.406 $ */
/* Copyright (c) David Cohrs, 1991 */ /* Copyright (c) David Cohrs, 1991 */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -208,15 +208,10 @@ boolean GFlag = FALSE;
boolean HE_resets_AS; /* see termcap.c */ boolean HE_resets_AS; /* see termcap.c */
#endif #endif
#if defined(MICRO) || defined(WIN32CON)
static const char to_continue[] = "to continue";
#define getret() getreturn(to_continue)
#else
static void getret(void);
#endif
static void bail(const char *); /* __attribute__((noreturn)) */ static void bail(const char *); /* __attribute__((noreturn)) */
static void newclipping(coordxy, coordxy); static void newclipping(coordxy, coordxy);
static void new_status_window(void); static void new_status_window(void);
static void getret(void);
static void erase_menu_or_text(winid, struct WinDesc *, boolean); static void erase_menu_or_text(winid, struct WinDesc *, boolean);
static void free_window_info(struct WinDesc *, boolean); static void free_window_info(struct WinDesc *, boolean);
static boolean toggle_menu_curr(winid, tty_menu_item *, int, boolean, static boolean toggle_menu_curr(winid, tty_menu_item *, int, boolean,
@@ -770,10 +765,12 @@ tty_get_nh_event(void)
return; return;
} }
#if !defined(MICRO) && !defined(WIN32CON)
static void static void
getret(void) getret(void)
{ {
#if defined(MICRO) || defined(WIN32CON)
getreturn("to continue");
#else
HUPSKIP(); HUPSKIP();
xputs("\n"); xputs("\n");
if (flags.standout) if (flags.standout)
@@ -784,8 +781,9 @@ getret(void)
if (flags.standout) if (flags.standout)
standoutend(); standoutend();
xwaitforspace(" "); xwaitforspace(" ");
}
#endif #endif
iflags.raw_printed = 0;
}
void void
tty_suspend_nhwindows(const char *str) tty_suspend_nhwindows(const char *str)
@@ -3965,6 +3963,8 @@ tty_raw_print(const char *str)
HUPSKIP(); HUPSKIP();
if (ttyDisplay) if (ttyDisplay)
ttyDisplay->rawprint++; ttyDisplay->rawprint++;
else if (*str)
iflags.raw_printed++;
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE); print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
#if defined(MICRO) || defined(WIN32CON) #if defined(MICRO) || defined(WIN32CON)
msmsg("%s\n", str); msmsg("%s\n", str);
@@ -3980,6 +3980,8 @@ tty_raw_print_bold(const char *str)
HUPSKIP(); HUPSKIP();
if (ttyDisplay) if (ttyDisplay)
ttyDisplay->rawprint++; ttyDisplay->rawprint++;
else if (*str)
iflags.raw_printed++;
print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE); print_vt_code2(AVTC_SELECT_WINDOW, NHW_BASE);
term_start_raw_bold(); term_start_raw_bold();
#if defined(MICRO) || defined(WIN32CON) #if defined(MICRO) || defined(WIN32CON)
@@ -5257,9 +5259,6 @@ play_usersound_via_idx(int idx, int volume)
#endif #endif
#undef RESIZABLE #undef RESIZABLE
#ifdef getret
#undef getret
#endif
#undef HUPSKIP #undef HUPSKIP
#undef HUPSKIP_RESULT #undef HUPSKIP_RESULT
#undef ttypanic #undef ttypanic