Interface TerminalProvider
- All Known Implementing Classes:
DumbTerminalProvider
,ExecTerminalProvider
,JniTerminalProvider
The TerminalProvider interface defines the contract for classes that can create and manage terminal instances on specific platforms. Each provider implements platform-specific terminal functionality, allowing JLine to work across different operating systems and environments.
JLine includes several built-in terminal providers:
- FFM - Foreign Function Memory (Java 22+) based implementation
- JNI - Java Native Interface based implementation
- Jansi - Implementation based on the Jansi library
- JNA - Java Native Access based implementation
- Exec - Implementation using external commands
- Dumb - Fallback implementation with limited capabilities
Terminal providers are loaded dynamically using the load(String)
method,
which looks up provider implementations in the classpath based on their name.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
isSystemStream
(SystemStream stream) Checks if the specified system stream is available on this platform.static TerminalProvider
Loads a terminal provider with the specified name.name()
Returns the name of this terminal provider.newTerminal
(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Charset stdinEncoding, Charset stdoutEncoding, Charset stderrEncoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) Creates a new terminal with custom input and output streams.default Terminal
newTerminal
(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) Deprecated.systemStreamName
(SystemStream stream) Returns the name of the specified system stream on this platform.int
systemStreamWidth
(SystemStream stream) Returns the width (number of columns) of the specified system stream.default Terminal
sysTerminal
(String name, String type, boolean ansiPassThrough, Charset encoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, boolean paused, SystemStream systemStream) sysTerminal
(String name, String type, boolean ansiPassThrough, Charset encoding, Charset stdinEncoding, Charset stdoutEncoding, Charset stderrEncoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, boolean paused, SystemStream systemStream) Creates a terminal connected to a system stream.
-
Method Details
-
name
String name()Returns the name of this terminal provider.The provider name is a unique identifier that can be used to request this specific provider when creating terminals. Common provider names include "ffm", "jni", "jansi", "jna", "exec", and "dumb".
- Returns:
- the name of this terminal provider
-
sysTerminal
@Deprecated default Terminal sysTerminal(String name, String type, boolean ansiPassThrough, Charset encoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, boolean paused, SystemStream systemStream) throws IOException Deprecated.Creates a terminal connected to a system stream.This method creates a terminal that is connected to one of the standard system streams (standard input, standard output, or standard error). Such terminals typically represent the actual terminal window or console that the application is running in.
- Parameters:
name
- the name of the terminaltype
- the terminal type (e.g., "xterm", "dumb")ansiPassThrough
- whether to pass through ANSI escape sequencesencoding
- the character encoding to usenativeSignals
- whether to use native signal handlingsignalHandler
- the signal handler to usepaused
- whether the terminal should start in a paused statesystemStream
- the system stream to connect to- Returns:
- a new terminal connected to the specified system stream
- Throws:
IOException
- if an I/O error occurs
-
sysTerminal
Terminal sysTerminal(String name, String type, boolean ansiPassThrough, Charset encoding, Charset stdinEncoding, Charset stdoutEncoding, Charset stderrEncoding, boolean nativeSignals, Terminal.SignalHandler signalHandler, boolean paused, SystemStream systemStream) throws IOException Creates a terminal connected to a system stream.This method creates a terminal that is connected to one of the standard system streams (standard input, standard output, or standard error). Such terminals typically represent the actual terminal window or console that the application is running in.
- Parameters:
name
- the name of the terminaltype
- the terminal type (e.g., "xterm", "dumb")ansiPassThrough
- whether to pass through ANSI escape sequencesencoding
- the general character encoding to usestdinEncoding
- the character encoding to use for standard inputstdoutEncoding
- the character encoding to use for standard outputstderrEncoding
- the character encoding to use for standard errornativeSignals
- whether to use native signal handlingsignalHandler
- the signal handler to usepaused
- whether the terminal should start in a paused statesystemStream
- the system stream to connect to- Returns:
- a new terminal connected to the specified system stream
- Throws:
IOException
- if an I/O error occurs
-
newTerminal
@Deprecated default Terminal newTerminal(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) throws IOException Deprecated.Creates a new terminal with custom input and output streams.This method creates a terminal that is connected to the specified input and output streams. Such terminals can be used for various purposes, such as connecting to remote terminals over network connections or creating virtual terminals for testing.
- Parameters:
name
- the name of the terminaltype
- the terminal type (e.g., "xterm", "dumb")masterInput
- the input stream to read frommasterOutput
- the output stream to write toencoding
- the character encoding to usesignalHandler
- the signal handler to usepaused
- whether the terminal should start in a paused stateattributes
- the initial terminal attributessize
- the initial terminal size- Returns:
- a new terminal connected to the specified streams
- Throws:
IOException
- if an I/O error occurs
-
newTerminal
Terminal newTerminal(String name, String type, InputStream masterInput, OutputStream masterOutput, Charset encoding, Charset stdinEncoding, Charset stdoutEncoding, Charset stderrEncoding, Terminal.SignalHandler signalHandler, boolean paused, Attributes attributes, Size size) throws IOException Creates a new terminal with custom input and output streams.This method creates a terminal that is connected to the specified input and output streams. Such terminals can be used for various purposes, such as connecting to remote terminals over network connections or creating virtual terminals for testing.
- Parameters:
name
- the name of the terminaltype
- the terminal type (e.g., "xterm", "dumb")masterInput
- the input stream to read frommasterOutput
- the output stream to write toencoding
- the general character encoding to usestdinEncoding
- the character encoding to use for standard inputstdoutEncoding
- the character encoding to use for standard outputstderrEncoding
- the character encoding to use for standard errorsignalHandler
- the signal handler to usepaused
- whether the terminal should start in a paused stateattributes
- the initial terminal attributessize
- the initial terminal size- Returns:
- a new terminal connected to the specified streams
- Throws:
IOException
- if an I/O error occurs
-
isSystemStream
Checks if the specified system stream is available on this platform.This method determines whether the specified system stream (standard input, standard output, or standard error) is available for use on the current platform. Some platforms or environments may restrict access to certain system streams.
- Parameters:
stream
- the system stream to check- Returns:
true
if the system stream is available,false
otherwise
-
systemStreamName
Returns the name of the specified system stream on this platform.This method returns a platform-specific name or identifier for the specified system stream. The name may be used for display purposes or for accessing the stream through platform-specific APIs.
- Parameters:
stream
- the system stream- Returns:
- the name of the system stream on this platform
-
systemStreamWidth
Returns the width (number of columns) of the specified system stream.This method determines the width of the terminal associated with the specified system stream. The width is measured in character cells and represents the number of columns available for display.
- Parameters:
stream
- the system stream- Returns:
- the width of the system stream in character columns
-
load
Loads a terminal provider with the specified name.This method loads a terminal provider implementation based on its name. Provider implementations are discovered through the Java ServiceLoader mechanism, looking for resource files in the classpath at
META-INF/services/org/jline/terminal/provider/[name]
.Each provider resource file should contain a
class
property that specifies the fully qualified name of the provider implementation class.- Parameters:
name
- the name of the provider to load- Returns:
- the loaded terminal provider
- Throws:
IOException
- if the provider cannot be loaded
-
newTerminal(String, String, InputStream, OutputStream, Charset, Charset, Charset, Charset, Terminal.SignalHandler, boolean, Attributes, Size)
instead