mirror of
https://github.com/VARCem/PDCurses.git
synced 2026-09-23 15:25:01 +00:00
Improved Windows console resizing, when reducing the vertical size.
After Ulf Magnusson. (See GitHub issue #26.)
This commit is contained in:
@@ -525,34 +525,43 @@ int PDC_resize_screen(int nlines, int ncols)
|
||||
SMALL_RECT rect;
|
||||
COORD size, max;
|
||||
|
||||
if (nlines || ncols)
|
||||
bool prog_resize = nlines || ncols;
|
||||
|
||||
if (!prog_resize)
|
||||
{
|
||||
if (nlines < 2 || ncols < 2)
|
||||
return ERR;
|
||||
|
||||
max = GetLargestConsoleWindowSize(pdc_con_out);
|
||||
|
||||
rect.Left = rect.Top = 0;
|
||||
rect.Right = ncols - 1;
|
||||
|
||||
if (rect.Right > max.X)
|
||||
rect.Right = max.X;
|
||||
|
||||
rect.Bottom = nlines - 1;
|
||||
|
||||
if (rect.Bottom > max.Y)
|
||||
rect.Bottom = max.Y;
|
||||
|
||||
size.X = rect.Right + 1;
|
||||
size.Y = rect.Bottom + 1;
|
||||
|
||||
_fit_console_window(pdc_con_out, &rect);
|
||||
SetConsoleScreenBufferSize(pdc_con_out, size);
|
||||
_fit_console_window(pdc_con_out, &rect);
|
||||
SetConsoleScreenBufferSize(pdc_con_out, size);
|
||||
SetConsoleActiveScreenBuffer(pdc_con_out);
|
||||
nlines = PDC_get_rows();
|
||||
ncols = PDC_get_columns();
|
||||
}
|
||||
|
||||
if (nlines < 2 || ncols < 2)
|
||||
return ERR;
|
||||
|
||||
max = GetLargestConsoleWindowSize(pdc_con_out);
|
||||
|
||||
rect.Left = rect.Top = 0;
|
||||
rect.Right = ncols - 1;
|
||||
|
||||
if (rect.Right > max.X)
|
||||
rect.Right = max.X;
|
||||
|
||||
rect.Bottom = nlines - 1;
|
||||
|
||||
if (rect.Bottom > max.Y)
|
||||
rect.Bottom = max.Y;
|
||||
|
||||
size.X = rect.Right + 1;
|
||||
size.Y = rect.Bottom + 1;
|
||||
|
||||
_fit_console_window(pdc_con_out, &rect);
|
||||
SetConsoleScreenBufferSize(pdc_con_out, size);
|
||||
|
||||
if (prog_resize)
|
||||
{
|
||||
_fit_console_window(pdc_con_out, &rect);
|
||||
SetConsoleScreenBufferSize(pdc_con_out, size);
|
||||
}
|
||||
SetConsoleActiveScreenBuffer(pdc_con_out);
|
||||
|
||||
PDC_flushinp();
|
||||
|
||||
SP->resized = FALSE;
|
||||
|
||||
Reference in New Issue
Block a user