/** * Returns an ansi output stream handler. We return whatever was * passed if we determine we cannot handle ansi based on Kernel32 calls. * * @return an @{link AltWindowAnsiOutputStream} instance or the passed * stream. */ private static OutputStream wrapOutputStream(final OutputStream stream) { if (Configuration.isWindows()) { // On windows we know the console does not interpret ANSI codes.. try { return new WindowsAnsiOutputStream(stream); } catch (Throwable ignore) { // this happens when JNA is not in the path.. or // this happens when the stdout is being redirected to a file. } // Use the ANSIOutputStream to strip out the ANSI escape sequences. return new AnsiOutputStream(stream); } return stream; }
public static String stripAnsi(String str) { if (str == null) return ""; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); AnsiOutputStream aos = new AnsiOutputStream(baos); aos.write(str.getBytes()); aos.close(); return baos.toString(); } catch (IOException e) { return str; } }
private CharSequence chew(final CharSequence str) { assert str != null; ByteArrayOutputStream buff = new ByteArrayOutputStream(); AnsiOutputStream out = new AnsiOutputStream(buff); try { out.write(str.toString().getBytes()); out.flush(); out.close(); } catch (IOException e) { throw new RuntimeException(e); } return new String(buff.toByteArray()); }
private String stripAnsi(String str) { if (str == null) return ""; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); AnsiOutputStream aos = new AnsiOutputStream(baos); aos.write(str.getBytes()); aos.flush(); return baos.toString(); } catch (IOException e) { return str; } }
public void write(int data) throws IOException { switch(data) { case 34: // " out.write(BYTES_QUOT); break; case 38: // & out.write(BYTES_AMP); break; case 60: // < out.write(BYTES_LT); break; case 62: // > out.write(BYTES_GT); break; default: super.write(data); } }
@Override public void close() throws IOException { closeAttributes(); super.close(); }
private String stripAnsi(final String str) { if (str == null) return ""; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); AnsiOutputStream aos = new AnsiOutputStream(baos); aos.write(str.getBytes()); aos.flush(); aos.close(); return baos.toString(); } catch (IOException e) { return str; } }
public void write(int data) throws IOException { switch (data) { case 34: // " out.write(BYTES_QUOT); break; case 38: // & out.write(BYTES_AMP); break; case 60: // < out.write(BYTES_LT); break; case 62: // > out.write(BYTES_GT); break; default: super.write(data); } }
@Override public void close() throws IOException { closeAttributes(); super.close(); }
private FilterOutputStream basicOutput(PrintStream stream) { return new AnsiOutputStream(stream); }
public static String stripAnsi(String str) { if (str == null) return ""; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); AnsiOutputStream aos = new AnsiOutputStream(baos); aos.write(str.getBytes()); aos.close(); return baos.toString(); } catch (IOException e) { return str; } }
@Override public void init(InputStream inputStream, OutputStream stdOut, OutputStream stdErr) { if(inputStream == System.in) { System.out.println("Using System.in"); } //setting up reader try { //AnsiConsole.systemInstall(); this.stdOut = new PrintWriter( new OutputStreamWriter(new WindowsAnsiOutputStream(stdOut))); this.stdErr = new PrintWriter( new OutputStreamWriter(new WindowsAnsiOutputStream(stdErr))); } catch (Exception ioe) { this.stdOut = new PrintWriter( new OutputStreamWriter(new AnsiOutputStream(stdOut))); this.stdErr = new PrintWriter( new OutputStreamWriter(new AnsiOutputStream(stdErr))); } this.input = inputStream; }
/** * Returns an ansi output stream handler. We return whatever was * passed if we determine we cannot handle ansi based on Kernel32 calls. * * @return an @{link AltWindowAnsiOutputStream} instance or the passed * stream. */ private static OutputStream wrapOutputStream(final OutputStream stream) { String os = System.getProperty("os.name"); if( os.startsWith("Windows") ) { // On windows we know the console does not interpret ANSI codes.. try { return new WindowsAnsiOutputStream(stream); } catch (Throwable ignore) { // this happens when JNA is not in the path.. or // this happens when the stdout is being redirected to a file. } // Use the ANSIOutputStream to strip out the ANSI escape sequences. return new AnsiOutputStream(stream); } return stream; }
return new AnsiOutputStream(stream); return new AnsiOutputStream(stream); return new AnsiOutputStream(stream);
return new AnsiOutputStream( stream ); return new AnsiOutputStream( stream );
/** * Returns an ansi output stream handler. We return whatever was * passed if we determine we cannot handle ansi based on Kernel32 calls. * * @return an @{link AltWindowAnsiOutputStream} instance or the passed * stream. */ private static OutputStream wrapOutputStream(final OutputStream stream) { if (Configuration.isWindows()) { // On windows we know the console does not interpret ANSI codes.. try { return new WindowsAnsiOutputStream(stream); } catch (Throwable ignore) { // this happens when JNA is not in the path.. or // this happens when the stdout is being redirected to a file. } // Use the ANSIOutputStream to strip out the ANSI escape sequences. return new AnsiOutputStream(stream); } return stream; }
public int run(String tool, String[] args, File workingDir, Map<String, String> env) { ThreadLocalPrintStream system_out = (ThreadLocalPrintStream) System.out; ThreadLocalPrintStream system_err = (ThreadLocalPrintStream) System.err; Injector injector; lock.readLock().lock(); try { injector = injectors.get(tool); } finally { lock.readLock().unlock(); } Main launcher = injector.getInstance(Main.class); SimpleScope requestScope = launcher.getRequestScope(); try { requestScope.enter(); Main.seedInjector(requestScope, tool, args, workingDir, env); TTYInfo tty = injector.getInstance(TTYInfo.class); if (!tty.stdout) { system_out.init(new PrintStream(new AnsiOutputStream(system_out.getPrintStream()))); } if (!tty.stderr) { system_err.init(new PrintStream(new AnsiOutputStream(system_err.getPrintStream()))); } int result = launcher.runApplication(); System.out.flush(); System.err.flush(); return result; } finally { requestScope.exit(); } }
return new AnsiOutputStream(stream); return new AnsiOutputStream(stream); return new AnsiOutputStream(stream);