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
FieldsModifier and TypeFieldDescriptionprotected final AttributesConsole dataprotected final OutputStreamprotected final Sizeprotected booleanprotected final NonBlockingPumpInputStreamprotected final OutputStreamprotected final OutputStreamprotected final NonBlockingReaderprotected final PrintWriterFields inherited from class org.jline.terminal.impl.AbstractTerminal
bools, encoding, handlers, ints, name, onClose, palette, status, strings, typeFields inherited from interface org.jline.terminal.Terminal
TYPE_DUMB, TYPE_DUMB_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionLineDisciplineTerminal(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 voiddoClose()protected booleandoProcessInputByte(int c) Returns the terminal attributes.Returns theTerminalProviderthat created this terminal ornullif the terminal was created with no provider.getSize()Retrieve the size of the visible windowThe underlying system stream, may beSystemStream.Output,SystemStream.Error, ornullif 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.voidprocessInputByte(int c) Master input processing.voidprocessInputBytes(byte[] input) voidprocessInputBytes(byte[] input, int offset, int length) protected voidprocessIOException(IOException ioException) protected voidprocessOutputByte(int c) Master output processing.voidraise(Terminal.Signal signal) Raise the specific signal.reader()Retrieve theReaderfor this terminal.voidsetAttributes(Attributes attr) Set the terminal attributes.voidwriter()Retrieve theWriterfor 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, toString, trackFocus, trackMouseMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jline.terminal.Terminal
getBufferSize, getHeight, getWidth
-
Field Details
-
masterOutput
-
slaveInputPipe
-
slaveInput
-
slaveReader
-
slaveWriter
-
slaveOutput
-
attributes
Console data -
size
-
skipNextLf
protected boolean skipNextLf
-
-
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:TerminalRetrieve theReaderfor 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:TerminalRetrieve theWriterfor this terminal. This is the standard way to write to this terminal.- Returns:
- The writer
-
input
Description copied from interface:TerminalRetrieve 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:TerminalRetrieve 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:TerminalReturns 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:TerminalSet the terminal attributes. The terminal will perform a copy of the given attributes.- Parameters:
attr- the new attributes
-
getSize
-
setSize
-
raise
Description copied from interface:TerminalRaise 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 toAttributes.ControlChar.VINTR,Attributes.ControlChar.VQUIT, orAttributes.ControlChar.VSUSP.- Specified by:
raisein interfaceTerminal- Overrides:
raisein classAbstractTerminal- Parameters:
signal- the signal to raise
-
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:
doClosein classAbstractTerminal- Throws:
IOException
-
getProvider
Description copied from interface:TerminalExtReturns theTerminalProviderthat created this terminal ornullif the terminal was created with no provider. -
getSystemStream
Description copied from interface:TerminalExtThe underlying system stream, may beSystemStream.Output,SystemStream.Error, ornullif this terminal is not bound to a system stream.
-