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:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,TerminalExt
,Terminal
public class ExternalTerminal extends LineDisciplineTerminal
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:
LineDisciplineTerminal
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jline.terminal.Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicBoolean
closed
protected java.lang.Object
lock
protected java.io.InputStream
masterInput
protected boolean
paused
protected java.lang.Thread
pumpThread
-
Fields inherited from class org.jline.terminal.impl.LineDisciplineTerminal
attributes, masterOutput, size, skipNextLf, slaveInput, slaveInputPipe, slaveOutput, slaveReader, slaveWriter
-
Fields inherited from class org.jline.terminal.impl.AbstractTerminal
bools, encoding, handlers, ints, name, onClose, palette, status, strings, type
-
Fields inherited from interface org.jline.terminal.Terminal
TYPE_DUMB, TYPE_DUMB_COLOR
-
-
Constructor Summary
Constructors Constructor Description ExternalTerminal(java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding)
ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler)
ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused)
ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canPauseResume()
Whether this terminal supportsTerminal.pause()
andTerminal.resume()
calls.protected void
doClose()
Cursor
getCursorPosition(java.util.function.IntConsumer discarded)
Query the terminal to report the cursor position.TerminalProvider
getProvider()
Returns theTerminalProvider
that created this terminal ornull
if the terminal was created with no provider.void
pause()
Stop reading the input stream.void
pause(boolean wait)
Stop reading the input stream and optionally wait for the underlying threads to finish.boolean
paused()
Check whether the terminal is currently reading the input stream or not.void
pump()
void
resume()
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, writer
-
Methods 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, trackMouse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jline.terminal.Terminal
getBufferSize, getHeight, getWidth
-
-
-
-
Constructor Detail
-
ExternalTerminal
public ExternalTerminal(java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler) throws java.io.IOException
- Throws:
java.io.IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused) throws java.io.IOException
- Throws:
java.io.IOException
-
ExternalTerminal
public ExternalTerminal(TerminalProvider provider, java.lang.String name, java.lang.String type, java.io.InputStream masterInput, java.io.OutputStream masterOutput, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
doClose
protected void doClose() throws java.io.IOException
- Overrides:
doClose
in classLineDisciplineTerminal
- Throws:
java.io.IOException
-
canPauseResume
public boolean canPauseResume()
Description copied from interface:Terminal
Whether this terminal supportsTerminal.pause()
andTerminal.resume()
calls.- Specified by:
canPauseResume
in interfaceTerminal
- Overrides:
canPauseResume
in classAbstractTerminal
- Returns:
- whether this terminal supports
Terminal.pause()
andTerminal.resume()
calls. - See Also:
Terminal.paused()
,Terminal.pause()
,Terminal.resume()
-
pause
public void pause()
Description copied from interface:Terminal
Stop reading the input stream.- Specified by:
pause
in interfaceTerminal
- Overrides:
pause
in classAbstractTerminal
- See Also:
Terminal.resume()
,Terminal.paused()
-
pause
public void pause(boolean wait) throws java.lang.InterruptedException
Description copied from interface:Terminal
Stop reading the input stream and optionally wait for the underlying threads to finish.- Specified by:
pause
in interfaceTerminal
- Overrides:
pause
in classAbstractTerminal
- Parameters:
wait
-true
to wait until the terminal is actually paused- Throws:
java.lang.InterruptedException
- if the call has been interrupted
-
resume
public void resume()
Description copied from interface:Terminal
Resume reading the input stream.- Specified by:
resume
in interfaceTerminal
- Overrides:
resume
in classAbstractTerminal
- See Also:
Terminal.pause()
,Terminal.paused()
-
paused
public boolean paused()
Description copied from interface:Terminal
Check 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:
paused
in interfaceTerminal
- Overrides:
paused
in classAbstractTerminal
- Returns:
- whether the terminal is currently reading the input stream or not
- See Also:
Terminal.pause()
,Terminal.resume()
-
pump
public void pump()
-
getCursorPosition
public Cursor getCursorPosition(java.util.function.IntConsumer discarded)
Description copied from interface:Terminal
Query 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:
getCursorPosition
in interfaceTerminal
- Overrides:
getCursorPosition
in classAbstractTerminal
- Parameters:
discarded
- a consumer receiving discarded characters- Returns:
null
if cursor position reporting is not supported or a valid cursor position
-
getProvider
public TerminalProvider getProvider()
Description copied from interface:TerminalExt
Returns theTerminalProvider
that created this terminal ornull
if the terminal was created with no provider.- Specified by:
getProvider
in interfaceTerminalExt
- Overrides:
getProvider
in classLineDisciplineTerminal
-
-