From 1db2fafb1173038586cbb3d6673e1549a681c3fe Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 3 Aug 2016 15:50:00 +0100 Subject: stty: adjust console buffer when console size changes The console buffer width is made to match the console width; the buffer height must always be greater than or equal to the number of rows in the console. --- win32/winansi.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'win32/winansi.c') diff --git a/win32/winansi.c b/win32/winansi.c index 757a3509d..aafd866a1 100644 --- a/win32/winansi.c +++ b/win32/winansi.c @@ -605,6 +605,12 @@ int winansi_set_terminal_width_height(struct winsize *win) sbi.cbSize = sizeof(sbi); if ((ret=GetConsoleScreenBufferInfoEx(console, &sbi)) != 0) { + if (sbi.dwSize.X != win->ws_col) { + sbi.dwSize.X = win->ws_col; + } + if (sbi.dwSize.Y < win->ws_row) { + sbi.dwSize.Y = win->ws_row; + } sbi.srWindow.Bottom = sbi.srWindow.Top + win->ws_row; sbi.srWindow.Right = sbi.srWindow.Left + win->ws_col; ret = SetConsoleScreenBufferInfoEx(console, &sbi); -- cgit v1.2.3-55-g6feb