Class AbstractPty
- java.lang.Object
-
- org.jline.terminal.impl.AbstractPty
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Pty
- Direct Known Subclasses:
ExecPty
,JniNativePty
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 TerminalProvider
provider
protected SystemStream
systemStream
-
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 void
checkInterrupted()
protected abstract java.io.InputStream
doGetSlaveInput()
protected abstract void
doSetAttr(Attributes attr)
TerminalProvider
getProvider()
Returns the terminal provider that created this PTY.java.io.InputStream
getSlaveInput()
Returns the input stream for the slave side of the PTY.SystemStream
getSystemStream()
Returns the system stream associated with this PTY, if any.protected static java.io.FileDescriptor
newDescriptor(int fd)
void
setAttr(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: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 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.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 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: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 interfacePty
- Returns:
- the terminal provider that created this PTY
- See Also:
TerminalProvider
-
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 interfacePty
- Returns:
- the associated system stream, or
null
if this PTY is not associated with a system stream - See Also:
SystemStream
-
newDescriptor
protected static java.io.FileDescriptor newDescriptor(int fd)
-
-