diff options
Diffstat (limited to 'winsup/cygwin/fhandler_console.cc')
-rw-r--r-- | winsup/cygwin/fhandler_console.cc | 52 |
1 files changed, 22 insertions, 30 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 5fe448051..380aeecf5 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1209,38 +1209,11 @@ dev_console::set_cl_y (cltype y) } bool -dev_console::scroll_window (HANDLE h, int x1, int y1, int x2, int y2) +dev_console::clear_should_scroll (HANDLE h, int x1, int y1, int x2, int y2) { if (save_buf || x1 != 0 || x2 != dwWinSize.X - 1 || y1 != b.srWindow.Top || y2 != b.srWindow.Bottom || b.dwSize.Y <= dwWinSize.Y) return false; - - SMALL_RECT sr; - int toscroll = 2 + dwEnd.Y - b.srWindow.Top; - int shrink = 1 + toscroll + b.srWindow.Bottom - b.dwSize.Y; - sr.Left = sr.Right = dwEnd.X = 0; - /* Can't increment dwEnd yet since we may not have space in - the buffer. */ - SetConsoleCursorPosition (h, dwEnd); - if (shrink > 0) - { - COORD c = b.dwSize; - c.Y = dwEnd.Y - shrink; - SetConsoleScreenBufferSize (h, c); - SetConsoleScreenBufferSize (h, b.dwSize); - dwEnd.Y = 0; - fillin (h); - toscroll = 2 + dwEnd.Y - b.srWindow.Top; - } - - sr.Top = sr.Bottom = toscroll; - - SetConsoleWindowInfo (h, FALSE, &sr); - - dwEnd.Y++; - SetConsoleCursorPosition (h, dwEnd); - - fillin (h); return true; } @@ -1261,8 +1234,27 @@ fhandler_console::clear_screen (cltype xc1, cltype yc1, cltype xc2, cltype yc2) /* Detect special case - scroll the screen if we have a buffer in order to preserve the buffer. */ - if (!con.scroll_window (h, x1, y1, x2, y2)) - con.clear_screen (h, x1, y1, x2, y2); + if (!con.clear_should_scroll (h, x1, y1, x2, y2)) + { + con.clear_screen (h, x1, y1, x2, y2); + return; + } + + int xpos, ypos; + DWORD done; + cursor_get(&xpos, &ypos); + cursor_set(false, 0, con.b.dwSize.Y - 1); + + for (int i = 0; i < con.dwWinSize.Y; i += done) + { + if (!WriteConsoleW (h, L"\n", 1, &done, 0)) + { + __seterrno (); + break; + } + } + + cursor_set(false, xpos, ypos); } void __reg3 |