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

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

  • Constructor Details

  • Method Details

    • reader

      public NonBlockingReader reader()
      Description copied from interface: Terminal
      Retrieve the Reader 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

      public PrintWriter writer()
      Description copied from interface: Terminal
      Retrieve the Writer for this terminal. This is the standard way to write to this terminal.
      Returns:
      The writer
    • input

      public InputStream 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 the Terminal.reader() instead.
      Returns:
      The input stream
      See Also:
    • output

      public OutputStream 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 the Terminal.writer() instead.
      Returns:
      The output stream
      See Also:
    • getAttributes

      public Attributes getAttributes()
      Description copied from interface: Terminal
      Returns the terminal attributes. The returned object can be safely modified further used in a call to Terminal.setAttributes(Attributes).
      Returns:
      the terminal attributes.
    • setAttributes

      public void setAttributes(Attributes attr)
      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

      public Size getSize()
      Description copied from interface: Terminal
      Retrieve the size of the visible window
      Returns:
      the visible terminal size
      See Also:
    • setSize

      public void setSize(Size sz)
    • raise

      public void raise(Terminal.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 terminal should be provided using this method.
      Parameters:
      c - the input byte
      Throws:
      IOException - if anything wrong happens
    • processInputBytes

      public void processInputBytes(byte[] input) throws IOException
      Throws:
      IOException
    • processInputBytes

      public void processInputBytes(byte[] input, int offset, int length) throws IOException
      Throws:
      IOException
    • doProcessInputByte

      protected boolean doProcessInputByte(int c) throws IOException
      Throws:
      IOException
    • 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 anything wrong happens
    • processIOException

      protected void processIOException(IOException ioException)
    • doClose

      protected void doClose() throws IOException
      Overrides:
      doClose in class AbstractTerminal
      Throws:
      IOException
    • getProvider

      public TerminalProvider getProvider()
      Description copied from interface: TerminalExt
      Returns the TerminalProvider that created this terminal or null if the terminal was created with no provider.
    • getSystemStream

      public SystemStream getSystemStream()
      Description copied from interface: TerminalExt
      The underlying system stream, may be SystemStream.Output, SystemStream.Error, or null if this terminal is not bound to a system stream.