Class AbstractPty

java.lang.Object
org.jline.terminal.impl.AbstractPty
All Implemented Interfaces:
Closeable, AutoCloseable, Pty
Direct Known Subclasses:
ExecPty

public abstract class AbstractPty extends Object implements Pty
Base implementation of the Pty interface.

The AbstractPty class provides a common foundation for pseudoterminal (PTY) implementations. It handles common functionality such as system stream management and provider access, while leaving platform-specific PTY operations to be implemented by concrete subclasses.

This class serves as the base for various PTY implementations, including:

  • Native PTY implementations (JNI, JNA, FFM) for direct access to system PTYs
  • Exec PTY implementation that uses external commands

The AbstractPty maintains information about the associated system stream and terminal provider, which are common to all PTY implementations regardless of the underlying mechanism used to interact with the terminal.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • setAttr

      public void setAttr(Attributes attr) throws IOException
      Description copied from interface: Pty
      Sets the terminal attributes for this PTY.

      This method allows changing various aspects of terminal behavior, such as echo settings, line discipline, and control characters.

      Specified by:
      setAttr in interface Pty
      Parameters:
      attr - the terminal attributes to set
      Throws:
      IOException - if an I/O error occurs
      See Also:
    • getSlaveInput

      public InputStream getSlaveInput() throws IOException
      Description copied from interface: Pty
      Returns the input stream for the slave side of the PTY.

      This stream receives data that has been written to the master's output stream. Processes running in the terminal read from this stream to get their input.

      Specified by:
      getSlaveInput in interface Pty
      Returns:
      the slave's input stream
      Throws:
      IOException - if an I/O error occurs
    • doSetAttr

      protected abstract void doSetAttr(Attributes attr) throws IOException
      Throws:
      IOException
    • doGetSlaveInput

      protected abstract InputStream doGetSlaveInput() throws IOException
      Throws:
      IOException
    • checkInterrupted

      protected void checkInterrupted() throws InterruptedIOException
      Throws:
      InterruptedIOException
    • getProvider

      public TerminalProvider getProvider()
      Description copied from interface: Pty
      Returns the terminal provider that created this PTY.

      The terminal provider is responsible for creating and managing terminal instances on a specific platform.

      Specified by:
      getProvider in interface Pty
      Returns:
      the terminal provider that created this PTY
      See Also:
    • getSystemStream

      public SystemStream getSystemStream()
      Description copied from interface: Pty
      Returns the system stream associated with this PTY, if any.

      The system stream indicates whether this PTY is connected to standard input, standard output, or standard error.

      Specified by:
      getSystemStream in interface Pty
      Returns:
      the associated system stream, or null if this PTY is not associated with a system stream
      See Also:
    • newDescriptor

      protected static FileDescriptor newDescriptor(int fd)