Package org.aesh.terminal.tty.impl
Class LineDisciplineTerminal
java.lang.Object
org.aesh.terminal.tty.impl.AbstractTerminal
org.aesh.terminal.tty.impl.LineDisciplineTerminal
- All Implemented Interfaces:
Closeable,AutoCloseable,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
Terminal.SignalHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AttributesTerminal attributes.protected final OutputStreamMaster output stream.protected SizeTerminal size.protected final InputStreamSlave input stream.protected final OutputStreamSlave input pipe write side.protected final OutputStreamSlave output stream. -
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.getSize()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.voidvoidsetAttributes(Attributes attr) Methods inherited from class org.aesh.terminal.tty.impl.AbstractTerminal
device, echo, echo, echoSignal, getName, getType, handle, handleDefaultSignalMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aesh.terminal.Terminal
getCodePointConsumer
-
Field Details
-
masterOutput
Master output stream. -
slaveInputPipe
Slave input pipe write side. -
slaveInput
Slave input stream. -
slaveOutput
Slave output stream. -
attributes
Terminal attributes. -
size
Terminal 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
-
setAttributes
-
getSize
-
raise
- Specified by:
raisein interfaceTerminal- 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
-