private ConsoleReader createAnsiWindowsReader() throws Exception { // Get decorated OutputStream that parses ANSI-codes final PrintStream ansiOut = (PrintStream) ClassUtils .getClass(JLineShell.class.getClassLoader(), ANSI_CONSOLE_CLASSNAME).getMethod("out") .invoke(null); final WindowsTerminal ansiTerminal = new WindowsTerminal() { @Override public boolean isANSISupported() { return true; } }; ansiTerminal.initializeTerminal(); // Make sure to reset the original shell's colors on shutdown by closing // the stream statusListener = new ShellStatusListener() { public void onShellStatusChange(final ShellStatus oldStatus, final ShellStatus newStatus) { if (newStatus.getStatus().equals(Status.SHUTTING_DOWN)) { ansiOut.close(); } } }; addShellStatusListener(statusListener); return new ConsoleReader(new FileInputStream(FileDescriptor.in), new PrintWriter( new OutputStreamWriter(ansiOut, // Default to Cp850 encoding for Windows console output // (ROO-439) System.getProperty("jline.WindowsTerminal.output.encoding", "Cp850"))), null, ansiTerminal); }
private ConsoleReader createAnsiWindowsReader() throws Exception { // Get decorated OutputStream that parses ANSI-codes final PrintStream ansiOut = (PrintStream) ClassUtils .getClass(JLineShell.class.getClassLoader(), ANSI_CONSOLE_CLASSNAME).getMethod("out") .invoke(null); final WindowsTerminal ansiTerminal = new WindowsTerminal() { @Override public boolean isANSISupported() { return true; } }; ansiTerminal.initializeTerminal(); // Make sure to reset the original shell's colors on shutdown by closing // the stream statusListener = new ShellStatusListener() { public void onShellStatusChange(final ShellStatus oldStatus, final ShellStatus newStatus) { if (newStatus.getStatus().equals(Status.SHUTTING_DOWN)) { ansiOut.close(); } } }; addShellStatusListener(statusListener); return new ConsoleReader(new FileInputStream(FileDescriptor.in), new PrintWriter( new OutputStreamWriter(ansiOut, // Default to Cp850 encoding for Windows console output // (ROO-439) System.getProperty("jline.WindowsTerminal.output.encoding", "Cp850"))), null, ansiTerminal); }