Package org.jline.terminal.impl
Class ExternalTerminal
java.lang.Object
org.jline.terminal.impl.AbstractTerminal
org.jline.terminal.impl.LineDisciplineTerminal
org.jline.terminal.impl.ExternalTerminal
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,TerminalExt,Terminal
Console implementation with embedded line disciplined.
This terminal is well-suited for supporting incoming external
connections, such as from the network (through telnet, ssh,
or any kind of protocol).
The terminal will start consuming the input in a separate thread
to generate interruption events.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jline.terminal.Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicBooleanprotected final Objectprotected final InputStreamprotected booleanprotected ThreadFields inherited from class org.jline.terminal.impl.LineDisciplineTerminal
attributes, masterOutput, size, skipNextLf, slaveInput, slaveInputPipe, slaveOutput, slaveReader, slaveWriterFields inherited from class org.jline.terminal.impl.AbstractTerminal
bools, encoding, handlers, ints, name, onClose, palette, status, strings, typeFields inherited from interface org.jline.terminal.Terminal
TYPE_DUMB, TYPE_DUMB_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionExternalTerminal(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding) ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused) ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this terminal supportsTerminal.pause()andTerminal.resume()calls.protected voiddoClose()getCursorPosition(IntConsumer discarded) Query the terminal to report the cursor position.Returns theTerminalProviderthat created this terminal ornullif the terminal was created with no provider.voidpause()Stop reading the input stream.voidpause(boolean wait) Stop reading the input stream and optionally wait for the underlying threads to finish.booleanpaused()Check whether the terminal is currently reading the input stream or not.voidpump()voidresume()Resume reading the input stream.Methods inherited from class org.jline.terminal.impl.LineDisciplineTerminal
doProcessInputByte, getAttributes, getSize, getSystemStream, input, output, processInputByte, processInputBytes, processInputBytes, processIOException, processOutputByte, raise, reader, setAttributes, setSize, writerMethods inherited from class org.jline.terminal.impl.AbstractTerminal
checkInterrupted, close, echo, echo, echoSignal, encoding, enterRawMode, flush, getBooleanCapability, getKind, getName, getNumericCapability, getPalette, getStatus, getStatus, getStringCapability, getType, handle, hasFocusSupport, hasMouseSupport, parseInfoCmp, puts, readMouseEvent, readMouseEvent, setOnClose, toString, trackFocus, trackMouseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jline.terminal.Terminal
getBufferSize, getHeight, getWidth
-
Field Details
-
closed
-
masterInput
-
lock
-
paused
protected boolean paused -
pumpThread
-
-
Constructor Details
-
ExternalTerminal
public ExternalTerminal(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding) throws IOException - Throws:
IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException - Throws:
IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused) throws IOException - Throws:
IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) throws IOException - Throws:
IOException
-
-
Method Details
-
doClose
- Overrides:
doClosein classLineDisciplineTerminal- Throws:
IOException
-
canPauseResume
public boolean canPauseResume()Description copied from interface:TerminalWhether this terminal supportsTerminal.pause()andTerminal.resume()calls.- Specified by:
canPauseResumein interfaceTerminal- Overrides:
canPauseResumein classAbstractTerminal- Returns:
- whether this terminal supports
Terminal.pause()andTerminal.resume()calls. - See Also:
-
pause
public void pause()Description copied from interface:TerminalStop reading the input stream.- Specified by:
pausein interfaceTerminal- Overrides:
pausein classAbstractTerminal- See Also:
-
pause
Description copied from interface:TerminalStop reading the input stream and optionally wait for the underlying threads to finish.- Specified by:
pausein interfaceTerminal- Overrides:
pausein classAbstractTerminal- Parameters:
wait-trueto wait until the terminal is actually paused- Throws:
InterruptedException- if the call has been interrupted
-
resume
public void resume()Description copied from interface:TerminalResume reading the input stream.- Specified by:
resumein interfaceTerminal- Overrides:
resumein classAbstractTerminal- See Also:
-
paused
public boolean paused()Description copied from interface:TerminalCheck whether the terminal is currently reading the input stream or not. In order to process signal as quickly as possible, the terminal need to read the input stream and buffer it internally so that it can detect specific characters in the input stream (Ctrl+C, Ctrl+D, etc...) and raise the appropriate signals. However, there are some cases where this processing should be disabled, for example when handing the terminal control to a subprocess.- Specified by:
pausedin interfaceTerminal- Overrides:
pausedin classAbstractTerminal- Returns:
- whether the terminal is currently reading the input stream or not
- See Also:
-
pump
public void pump() -
getCursorPosition
Description copied from interface:TerminalQuery the terminal to report the cursor position. As the response is read from the input stream, some characters may be read before the cursor position is actually read. Those characters can be given back usingorg.jline.keymap.BindingReader#runMacro(String)- Specified by:
getCursorPositionin interfaceTerminal- Overrides:
getCursorPositionin classAbstractTerminal- Parameters:
discarded- a consumer receiving discarded characters- Returns:
nullif cursor position reporting is not supported or a valid cursor position
-
getProvider
Description copied from interface:TerminalExtReturns theTerminalProviderthat created this terminal ornullif the terminal was created with no provider.- Specified by:
getProviderin interfaceTerminalExt- Overrides:
getProviderin classLineDisciplineTerminal
-