Package org.jline.terminal.impl
Class PosixPtyTerminal
- java.lang.Object
-
- org.jline.terminal.impl.AbstractTerminal
-
- org.jline.terminal.impl.AbstractPosixTerminal
-
- org.jline.terminal.impl.PosixPtyTerminal
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
,Terminal
public class PosixPtyTerminal extends AbstractPosixTerminal
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
PosixPtyTerminal.InputStreamWrapper
-
Nested classes/interfaces inherited from interface org.jline.terminal.Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.InputStream
in
private NonBlockingInputStream
input
private java.lang.Thread
inputPumpThread
private java.lang.Object
lock
private java.io.InputStream
masterInput
private java.io.OutputStream
masterOutput
private java.io.OutputStream
out
private java.io.OutputStream
output
private java.lang.Thread
outputPumpThread
private boolean
paused
private NonBlockingReader
reader
private java.io.PrintWriter
writer
-
Fields inherited from class org.jline.terminal.impl.AbstractPosixTerminal
originalAttributes, pty
-
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 PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding)
PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler)
PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused)
-
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()
java.io.InputStream
input()
Retrieve the input stream for this terminal.java.io.OutputStream
output()
Retrieve the output stream for this terminal.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.private void
pumpIn()
private void
pumpOut()
NonBlockingReader
reader()
Retrieve theReader
for this terminal.void
resume()
Resume reading the input stream.java.io.PrintWriter
writer()
Retrieve theWriter
for this terminal.-
Methods inherited from class org.jline.terminal.impl.AbstractPosixTerminal
getAttributes, getCursorPosition, getPty, getSize, setAttributes, setSize
-
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, raise, readMouseEvent, readMouseEvent, setOnClose, trackFocus, trackMouse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.terminal.Terminal
getBufferSize, getHeight, getWidth
-
-
-
-
Field Detail
-
in
private final java.io.InputStream in
-
out
private final java.io.OutputStream out
-
masterInput
private final java.io.InputStream masterInput
-
masterOutput
private final java.io.OutputStream masterOutput
-
input
private final NonBlockingInputStream input
-
output
private final java.io.OutputStream output
-
reader
private final NonBlockingReader reader
-
writer
private final java.io.PrintWriter writer
-
lock
private final java.lang.Object lock
-
inputPumpThread
private java.lang.Thread inputPumpThread
-
outputPumpThread
private java.lang.Thread outputPumpThread
-
paused
private boolean paused
-
-
Constructor Detail
-
PosixPtyTerminal
public PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding) throws java.io.IOException
- Throws:
java.io.IOException
-
PosixPtyTerminal
public PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler) throws java.io.IOException
- Throws:
java.io.IOException
-
PosixPtyTerminal
public PosixPtyTerminal(java.lang.String name, java.lang.String type, Pty pty, java.io.InputStream in, java.io.OutputStream out, java.nio.charset.Charset encoding, Terminal.SignalHandler signalHandler, boolean paused) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
input
public java.io.InputStream input()
Description copied from interface:Terminal
Retrieve the input stream for this terminal. In some rare cases, there may be a need to access the terminal input stream directly. In the usual cases, use theTerminal.reader()
instead.- Returns:
- The input stream
- See Also:
Terminal.reader()
-
reader
public NonBlockingReader reader()
Description copied from interface:Terminal
Retrieve theReader
for this terminal. This is the standard way to read input from this terminal. The reader is non blocking.- Returns:
- The non blocking reader
-
output
public java.io.OutputStream output()
Description copied from interface:Terminal
Retrieve the output stream for this terminal. In some rare cases, there may be a need to access the terminal output stream directly. In the usual cases, use theTerminal.writer()
instead.- Returns:
- The output stream
- See Also:
Terminal.writer()
-
writer
public java.io.PrintWriter writer()
Description copied from interface:Terminal
Retrieve theWriter
for this terminal. This is the standard way to write to this terminal.- Returns:
- The writer
-
doClose
protected void doClose() throws java.io.IOException
- Overrides:
doClose
in classAbstractPosixTerminal
- 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()
-
pumpIn
private void pumpIn()
-
pumpOut
private void pumpOut()
-
-