fixed the console scroll down issue

https://github.com/PowerShell/Win32-OpenSSH/issues/585
This commit is contained in:
bagajjal 2017-03-25 00:07:30 -07:00 committed by Manoj Ampalam
parent b5b05a5eac
commit dd8cfb0e06
2 changed files with 22 additions and 7 deletions

View File

@ -140,7 +140,7 @@ ConEnterRawMode(DWORD OutputHandle, BOOL fSmartInit)
SavedViewRect = csbi.srWindow;
debug("console doesn't support the ansi parsing");
} else {
ConMoveCurosorTop(csbi);
ConMoveCursorTop(csbi);
debug("console supports the ansi parsing");
}
@ -1082,9 +1082,20 @@ ConMoveVisibleWindow(int offset)
SMALL_RECT visibleWindowRect;
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
memcpy(&visibleWindowRect, &consoleInfo.srWindow, sizeof(visibleWindowRect));
visibleWindowRect.Top += offset;
visibleWindowRect.Bottom += offset;
/* Check if applying the offset results in console buffer overflow.
* if yes, then scrolldown the console buffer.
*/
if ((consoleInfo.srWindow.Bottom + offset) >= (consoleInfo.dwSize.Y - 1)) {
for (int i = 0; i < offset; i++)
ConScrollDown(0, consoleInfo.dwSize.Y - 1);
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo))
memcpy(&visibleWindowRect, &consoleInfo.srWindow, sizeof(visibleWindowRect));
} else {
memcpy(&visibleWindowRect, &consoleInfo.srWindow, sizeof(visibleWindowRect));
visibleWindowRect.Top += offset;
visibleWindowRect.Bottom += offset;
}
SetConsoleWindowInfo(hOutputConsole, TRUE, &visibleWindowRect);
}
@ -1552,8 +1563,12 @@ ConSaveWindowsState()
}
void
ConMoveCurosorTop(CONSOLE_SCREEN_BUFFER_INFO csbi)
ConMoveCursorTop(CONSOLE_SCREEN_BUFFER_INFO csbi)
{
/* Windows server at first sends the "cls" after the connection is established.
* Since we don't want to loose any data on the console, we would like to scroll down
* the visible window.
*/
int offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
ConMoveVisibleWindow(offset);

View File

@ -137,5 +137,5 @@ void ConSaveWindowsState();
void ConMoveVisibleWindow(int offset);
int is_cursor_at_lastline_of_visible_window();
void ConGetCursorPosition(int *x, int *y);
void ConMoveCurosorTop(CONSOLE_SCREEN_BUFFER_INFO csbi);
void ConMoveCursorTop(CONSOLE_SCREEN_BUFFER_INFO csbi);
#endif