Class LineDisciplineTerminal
java.lang.Object
org.aesh.terminal.tty.impl.AbstractTerminal
org.aesh.terminal.tty.impl.LineDisciplineTerminal
- All Implemented Interfaces:
Closeable, AutoCloseable, org.aesh.terminal.Terminal
- Direct Known Subclasses:
ExternalTerminal
Abstract console 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 console 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.aesh.terminal.Terminal
org.aesh.terminal.Terminal.SignalHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.aesh.terminal.AttributesTerminal attributes.protected final OutputStreamMaster output stream.protected org.aesh.terminal.tty.SizeTerminal size.protected final InputStreamSlave input stream.protected final OutputStreamSlave input pipe write side.protected final OutputStreamSlave output stream.Fields inherited from class AbstractTerminal
device, handlers, name, typeFields inherited from interface org.aesh.terminal.Terminal
READ_EXPIRED -
Constructor Summary
ConstructorsConstructorDescriptionLineDisciplineTerminal(String name, String type, OutputStream masterOutput) Create a new line discipline terminal. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidClose the slave input pipe.org.aesh.terminal.Attributesorg.aesh.terminal.tty.SizegetSize()input()output()voidprocessInputByte(int c) Master input processing.voidprocessInputBytes(byte[] input) Process an array of input bytes.voidprocessInputBytes(byte[] input, int length) Process input bytes up to the specified length.voidprocessInputBytes(int[] input, int length) Process input code points up to the specified length.protected voidprocessOutputByte(int c) Master output processing.voidraise(org.aesh.terminal.tty.Signal signal) voidsetAttributes(org.aesh.terminal.Attributes attr) Methods inherited from class AbstractTerminal
device, echo, echo, echoSignal, getName, getType, handle, handleDefaultSignalMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aesh.terminal.Terminal
getCodePointConsumer, peek, read, read, supportsNonBlockingRead
-
Field Details
-
masterOutput
Master output stream. -
slaveInputPipe
Slave input pipe write side. -
slaveInput
Slave input stream. -
slaveOutput
Slave output stream. -
attributes
protected final org.aesh.terminal.Attributes attributesTerminal attributes. -
size
protected org.aesh.terminal.tty.Size sizeTerminal size.
-
-
Constructor Details
-
LineDisciplineTerminal
public LineDisciplineTerminal(String name, String type, OutputStream masterOutput) throws IOException Create a new line discipline terminal.- Parameters:
name- the terminal nametype- the terminal typemasterOutput- the master output stream- Throws:
IOException- if an I/O error occurs
-
-
Method Details
-
input
-
output
-
getAttributes
public org.aesh.terminal.Attributes getAttributes() -
setAttributes
public void setAttributes(org.aesh.terminal.Attributes attr) -
getSize
public org.aesh.terminal.tty.Size getSize() -
raise
public void raise(org.aesh.terminal.tty.Signal signal) - Specified by:
raisein interfaceorg.aesh.terminal.Terminal- Overrides:
raisein classAbstractTerminal
-
processInputByte
Master input processing. All data coming to the console should be provided using this method.- Parameters:
c- the input byte- Throws:
IOException- if an I/O error occurs
-
processInputBytes
Process an array of input bytes.- Parameters:
input- the input bytes- Throws:
IOException- if an I/O error occurs
-
processInputBytes
Process input bytes up to the specified length.- Parameters:
input- the input byteslength- the number of bytes to process- Throws:
IOException- if an I/O error occurs
-
processInputBytes
Process input code points up to the specified length.- Parameters:
input- the input code pointslength- the number of code points to process- Throws:
IOException- if an I/O error occurs
-
closeSlaveInputPipe
protected void closeSlaveInputPipe()Close the slave input pipe. -
processOutputByte
Master output processing. All data going to the master should be provided by this method.- Parameters:
c- the output byte- Throws:
IOException- if an I/O error occurs
-
close
- Throws:
IOException
-