Class AbstractPty
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Pty
- Direct Known Subclasses:
ExecPty
,JniNativePty
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected abstract InputStream
protected abstract void
doSetAttr
(Attributes attr) Returns the terminal provider that created this PTY.Returns the input stream for the slave side of the PTY.Returns the system stream associated with this PTY, if any.protected static 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 Details
-
provider
-
systemStream
-
-
Constructor Details
-
AbstractPty
-
-
Method Details
-
setAttr
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:
IOException
- if an I/O error occurs- See Also:
-
getSlaveInput
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:
IOException
- if an I/O error occurs
-
doSetAttr
- Throws:
IOException
-
doGetSlaveInput
- Throws:
IOException
-
checkInterrupted
- Throws:
InterruptedIOException
-
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:
-
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:
-
newDescriptor
-