Class AbstractPty
- java.lang.Object
-
- org.jline.terminal.impl.AbstractPty
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,Pty
- Direct Known Subclasses:
ExecPty
public abstract class AbstractPty extends java.lang.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:
Pty
-
-
Field Summary
Fields Modifier and Type Field Description protected TerminalProviderproviderprotected SystemStreamsystemStream
-
Constructor Summary
Constructors Constructor Description AbstractPty(TerminalProvider provider, SystemStream systemStream)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheckInterrupted()protected abstract java.io.InputStreamdoGetSlaveInput()protected abstract voiddoSetAttr(Attributes attr)TerminalProvidergetProvider()Returns the terminal provider that created this PTY.java.io.InputStreamgetSlaveInput()Returns the input stream for the slave side of the PTY.SystemStreamgetSystemStream()Returns the system stream associated with this PTY, if any.protected static java.io.FileDescriptornewDescriptor(int fd)voidsetAttr(Attributes attr)Sets the terminal attributes for this PTY.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jline.terminal.spi.Pty
getAttr, getMasterInput, getMasterOutput, getSize, getSlaveOutput, setSize
-
-
-
-
Field Detail
-
provider
protected final TerminalProvider provider
-
systemStream
protected final SystemStream systemStream
-
-
Constructor Detail
-
AbstractPty
public AbstractPty(TerminalProvider provider, SystemStream systemStream)
-
-
Method Detail
-
setAttr
public void setAttr(Attributes attr) throws java.io.IOException
Description copied from interface:PtySets 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:
setAttrin interfacePty- Parameters:
attr- the terminal attributes to set- Throws:
java.io.IOException- if an I/O error occurs- See Also:
Attributes
-
getSlaveInput
public java.io.InputStream getSlaveInput() throws java.io.IOExceptionDescription copied from interface:PtyReturns 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:
getSlaveInputin interfacePty- Returns:
- the slave's input stream
- Throws:
java.io.IOException- if an I/O error occurs
-
doSetAttr
protected abstract void doSetAttr(Attributes attr) throws java.io.IOException
- Throws:
java.io.IOException
-
doGetSlaveInput
protected abstract java.io.InputStream doGetSlaveInput() throws java.io.IOException- Throws:
java.io.IOException
-
checkInterrupted
protected void checkInterrupted() throws java.io.InterruptedIOException- Throws:
java.io.InterruptedIOException
-
getProvider
public TerminalProvider getProvider()
Description copied from interface:PtyReturns the terminal provider that created this PTY.The terminal provider is responsible for creating and managing terminal instances on a specific platform.
- Specified by:
getProviderin interfacePty- Returns:
- the terminal provider that created this PTY
- See Also:
TerminalProvider
-
getSystemStream
public SystemStream getSystemStream()
Description copied from interface:PtyReturns 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:
getSystemStreamin interfacePty- Returns:
- the associated system stream, or
nullif this PTY is not associated with a system stream - See Also:
SystemStream
-
newDescriptor
protected static java.io.FileDescriptor newDescriptor(int fd)
-
-