APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.internal.org.jline.terminal.impl

public Class LineDisciplineTerminal

extends AbstractTerminal
Class Inheritance
Known Direct Subclasses
jdk.internal.org.jline.terminal.impl.ExternalTerminal
Imports
java.io.IOException, .InputStream, .OutputStream, .OutputStreamWriter, .PrintWriter, java.nio.charset.Charset, java.util.EnumSet, .Objects, jdk.internal.org.jline.terminal.Attributes, .Attributes.ControlChar, .Attributes.InputFlag, .Attributes.LocalFlag, .Attributes.OutputFlag, .Size, .Terminal, jdk.internal.org.jline.terminal.spi.SystemStream, .TerminalProvider, jdk.internal.org.jline.utils.NonBlocking, .NonBlockingPumpInputStream, .NonBlockingReader

Abstract terminal with support for line discipline. The 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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
protected final Attributes
attributes

Console data

protected final OutputStream
private static final int
protected final Size
protected boolean
protected final NonBlockingPumpInputStream
protected final OutputStream
protected final OutputStream
protected final NonBlockingReader
protected final PrintWriter
Inherited from jdk.internal.org.jline.terminal.impl.AbstractTerminal:
boolsencodinghandlersintsnameonClosepalettestatusstringstype

Constructor Summary

AccessConstructor and Description
public
LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding)

public
LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler)

Method Summary

Modifier and TypeMethod and Description
private static int
ctrl(char c)

protected void
protected boolean
public Attributes
getAttributes()

Implements jdk.internal.org.jline.terminal.Terminal.getAttributes.

Returns the terminal attributes.

private static Attributes
public TerminalProvider
getProvider()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Returns the TerminalProvider that created this terminal or null if the terminal was created with no provider.

public Size
getSize()

Implements jdk.internal.org.jline.terminal.Terminal.getSize.

Retrieve the size of the visible window

public SystemStream
getSystemStream()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

The underlying system stream, may be SystemStream#Output, SystemStream#Error, or null if this terminal is not bound to a system stream.

public InputStream
input()

Implements jdk.internal.org.jline.terminal.Terminal.input.

Retrieve the input stream for this terminal.

public OutputStream
output()

Implements jdk.internal.org.jline.terminal.Terminal.output.

Retrieve the output stream for this terminal.

public void
processInputByte(int
the input byte
c
)

Master input processing.

public void
processInputBytes(byte[] input)

public void
processInputBytes(byte[] input, int offset, int length)

protected void
protected void
processOutputByte(int
the output byte
c
)

Master output processing.

public void
public NonBlockingReader
reader()

Implements jdk.internal.org.jline.terminal.Terminal.reader.

Retrieve the Reader for this terminal.

public void
public void
public PrintWriter
writer()

Implements jdk.internal.org.jline.terminal.Terminal.writer.

Retrieve the Writer for this terminal.

Inherited from jdk.internal.org.jline.terminal.impl.AbstractTerminal:
canPauseResumecheckInterruptedcloseechoechoechoSignalencodingenterRawModeflushgetBooleanCapabilitygetCursorPositiongetKindgetNamegetNumericCapabilitygetPalettegetStatusgetStatusgetStringCapabilitygetTypehandlehasFocusSupporthasMouseSupportparseInfoCmppausepausepausedputsreadMouseEventreadMouseEventresumesetOnClosetoStringtrackFocustrackMouse

Field Detail

attributesback to summary
protected final Attributes attributes

Console data

masterOutputback to summary
protected final OutputStream masterOutput
PIPE_SIZEback to summary
private static final int PIPE_SIZE
sizeback to summary
protected final Size size
skipNextLfback to summary
protected boolean skipNextLf
slaveInputback to summary
protected final NonBlockingPumpInputStream slaveInput
slaveInputPipeback to summary
protected final OutputStream slaveInputPipe
slaveOutputback to summary
protected final OutputStream slaveOutput
slaveReaderback to summary
protected final NonBlockingReader slaveReader
slaveWriterback to summary
protected final PrintWriter slaveWriter

Constructor Detail

LineDisciplineTerminalback to summary
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding) throws IOException
LineDisciplineTerminalback to summary
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException
Annotations
@SuppressWarnings:this-escape

Method Detail

ctrlback to summary
private static int ctrl(char c)
doCloseback to summary
protected void doClose() throws IOException

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.doClose.

doProcessInputByteback to summary
protected boolean doProcessInputByte(int c) throws IOException
getAttributesback to summary
public Attributes getAttributes()

Implements jdk.internal.org.jline.terminal.Terminal.getAttributes.

Doc from jdk.internal.org.jline.terminal.Terminal.getAttributes.

Returns the terminal attributes. The returned object can be safely modified further used in a call to setAttributes(Attributes).

getDefaultTerminalAttributesback to summary
private static Attributes getDefaultTerminalAttributes()
getProviderback to summary
public TerminalProvider getProvider()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Doc from jdk.internal.org.jline.terminal.spi.TerminalExt.getProvider.

Returns the TerminalProvider that created this terminal or null if the terminal was created with no provider.

Annotations
@Override
getSizeback to summary
public Size getSize()

Implements jdk.internal.org.jline.terminal.Terminal.getSize.

Doc from jdk.internal.org.jline.terminal.Terminal.getSize.

Retrieve the size of the visible window

getSystemStreamback to summary
public SystemStream getSystemStream()

Implements jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

Doc from jdk.internal.org.jline.terminal.spi.TerminalExt.getSystemStream.

The underlying system stream, may be SystemStream#Output, SystemStream#Error, or null if this terminal is not bound to a system stream.

Annotations
@Override
inputback to summary
public InputStream input()

Implements jdk.internal.org.jline.terminal.Terminal.input.

Doc from jdk.internal.org.jline.terminal.Terminal.input.

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 the reader() instead.

Annotations
@Override
outputback to summary
public OutputStream output()

Implements jdk.internal.org.jline.terminal.Terminal.output.

Doc from jdk.internal.org.jline.terminal.Terminal.output.

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 the writer() instead.

Annotations
@Override
processInputByteback to summary
public void processInputByte(int c) throws IOException

Master input processing. All data coming to the terminal should be provided using this method.

Parameters
c:int

the input byte

Exceptions
IOException:
if anything wrong happens
processInputBytesback to summary
public void processInputBytes(byte[] input) throws IOException
processInputBytesback to summary
public void processInputBytes(byte[] input, int offset, int length) throws IOException
processIOExceptionback to summary
protected void processIOException(IOException ioException)
processOutputByteback to summary
protected void processOutputByte(int c) throws IOException

Master output processing. All data going to the master should be provided by this method.

Parameters
c:int

the output byte

Exceptions
IOException:
if anything wrong happens
raiseback to summary
public void raise(Terminal.Signal signal)

Overrides jdk.internal.org.jline.terminal.impl.AbstractTerminal.raise.

Implements jdk.internal.org.jline.terminal.Terminal.raise.

Doc from jdk.internal.org.jline.terminal.Terminal.raise.

Raise the specific signal. This is not method usually called by non system terminals. When accessing a terminal through a SSH or Telnet connection, signals may be conveyed by the protocol and thus need to be raised when reaching the terminal code. The terminals do that automatically when the terminal input stream has a character mapped to Attributes.ControlChar#VINTR, Attributes.ControlChar#VQUIT, or Attributes.ControlChar#VSUSP.

Annotations
@Override
readerback to summary
public NonBlockingReader reader()

Implements jdk.internal.org.jline.terminal.Terminal.reader.

Doc from jdk.internal.org.jline.terminal.Terminal.reader.

Retrieve the Reader for this terminal. This is the standard way to read input from this terminal. The reader is non blocking.

setAttributesback to summary
public void setAttributes(Attributes attr)

Implements jdk.internal.org.jline.terminal.Terminal.setAttributes.

Doc from jdk.internal.org.jline.terminal.Terminal.setAttributes.

Set the terminal attributes. The terminal will perform a copy of the given attributes.

setSizeback to summary
public void setSize(Size sz)

Implements jdk.internal.org.jline.terminal.Terminal.setSize.

writerback to summary
public PrintWriter writer()

Implements jdk.internal.org.jline.terminal.Terminal.writer.

Doc from jdk.internal.org.jline.terminal.Terminal.writer.

Retrieve the Writer for this terminal. This is the standard way to write to this terminal.

jdk.internal.org.jline.terminal.impl back to summary

private Class LineDisciplineTerminal.FilteringOutputStream

extends OutputStream
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

public void
write(int b)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[] b, int off, int len)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
nullOutputStreamwrite

Constructor Detail

FilteringOutputStreamback to summary
private FilteringOutputStream()

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.