summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-11-17 16:53:45 -0800
committerKaz Kylheku <kaz@kylheku.com>2020-10-11 11:34:02 -0700
commit34da597c54715d1baa1768a7a4a9095119271efa (patch)
tree320b9d1983df40cde0866b58df93b04275ce13f1
parent972345ffe1d326e71be9289532bae6725cb2945c (diff)
downloadcygnal-34da597c54715d1baa1768a7a4a9095119271efa.tar.gz
cygnal-34da597c54715d1baa1768a7a4a9095119271efa.tar.bz2
cygnal-34da597c54715d1baa1768a7a4a9095119271efa.zip
Revert "Fix console clear screen if buffer is full"
This reverts commit 99a3f266c15af5bbb9a8cacda63ce11b094c10d1. Unfortunately Corinna's August 3, 2016 is unsatisfactory, and interferes with our patch for the issue cherry picked from cygnal-2.5.2 into cygnal-2.9.0-branch. When the screen-clearing escape sequence ESC[2J is issued material below the cursor is not cleared properly. For instance, in the TXR Lisp listener, the Ctrl-L command fails to clear the screen at all, because it first homes the cursor to the top line of the screen and then issues the clear screen.
-rw-r--r--winsup/cygwin/fhandler_console.cc41
1 files changed, 16 insertions, 25 deletions
diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc
index 44eca2087..e8b2f61bf 100644
--- a/winsup/cygwin/fhandler_console.cc
+++ b/winsup/cygwin/fhandler_console.cc
@@ -1601,47 +1601,38 @@ dev_console::scroll_window (HANDLE h, int x1, int y1, int x2, int y2)
would move us beyond the buffer. What we do here is to scroll the
console buffer upward by just as much so that the current last line
becomes the last line just prior to the first window line. That
- keeps the end of the console buffer intact, as desired. */
+ keeps the end of the console buffer intact, as desired.
+
+ Since we're moving the console buffer under the console window in
+ this case, we must not move the console window. */
SMALL_RECT br;
COORD dest;
CHAR_INFO fill;
br.Left = 0;
- br.Top = (b.srWindow.Bottom - b.srWindow.Top) + 1
- - (b.dwSize.Y - dwEnd.Y - 1);
+ br.Top = dwEnd.Y - b.srWindow.Top + 1;
br.Right = b.dwSize.X - 1;
br.Bottom = b.dwSize.Y - 1;
dest.X = dest.Y = 0;
fill.Char.UnicodeChar = L' ';
fill.Attributes = current_win32_attr;
- ScrollConsoleScreenBufferW (h, &br, NULL, dest, &fill);
- /* Since we're moving the console buffer under the console window
- we only have to move the console window if the user scrolled the
- window upwards. The number of lines is the distance to the
- buffer bottom. */
- toscroll = b.dwSize.Y - b.srWindow.Bottom - 1;
- /* Fix dwEnd to reflect the new cursor line. Take the above scrolling
- into account and subtract 1 to account for the increment below. */
- dwEnd.Y = b.dwCursorPosition.Y + toscroll - 1;
- }
- if (toscroll)
- {
- /* FIXME: For some reason SetConsoleWindowInfo does not correctly
- set the scrollbars. Calling SetConsoleCursorPosition here is
- just a workaround which doesn't cover all cases. In some scenarios
- the scrollbars are still off by one console window size. */
-
+ ScrollConsoleScreenBuffer (h, &br, NULL, dest, &fill);
+ /* Fix dwEnd to reflect the new cursor line (minus 1 to take the
+ increment a few lines later into account) */
+ dwEnd.Y = b.dwCursorPosition.Y - 1;
+ }
+ else
+ {
/* The reminder of the console buffer is big enough to simply move
the console window. We have to set the cursor first, otherwise
the scroll bars will not be corrected. */
SetConsoleCursorPosition (h, dwEnd);
- /* If the user scolled manually, setting the cursor position might scroll
- the console window so that the cursor is not at the top. Correct
+ /* If we scroll backwards, setting the cursor position will scroll
+ the console window up so that the cursor is at the bottom. Correct
the action by moving the window down again so the cursor is one line
above the new window position. */
- GetConsoleScreenBufferInfo (h, &b);
- if (b.dwCursorPosition.Y >= b.srWindow.Top)
- toscroll = b.dwCursorPosition.Y - b.srWindow.Top + 1;
+ if (toscroll < 0)
+ toscroll = b.srWindow.Bottom - b.srWindow.Top;
/* Move the window accordingly. */
sr.Top = sr.Bottom = toscroll;
SetConsoleWindowInfo (h, FALSE, &sr);