diff --git a/include/extern.h b/include/extern.h index 7f0e72aaa..cb0234696 100644 --- a/include/extern.h +++ b/include/extern.h @@ -3410,6 +3410,10 @@ extern void choose_windows(const char *); void addto_windowchain(const char *s); void commit_windowchain(void); #endif +#ifdef TTY_GRAPHICS +extern boolean check_tty_wincap(unsigned long); +extern boolean check_tty_wincap2(unsigned long); +#endif extern boolean genl_can_suspend_no(void); extern boolean genl_can_suspend_yes(void); extern char genl_message_menu(char, int, const char *); diff --git a/src/options.c b/src/options.c index a3c9f1688..fabb8a96c 100644 --- a/src/options.c +++ b/src/options.c @@ -5155,9 +5155,16 @@ can_set_perm_invent(void) * and is about to be changed to True. */ uchar old_perminv_mode = iflags.perminv_mode; - - if (!(windowprocs.wincap & WC_PERM_INVENT)) - return FALSE; /* should never happen */ + if (!(windowprocs.wincap & WC_PERM_INVENT)) { +#ifdef TTY_GRAPHICS +#ifdef TTY_PERM_INVENT + /* check tty, not necessarily the active window port; + windows early startup can still be set to safeprocs */ + if (!check_tty_wincap(WC_PERM_INVENT)) +#endif +#endif + return FALSE; /* should never happen */ + } if (iflags.perminv_mode == InvOptNone) iflags.perminv_mode = InvOptOn; diff --git a/src/windows.c b/src/windows.c index 7f9d28d7e..dfcf4e168 100644 --- a/src/windows.c +++ b/src/windows.c @@ -59,6 +59,10 @@ extern void trace_procs_init(int); extern void *trace_procs_chain(int, int, void *, void *, void *); #endif +#if defined(WINCHAIN) || defined(TTY_GRAPHICS) +static struct win_choices *win_choices_find(const char *s); +#endif + static void def_raw_print(const char *s); static void def_wait_synch(void); static boolean get_menu_coloring(const char *, int *, int *); @@ -222,7 +226,29 @@ def_wait_synch(void) return; } -#ifdef WINCHAIN +#ifdef TTY_GRAPHICS +boolean +check_tty_wincap(unsigned long wincap) +{ + struct win_choices *wc = win_choices_find("tty"); + + if (wc) + return ((wc->procs->wincap & wincap) == wincap); + return FALSE; +} + +boolean +check_tty_wincap2(unsigned long wincap2) +{ + struct win_choices *wc = win_choices_find("tty"); + + if (wc) + return ((wc->procs->wincap2 & wincap2) == wincap2); + return FALSE; +} +#endif + +#if defined(WINCHAIN) || defined(TTY_GRAPHICS) static struct win_choices * win_choices_find(const char *s) {