mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 08:44:52 +02:00
fixed the console scroll down issue
https://github.com/PowerShell/Win32-OpenSSH/issues/585
This commit is contained in:
parent
b5b05a5eac
commit
dd8cfb0e06
@ -140,7 +140,7 @@ ConEnterRawMode(DWORD OutputHandle, BOOL fSmartInit)
|
|||||||
SavedViewRect = csbi.srWindow;
|
SavedViewRect = csbi.srWindow;
|
||||||
debug("console doesn't support the ansi parsing");
|
debug("console doesn't support the ansi parsing");
|
||||||
} else {
|
} else {
|
||||||
ConMoveCurosorTop(csbi);
|
ConMoveCursorTop(csbi);
|
||||||
debug("console supports the ansi parsing");
|
debug("console supports the ansi parsing");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1075,16 +1075,27 @@ ConScrollUp(int topline, int botline)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ConMoveVisibleWindow(int offset)
|
ConMoveVisibleWindow(int offset)
|
||||||
{
|
{
|
||||||
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
|
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
|
||||||
SMALL_RECT visibleWindowRect;
|
SMALL_RECT visibleWindowRect;
|
||||||
|
|
||||||
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
|
if (GetConsoleScreenBufferInfo(hOutputConsole, &consoleInfo)) {
|
||||||
memcpy(&visibleWindowRect, &consoleInfo.srWindow, sizeof(visibleWindowRect));
|
/* Check if applying the offset results in console buffer overflow.
|
||||||
visibleWindowRect.Top += offset;
|
* if yes, then scrolldown the console buffer.
|
||||||
visibleWindowRect.Bottom += offset;
|
*/
|
||||||
|
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);
|
SetConsoleWindowInfo(hOutputConsole, TRUE, &visibleWindowRect);
|
||||||
}
|
}
|
||||||
@ -1552,8 +1563,12 @@ ConSaveWindowsState()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
int offset = csbi.dwCursorPosition.Y - csbi.srWindow.Top;
|
||||||
ConMoveVisibleWindow(offset);
|
ConMoveVisibleWindow(offset);
|
||||||
|
|
||||||
|
@ -137,5 +137,5 @@ void ConSaveWindowsState();
|
|||||||
void ConMoveVisibleWindow(int offset);
|
void ConMoveVisibleWindow(int offset);
|
||||||
int is_cursor_at_lastline_of_visible_window();
|
int is_cursor_at_lastline_of_visible_window();
|
||||||
void ConGetCursorPosition(int *x, int *y);
|
void ConGetCursorPosition(int *x, int *y);
|
||||||
void ConMoveCurosorTop(CONSOLE_SCREEN_BUFFER_INFO csbi);
|
void ConMoveCursorTop(CONSOLE_SCREEN_BUFFER_INFO csbi);
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user