private void insertClose(String s) throws IOException { putString(s); int closePosition = buf.cursor; moveCursor(-1); viMatch(); if (in.isNonBlockingEnabled()) { in.peek(parenBlinkTimeout); } setCursorPosition(closePosition); flush(); }
void setInput(final InputStream in) throws IOException { this.escapeTimeout = Configuration.getLong(JLINE_ESC_TIMEOUT, 100); boolean nonBlockingEnabled = escapeTimeout > 0L && terminal.isSupported() && in != null; /* * If we had a non-blocking thread already going, then shut it down * and start a new one. */ if (this.in != null) { this.in.shutdown(); } final InputStream wrapped = terminal.wrapInIfNeeded( in ); this.in = new NonBlockingInputStream(wrapped, nonBlockingEnabled); this.reader = new InputStreamReader( this.in, encoding ); }
@Override public int read() throws IOException { if (nonBlockingEnabled) return read(0L, false); return in.read (); }
clearEcho(c); if (c == ESCAPE && checkForAltKeyCombo && in.peek(escapeTimeout) >= 32) {
/** * Shuts the console reader down. This method should be called when you * have completed using the reader as it shuts down and cleans up resources * that would otherwise be "leaked". */ @Override public void close() { if (in != null) { in.shutdown(); } }
clearEcho(c); if (c == ESCAPE && checkForAltKeyCombo && in.peek(escapeTimeout) >= 32) {
@Override public void close() throws IOException { /* * The underlying input stream is closed first. This means that if the * I/O thread was blocked waiting on input, it will be woken for us. */ in.close(); shutdown(); }
&& in.isNonBlockingEnabled() && in.peek(escapeTimeout) == READ_EXPIRED) { o = ((KeyMap) o).getAnotherKey(); if (o == null || o instanceof KeyMap) {
/** * Attempts to read a character from the input stream for a specific * period of time. * @param timeout The amount of time to wait for the character * @return The character read, -1 if EOF is reached, or -2 if the * read timed out. */ public int read(long timeout) throws IOException { if (!nonBlockingEnabled || isShutdown) { throw new UnsupportedOperationException ("read() with timeout " + "cannot be called as non-blocking operation is disabled"); } return read(timeout, false); }
void setInput(final InputStream in) throws IOException { this.escapeTimeout = Configuration.getLong(JLINE_ESC_TIMEOUT, 100); boolean nonBlockingEnabled = escapeTimeout > 0L && terminal.isSupported() && in != null; /* * If we had a non-blocking thread already going, then shut it down * and start a new one. */ if (this.in != null) { this.in.shutdown(); } final InputStream wrapped = terminal.wrapInIfNeeded( in ); this.in = new NonBlockingInputStream(wrapped, nonBlockingEnabled); this.reader = new InputStreamReader( this.in, encoding ); }
/** * Shuts the console reader down. This method should be called when you * have completed using the reader as it shuts down and cleans up resources * that would otherwise be "leaked". */ @Override public void close() { if (in != null) { in.shutdown(); } }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
/** * Peeks to see if there is a byte waiting in the input stream without * actually consuming the byte. * * @param timeout The amount of time to wait, 0 == forever * @return -1 on eof, -2 if the timeout expired with no available input * or the character that was read (without consuming it). */ public int peek(long timeout) throws IOException { if (!nonBlockingEnabled || isShutdown) { throw new UnsupportedOperationException ("peek() " + "cannot be called as non-blocking operation is disabled"); } return read(timeout, true); }
@Override public void close() throws IOException { /* * The underlying input stream is closed first. This means that if the * I/O thread was blocked waiting on input, it will be woken for us. */ in.close(); shutdown(); }
private void insertClose(String s) throws IOException { putString(s); int closePosition = buf.cursor; moveCursor(-1); viMatch(); if (in.isNonBlockingEnabled()) { in.peek(parenBlinkTimeout); } setCursorPosition(closePosition); flush(); }
/** * This version of read() is very specific to jline's purposes, it * will always always return a single byte at a time, rather than filling * the entire buffer. */ @Override public int read (byte[] b, int off, int len) throws IOException { if (b == null) { throw new NullPointerException(); } else if (off < 0 || len < 0 || len > b.length - off) { throw new IndexOutOfBoundsException(); } else if (len == 0) { return 0; } int c; if (nonBlockingEnabled) c = this.read(0L); else c = in.read(); if (c == -1) { return -1; } b[off] = (byte)c; return 1; }
&& in.isNonBlockingEnabled() && in.peek(escapeTimeout) == READ_EXPIRED) { o = ((KeyMap) o).getAnotherKey(); if (o == null || o instanceof KeyMap) {
/** * Attempts to read a character from the input stream for a specific * period of time. * @param timeout The amount of time to wait for the character * @return The character read, -1 if EOF is reached, or -2 if the * read timed out. */ public int read(long timeout) throws IOException { if (!nonBlockingEnabled || isShutdown) { throw new UnsupportedOperationException ("read() with timeout " + "cannot be called as non-blocking operation is disabled"); } return read(timeout, false); }
/** * Possible states in which the current readline operation may be in. */ private static enum State { /** * The user is just typing away */ NORMAL, /** * In the middle of a emacs seach */ SEARCH, FORWARD_SEARCH, /** * VI "yank-to" operation ("y" during move mode) */ VI_YANK_TO, /** * VI "delete-to" operation ("d" during move mode) */ VI_DELETE_TO, /** * VI "change-to" operation ("c" during move mode) */ VI_CHANGE_TO }
@Override public int read() throws IOException { if (nonBlockingEnabled) return read(0L, false); return in.read (); }