diff --git a/include/extern.h b/include/extern.h index 8f113ba2d..eafc34c92 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2031,6 +2031,10 @@ extern int win32_cr_helper(char, struct CRctxt *, void *, int); extern int win32_cr_gettrace(int, char *, int); extern int *win32_cr_shellexecute(const char *); # endif +#ifdef MSWIN_GRAPHICS +extern int get_approx_window_column_width(void); +extern int get_approx_window_rows(void); +#endif #endif /* WIN32 */ #endif /* MICRO || WIN32 */ diff --git a/sys/windows/windsys.c b/sys/windows/windsys.c index 91dc8eb40..40c788a0d 100644 --- a/sys/windows/windsys.c +++ b/sys/windows/windsys.c @@ -1252,6 +1252,18 @@ error: } #undef win32err +#ifdef MSWIN_GRAPHICS +int +get_approx_window_column_width(void) +{ + return GetSystemMetrics(SM_CXSCREEN) / 8; +} +int +get_approx_window_rows(void) +{ + return GetSystemMetrics(SM_CYSCREEN) / 12; +} +#endif #include #define MAX_SYM_SIZE 100 diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index 5fcd726b9..dd733a156 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -768,8 +768,18 @@ curses_init_options(void) if (console_width != 0) iflags.wc2_term_cols = console_width; else -#endif iflags.wc2_term_cols = 110; +#else + int width = get_approx_window_column_width(); + + if (width > 220) + width = 220; + + if (width != 0) + iflags.wc2_term_cols = width; + else + iflags.wc2_term_cols = 110; +#endif } if (iflags.wc2_term_rows == 0) { #ifndef MSWIN_GRAPHICS @@ -778,8 +788,14 @@ curses_init_options(void) if (console_height != 0) iflags.wc2_term_rows = console_height; else -#endif iflags.wc2_term_rows = 32; +#else + int scrows = get_approx_window_rows(); + + if (scrows > 54) + scrows = 54; + iflags.wc2_term_rows = scrows ? scrows : 32; +#endif } resize_term(iflags.wc2_term_rows, iflags.wc2_term_cols); getmaxyx(base_term, term_rows, term_cols);