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

public class LineDisciplineTerminal extends AbstractTerminal
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.
  • Field Details

    • masterOutput

      protected final OutputStream masterOutput
      Master output stream.
    • slaveInputPipe

      protected final OutputStream slaveInputPipe
      Slave input pipe write side.
    • slaveInput

      protected final InputStream slaveInput
      Slave input stream.
    • slaveOutput

      protected final OutputStream slaveOutput
      Slave output stream.
    • attributes

      protected final Attributes attributes
      Terminal attributes.
    • size

      protected Size 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 name
      type - the terminal type
      masterOutput - the master output stream
      Throws:
      IOException - if an I/O error occurs
  • Method Details

    • input

      public InputStream input()
    • output

      public OutputStream output()
    • getAttributes

      public Attributes getAttributes()
    • setAttributes

      public void setAttributes(Attributes attr)
    • getSize

      public Size getSize()
    • raise

      public void raise(Signal signal)
      Specified by:
      raise in interface Terminal
      Overrides:
      raise in class AbstractTerminal
    • processInputByte

      public void processInputByte(int c) throws IOException
      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

      public void processInputBytes(byte[] input) throws IOException
      Process an array of input bytes.
      Parameters:
      input - the input bytes
      Throws:
      IOException - if an I/O error occurs
    • processInputBytes

      public void processInputBytes(byte[] input, int length) throws IOException
      Process input bytes up to the specified length.
      Parameters:
      input - the input bytes
      length - the number of bytes to process
      Throws:
      IOException - if an I/O error occurs
    • processInputBytes

      public void processInputBytes(int[] input, int length) throws IOException
      Process input code points up to the specified length.
      Parameters:
      input - the input code points
      length - 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

      protected void processOutputByte(int c) throws IOException
      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

      public void close() throws IOException
      Throws:
      IOException