8171386: jshell tool: paging of javadoc output broken on Windows
Summary: Fixing detection of console window size.
Reviewed-by: rfield
--- a/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp Mon Jan 16 15:16:10 2017 +0800
+++ b/jdk/src/jdk.internal.le/windows/native/lible/WindowsTerminal.cpp Mon Jan 16 09:53:34 2017 +0100
@@ -102,26 +102,26 @@
JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalWidth
(JNIEnv *, jobject) {
- HANDLE hStdIn;
- if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
+ HANDLE hStdOut;
+ if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
return -1;
}
CONSOLE_SCREEN_BUFFER_INFO info;
- if (! GetConsoleScreenBufferInfo(hStdIn, &info)) {
+ if (! GetConsoleScreenBufferInfo(hStdOut, &info)) {
return -1;
}
- return info.dwSize.X;
+ return info.srWindow.Right - info.srWindow.Left;
}
JNIEXPORT jint JNICALL Java_jdk_internal_jline_WindowsTerminal_getWindowsTerminalHeight
(JNIEnv *, jobject) {
- HANDLE hStdIn;
- if ((hStdIn = GetStdHandle(STD_INPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
+ HANDLE hStdOut;
+ if ((hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)) == INVALID_HANDLE_VALUE) {
return -1;
}
CONSOLE_SCREEN_BUFFER_INFO info;
- if (! GetConsoleScreenBufferInfo(hStdIn, &info)) {
+ if (! GetConsoleScreenBufferInfo(hStdOut, &info)) {
return -1;
}
- return info.dwSize.Y;
+ return info.srWindow.Bottom - info.srWindow.Top + 1;
}