diff --git a/include/extern.h b/include/extern.h index af726885b..bac993d62 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2180,6 +2180,8 @@ void console_g_putch(int in_ch); extern void set_output_mode(int); extern void synch_cursor(void); extern void nethack_enter_consoletty(void); +extern int get_console_width(void); +extern int get_console_height(void); extern void consoletty_exit(void); extern int set_keyhandling_via_option(void); #ifdef ENHANCED_SYMBOLS diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index 65462ef47..1e5cb7cd4 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -2638,6 +2638,18 @@ void nethack_enter_consoletty(void) nhUse(apisuccess); } +int +get_console_width(void) +{ + return console.width; +} + +int +get_console_height(void) +{ + return console.height; +} + RESTORE_WARNING_CONDEXPR_IS_CONSTANT #endif /* TTY_GRAPHICS */ diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index 5ab7ea198..5fcd726b9 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -761,11 +761,26 @@ curses_init_options(void) terminal size programmatically. If the user does not specify a size in the config file, we will set it to a nice big 32x110 to take advantage of some of the nice features of this windowport. */ - if (iflags.wc2_term_cols == 0) - iflags.wc2_term_cols = 110; - if (iflags.wc2_term_rows == 0) - iflags.wc2_term_rows = 32; + if (iflags.wc2_term_cols == 0) { +#ifndef MSWIN_GRAPHICS + int console_width = get_console_width(); + if (console_width != 0) + iflags.wc2_term_cols = console_width; + else +#endif + iflags.wc2_term_cols = 110; + } + if (iflags.wc2_term_rows == 0) { +#ifndef MSWIN_GRAPHICS + int console_height = get_console_height(); + + if (console_height != 0) + iflags.wc2_term_rows = console_height; + else +#endif + iflags.wc2_term_rows = 32; + } resize_term(iflags.wc2_term_rows, iflags.wc2_term_cols); getmaxyx(base_term, term_rows, term_cols);