Skip to content

Commit

Permalink
Windows CMD, redirecting input using JLine with Jansi fails, fixes #597
Browse files Browse the repository at this point in the history
  • Loading branch information
mattirn committed Nov 5, 2020
1 parent 3f399ac commit 1d7fb07
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ public static JansiWinSysTerminal createTerminal(String name, String type, boole
}
writer = new JansiWinConsoleWriter();
} else {
long console = GetStdHandle(STD_OUTPUT_HANDLE);
long consoleOut = GetStdHandle(STD_OUTPUT_HANDLE);
long consoleIn = GetStdHandle(STD_INPUT_HANDLE);
int[] mode = new int[1];
if (Kernel32.GetConsoleMode(console, mode) == 0) {
if (Kernel32.GetConsoleMode(consoleOut, mode) == 0
|| Kernel32.GetConsoleMode(consoleIn, mode) == 0) {
throw new IOException("Failed to get console mode: " + getLastErrorMessage());
}
if (Kernel32.SetConsoleMode(console, mode[0] | AbstractWindowsTerminal.ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0) {
if (Kernel32.SetConsoleMode(consoleOut, mode[0] | AbstractWindowsTerminal.ENABLE_VIRTUAL_TERMINAL_PROCESSING) != 0) {
if (type == null) {
type = TYPE_WINDOWS_VTP;
}
Expand Down

0 comments on commit 1d7fb07

Please sign in to comment.