Closeable
, Flushable
, AutoCloseable
, Terminal
ExternalTerminal
public class LineDisciplineTerminal extends AbstractTerminal
Terminal
interface represents the slave
side of a PTY, but implementations derived from this class
will handle both the slave and master side of things.
In order to correctly handle line discipline, the terminal
needs to read the input in advance in order to raise the
signals as fast as possible.
For example, when the user hits Ctrl+C, we can't wait until
the application consumes all the read events.
The same applies to echoing, when enabled, as the echoing
has to happen as soon as the user hit the keyboard, and not
only when the application running in the terminal processes
the input.Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
Modifier and Type | Field | Description |
---|---|---|
protected Attributes |
attributes |
Console data
|
protected OutputStream |
masterOutput |
|
protected Size |
size |
|
protected NonBlockingPumpInputStream |
slaveInput |
|
protected OutputStream |
slaveInputPipe |
|
protected OutputStream |
slaveOutput |
|
protected NonBlockingReader |
slaveReader |
|
protected PrintWriter |
slaveWriter |
bools, encoding, handlers, ints, name, onClose, status, strings, type
TYPE_DUMB, TYPE_DUMB_COLOR
Constructor | Description |
---|---|
LineDisciplineTerminal(String name,
String type,
OutputStream masterOutput,
Charset encoding) |
|
LineDisciplineTerminal(String name,
String type,
OutputStream masterOutput,
Charset encoding,
Terminal.SignalHandler signalHandler) |
Modifier and Type | Method | Description |
---|---|---|
protected void |
doClose() |
|
protected boolean |
doProcessInputByte(int c) |
|
Attributes |
getAttributes() |
|
Size |
getSize() |
Retrieve the size of the visible window
|
InputStream |
input() |
Retrieve the input stream for this terminal.
|
OutputStream |
output() |
Retrieve the output stream for this terminal.
|
void |
processInputByte(int c) |
Master input processing.
|
void |
processInputBytes(byte[] input) |
|
void |
processInputBytes(byte[] input,
int offset,
int length) |
|
protected void |
processIOException(IOException ioException) |
|
protected void |
processOutputByte(int c) |
Master output processing.
|
void |
raise(Terminal.Signal signal) |
|
NonBlockingReader |
reader() |
Retrieve the
Reader for this terminal. |
void |
setAttributes(Attributes attr) |
|
void |
setSize(Size sz) |
|
PrintWriter |
writer() |
Retrieve the
Writer for this terminal. |
canPauseResume, checkInterrupted, close, echo, echo, echoSignal, encoding, enterRawMode, flush, getBooleanCapability, getCursorPosition, getKind, getName, getNumericCapability, getStatus, getStatus, getStringCapability, getType, handle, hasFocusSupport, hasMouseSupport, parseInfoCmp, pause, pause, paused, puts, readMouseEvent, readMouseEvent, resume, setOnClose, trackFocus, trackMouse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBufferSize, getHeight, getWidth
protected final OutputStream masterOutput
protected final OutputStream slaveInputPipe
protected final NonBlockingPumpInputStream slaveInput
protected final NonBlockingReader slaveReader
protected final PrintWriter slaveWriter
protected final OutputStream slaveOutput
protected final Attributes attributes
protected final Size size
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding) throws IOException
IOException
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException
IOException
public NonBlockingReader reader()
Terminal
Reader
for this terminal.
This is the standard way to read input from this terminal.
The reader is non blocking.public PrintWriter writer()
Terminal
Writer
for this terminal.
This is the standard way to write to this terminal.public InputStream input()
Terminal
Terminal.reader()
instead.Terminal.reader()
public OutputStream output()
Terminal
Terminal.writer()
instead.Terminal.writer()
public Attributes getAttributes()
public void setAttributes(Attributes attr)
public Size getSize()
Terminal
Terminal.getBufferSize()
public void setSize(Size sz)
public void raise(Terminal.Signal signal)
raise
in interface Terminal
raise
in class AbstractTerminal
public void processInputByte(int c) throws IOException
c
- the input byteIOException
- if anything wrong happenspublic void processInputBytes(byte[] input) throws IOException
IOException
public void processInputBytes(byte[] input, int offset, int length) throws IOException
IOException
protected boolean doProcessInputByte(int c) throws IOException
IOException
protected void processOutputByte(int c) throws IOException
c
- the output byteIOException
- if anything wrong happensprotected void processIOException(IOException ioException)
protected void doClose() throws IOException
doClose
in class AbstractTerminal
IOException
Copyright © 2020. All rights reserved.