Package org.jline.terminal.impl
Class LineDisciplineTerminal
java.lang.Object
org.jline.terminal.impl.AbstractTerminal
org.jline.terminal.impl.LineDisciplineTerminal
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,TerminalExt
,Terminal
- Direct Known Subclasses:
ExternalTerminal
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 Class Summary
Nested classes/interfaces inherited from interface org.jline.terminal.Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Attributes
Console dataprotected final OutputStream
protected final Size
protected final NonBlockingPumpInputStream
protected final OutputStream
protected final OutputStream
protected final NonBlockingReader
protected final PrintWriter
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
ConstructorDescriptionLineDisciplineTerminal
(String name, String type, OutputStream masterOutput, Charset encoding) LineDisciplineTerminal
(String name, String type, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doClose()
protected boolean
doProcessInputByte
(int c) Returns the terminal attributes.Returns theTerminalProvider
that created this terminal ornull
if the terminal was created with no provider.getSize()
Retrieve the size of the visible windowThe underlying system stream, may beSystemStream.Output
,SystemStream.Error
, ornull
if this terminal is not bound to a system stream.input()
Retrieve the input stream for this terminal.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) reader()
Retrieve theReader
for this terminal.void
setAttributes
(Attributes attr) Set the terminal attributes.void
writer()
Retrieve theWriter
for this terminal.Methods inherited from class org.jline.terminal.impl.AbstractTerminal
canPauseResume, checkInterrupted, close, echo, echo, echoSignal, encoding, enterRawMode, flush, getBooleanCapability, getCursorPosition, getKind, getName, getNumericCapability, getPalette, getStatus, getStatus, getStringCapability, getType, handle, hasFocusSupport, hasMouseSupport, parseInfoCmp, pause, pause, paused, puts, readMouseEvent, readMouseEvent, resume, 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 Details
-
masterOutput
-
slaveInputPipe
-
slaveInput
-
slaveReader
-
slaveWriter
-
slaveOutput
-
attributes
Console data -
size
-
-
Constructor Details
-
LineDisciplineTerminal
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding) throws IOException - Throws:
IOException
-
LineDisciplineTerminal
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException - Throws:
IOException
-
-
Method Details
-
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
-
writer
Description copied from interface:Terminal
Retrieve theWriter
for this terminal. This is the standard way to write to this terminal.- Returns:
- The writer
-
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:
-
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:
-
getAttributes
Description copied from interface:Terminal
Returns the terminal attributes. The returned object can be safely modified further used in a call toTerminal.setAttributes(Attributes)
.- Returns:
- the terminal attributes.
-
setAttributes
Description copied from interface:Terminal
Set the terminal attributes. The terminal will perform a copy of the given attributes.- Parameters:
attr
- the new attributes
-
getSize
Description copied from interface:Terminal
Retrieve the size of the visible window- Returns:
- the visible terminal size
- See Also:
-
setSize
-
raise
- Specified by:
raise
in interfaceTerminal
- Overrides:
raise
in classAbstractTerminal
-
processInputByte
Master input processing. All data coming to the terminal should be provided using this method.- Parameters:
c
- the input byte- Throws:
IOException
- if anything wrong happens
-
processInputBytes
- Throws:
IOException
-
processInputBytes
- Throws:
IOException
-
doProcessInputByte
- Throws:
IOException
-
processOutputByte
Master output processing. All data going to the master should be provided by this method.- Parameters:
c
- the output byte- Throws:
IOException
- if anything wrong happens
-
processIOException
-
doClose
- Overrides:
doClose
in classAbstractTerminal
- Throws:
IOException
-
getProvider
Description copied from interface:TerminalExt
Returns theTerminalProvider
that created this terminal ornull
if the terminal was created with no provider. -
getSystemStream
Description copied from interface:TerminalExt
The underlying system stream, may beSystemStream.Output
,SystemStream.Error
, ornull
if this terminal is not bound to a system stream.
-