@Override public String getOutputEncoding() { int codepage = getConsoleOutputCodepage(); //http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html String charsetMS = "ms" + codepage; if (java.nio.charset.Charset.isSupported(charsetMS)) { return charsetMS; } String charsetCP = "cp" + codepage; if (java.nio.charset.Charset.isSupported(charsetCP)) { return charsetCP; } Log.debug("can't figure out the Java Charset of this code page (" + codepage + ")..."); return super.getOutputEncoding(); }
@Override public synchronized void setEchoEnabled(final boolean enabled) { try { if (enabled) { settings.set("echo"); } else { settings.set("-echo"); } super.setEchoEnabled(enabled); } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Log.error("Failed to ", enabled ? "enable" : "disable", " echo", e); } }
public void run() throws Exception { restore(); } });
@Override public void init() throws Exception { super.init(); if (stty != null) { sttyClass.getMethod("jlineMode").invoke(stty); } }
@Override public InputStream wrapInIfNeeded(InputStream in) throws IOException { if (directConsole && isSystemIn(in)) { return new InputStream() { private byte[] buf = null; int bufIdx = 0; @Override public int read() throws IOException { while (buf == null || bufIdx == buf.length) { buf = readConsoleInput(); bufIdx = 0; } int c = buf[bufIdx] & 0xFF; bufIdx++; return c; } }; } else { return super.wrapInIfNeeded(in); } }
@Override public void restore() throws Exception { if (stty != null) { sttyClass.getMethod("reset").invoke(stty); } super.restore(); // Newline in end of restore like in jline.UnixTerminal System.out.println(); }
/** * Remove line-buffered input by invoking "stty -icanon min 1" * against the current terminal. */ @Override public void init() throws Exception { super.init(); setAnsiSupported(true); // Set the console to be character-buffered instead of line-buffered. // Make sure we're distinguishing carriage return from newline. // Allow ctrl-s keypress to be used (as forward search) // // Please note that FreeBSD does not seem to support -icrnl and thus // has to be handled separately. Otherwise the console will be "stuck" // and will neither accept input nor print anything to stdout. if (Configuration.getOsName().contains(TerminalFactory.FREEBSD)) { settings.set("-icanon min 1 -inlcr -ixon"); } else { settings.set("-icanon min 1 -icrnl -inlcr -ixon"); } settings.undef("dsusp"); setEchoEnabled(false); parseInfoCmp(); }
@Override public InputStream wrapInIfNeeded(InputStream in) throws IOException { if (directConsole && isSystemIn(in)) { return new InputStream() { private byte[] buf = null; int bufIdx = 0; @Override public int read() throws IOException { while (buf == null || bufIdx == buf.length) { buf = readConsoleInput(); bufIdx = 0; } int c = buf[bufIdx] & 0xFF; bufIdx++; return c; } }; } else { return super.wrapInIfNeeded(in); } }
/** * Restore the original terminal configuration, which can be used when * shutting down the console reader. The ConsoleReader cannot be * used after calling this method. */ @Override public void restore() throws Exception { // restore the old console mode setConsoleMode(originalMode); super.restore(); }
@Override public void init() throws Exception { super.init(); setAnsiSupported(Configuration.getBoolean(ANSI, true)); // // FIXME: Need a way to disable direct console and sysin detection muck // setDirectConsole(Configuration.getBoolean(DIRECT_CONSOLE, true)); this.originalMode = getConsoleMode(); setConsoleMode(originalMode & ~ENABLE_ECHO_INPUT.code); setEchoEnabled(false); }
@Override public void setEchoEnabled(final boolean enabled) { // Must set these four modes at the same time to make it work fine. if (enabled) { setConsoleMode(getConsoleMode() | ENABLE_ECHO_INPUT.code | ENABLE_LINE_INPUT.code | ENABLE_WINDOW_INPUT.code); } else { setConsoleMode(getConsoleMode() & ~(ENABLE_LINE_INPUT.code | ENABLE_ECHO_INPUT.code | ENABLE_WINDOW_INPUT.code)); } super.setEchoEnabled(enabled); }
@Override public String getOutputEncoding() { int codepage = getConsoleOutputCodepage(); //http://docs.oracle.com/javase/6/docs/technotes/guides/intl/encoding.doc.html String charsetMS = "ms" + codepage; if (java.nio.charset.Charset.isSupported(charsetMS)) { return charsetMS; } String charsetCP = "cp" + codepage; if (java.nio.charset.Charset.isSupported(charsetCP)) { return charsetCP; } Log.debug("can't figure out the Java Charset of this code page (" + codepage + ")..."); return super.getOutputEncoding(); }
/** * Restore the original terminal configuration, which can be used when * shutting down the console reader. The ConsoleReader cannot be * used after calling this method. */ @Override public void restore() throws Exception { settings.restore(); super.restore(); }
@Override public void init() throws Exception { super.init(); if (stty != null) { sttyClass.getMethod("jlineMode").invoke(stty); } }
@Override public synchronized void setEchoEnabled(final boolean enabled) { try { if (enabled) { settings.set("echo"); } else { settings.set("-echo"); } super.setEchoEnabled(enabled); } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Log.error("Failed to ", enabled ? "enable" : "disable", " echo", e); } }
public void run() throws Exception { restore(); } });
@Override public void init() throws Exception { super.init(); setEchoEnabled(false); setAnsiSupported(true); // InfoCmp.parseInfoCmp(InfoCmp.getAnsiCaps(), bools, ints, strings); }
@Override public void setEchoEnabled(final boolean enabled) { // Must set these four modes at the same time to make it work fine. if (enabled) { setConsoleMode(getConsoleMode() | ENABLE_ECHO_INPUT.code | ENABLE_LINE_INPUT.code | ENABLE_WINDOW_INPUT.code); } else { setConsoleMode(getConsoleMode() & ~(ENABLE_LINE_INPUT.code | ENABLE_ECHO_INPUT.code | ENABLE_WINDOW_INPUT.code)); } super.setEchoEnabled(enabled); }