|
29 | 29 | import static org.fusesource.jansi.internal.Kernel32.GetConsoleScreenBufferInfo;
|
30 | 30 | import static org.fusesource.jansi.internal.Kernel32.GetStdHandle;
|
31 | 31 | import static org.fusesource.jansi.internal.Kernel32.SMALL_RECT;
|
| 32 | +import static org.fusesource.jansi.internal.Kernel32.STD_ERROR_HANDLE; |
32 | 33 | import static org.fusesource.jansi.internal.Kernel32.STD_OUTPUT_HANDLE;
|
33 | 34 | import static org.fusesource.jansi.internal.Kernel32.ScrollConsoleScreenBuffer;
|
34 | 35 | import static org.fusesource.jansi.internal.Kernel32.SetConsoleCursorPosition;
|
|
54 | 55 | */
|
55 | 56 | public final class WindowsAnsiOutputStream extends AnsiOutputStream { // expected diff with WindowsAnsiPrintStream.java
|
56 | 57 |
|
57 |
| - private static final long console = GetStdHandle(STD_OUTPUT_HANDLE); |
| 58 | + private static final long stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); |
| 59 | + private static final long stderr_handle = GetStdHandle(STD_ERROR_HANDLE); |
| 60 | + private final long console; |
58 | 61 |
|
59 | 62 | private static final short FOREGROUND_BLACK = 0;
|
60 | 63 | private static final short FOREGROUND_YELLOW = (short) (FOREGROUND_RED | FOREGROUND_GREEN);
|
@@ -97,12 +100,17 @@ public final class WindowsAnsiOutputStream extends AnsiOutputStream { // expecte
|
97 | 100 | private short savedX = -1;
|
98 | 101 | private short savedY = -1;
|
99 | 102 |
|
100 |
| - public WindowsAnsiOutputStream(OutputStream os) throws IOException { // expected diff with WindowsAnsiPrintStream.java |
| 103 | + public WindowsAnsiOutputStream(OutputStream os, boolean stdout) throws IOException { // expected diff with WindowsAnsiPrintStream.java |
101 | 104 | super(os); // expected diff with WindowsAnsiPrintStream.java
|
| 105 | + this.console = stdout ? stdout_handle : stderr_handle; |
102 | 106 | getConsoleInfo();
|
103 | 107 | originalColors = info.attributes;
|
104 | 108 | }
|
105 | 109 |
|
| 110 | + public WindowsAnsiOutputStream(OutputStream os) throws IOException { // expected diff with WindowsAnsiPrintStream.java |
| 111 | + this(os, true); // expected diff with WindowsAnsiPrintStream.java |
| 112 | + } |
| 113 | + |
106 | 114 | private void getConsoleInfo() throws IOException {
|
107 | 115 | out.flush(); // expected diff with WindowsAnsiPrintStream.java
|
108 | 116 | if (GetConsoleScreenBufferInfo(console, info) == 0) {
|
|
0 commit comments