Package org.jline.terminal
Class TerminalBuilder
java.lang.Object
org.jline.terminal.TerminalBuilder
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Method Summary
Modifier and TypeMethodDescriptionattributes(Attributes attributes) Attributes to use when creating a non system terminal, i.e. when the builder has been given the input and output streams using thestreams(InputStream, OutputStream)method or whensystem(boolean)has been explicitly called withfalse.build()Builds the terminal.static TerminalBuilderbuilder()Creates a new terminal builder instance.codepage(int codepage) Deprecated.JLine now writes Unicode output independently from the selected code page.color(boolean color) dumb(boolean dumb) Enables or disables thePROP_PROVIDER_DUMB/dumbterminal provider.Set the encoding to use for reading/writing from the console.Set theCharsetto use for reading/writing from the console.exec(boolean exec) Enables or disables thePROP_PROVIDER_EXEC/execterminal provider.ffm(boolean ffm) Enables or disables thePROP_PROVIDER_FFM/ffmterminal provider.getProviders(String provider, IllegalStateException exception) Get the list of available terminal providers.jansi(boolean jansi) Enables or disables thePROP_PROVIDER_JANSI/jansiterminal provider.jna(boolean jna) Enables or disables thePROP_PROVIDER_JNA/jnaterminal provider.jni(boolean jni) Enables or disables thePROP_PROVIDER_JNI/jniterminal provider.nativeSignals(boolean nativeSignals) paused(boolean paused) Initial paused state of the terminal (defaults to false).Forces the usage of the give terminal provider.Sets the list of providers to try when creating the terminal.static voidsetTerminalOverride(Terminal terminal) Deprecated.signalHandler(Terminal.SignalHandler signalHandler) Determines the default value for signal handlers.Initial size to use when creating a non system terminal, i.e. when the builder has been given the input and output streams using thestreams(InputStream, OutputStream)method or whensystem(boolean)has been explicitly called withfalse.streams(InputStream in, OutputStream out) system(boolean system) systemOutput(TerminalBuilder.SystemOutput systemOutput) Indicates which standard stream should be used when displaying to the terminal.static Terminalterminal()Returns the default system terminal.
-
Field Details
-
PROP_ENCODING
- See Also:
-
PROP_CODEPAGE
- See Also:
-
PROP_TYPE
- See Also:
-
PROP_PROVIDER
- See Also:
-
PROP_PROVIDERS
- See Also:
-
PROP_PROVIDER_FFM
- See Also:
-
PROP_PROVIDER_JNI
- See Also:
-
PROP_PROVIDER_JANSI
- See Also:
-
PROP_PROVIDER_JNA
- See Also:
-
PROP_PROVIDER_EXEC
- See Also:
-
PROP_PROVIDER_DUMB
- See Also:
-
PROP_PROVIDERS_DEFAULT
-
PROP_FFM
- See Also:
-
PROP_JNI
- See Also:
-
PROP_JANSI
- See Also:
-
PROP_JNA
- See Also:
-
PROP_EXEC
- See Also:
-
PROP_DUMB
- See Also:
-
PROP_DUMB_COLOR
- See Also:
-
PROP_OUTPUT
- See Also:
-
PROP_OUTPUT_OUT
- See Also:
-
PROP_OUTPUT_ERR
- See Also:
-
PROP_OUTPUT_OUT_ERR
- See Also:
-
PROP_OUTPUT_ERR_OUT
- See Also:
-
PROP_OUTPUT_FORCED_OUT
- See Also:
-
PROP_OUTPUT_FORCED_ERR
- See Also:
-
PROP_NON_BLOCKING_READS
- See Also:
-
PROP_COLOR_DISTANCE
- See Also:
-
PROP_DISABLE_ALTERNATE_CHARSET
- See Also:
-
PROP_FILE_DESCRIPTOR_CREATION_MODE
- See Also:
-
PROP_FILE_DESCRIPTOR_CREATION_MODE_NATIVE
- See Also:
-
PROP_FILE_DESCRIPTOR_CREATION_MODE_REFLECTION
- See Also:
-
PROP_FILE_DESCRIPTOR_CREATION_MODE_DEFAULT
-
PROP_REDIRECT_PIPE_CREATION_MODE
- See Also:
-
PROP_REDIRECT_PIPE_CREATION_MODE_NATIVE
- See Also:
-
PROP_REDIRECT_PIPE_CREATION_MODE_REFLECTION
- See Also:
-
PROP_REDIRECT_PIPE_CREATION_MODE_DEFAULT
-
DEPRECATED_PROVIDERS
-
PROP_DISABLE_DEPRECATED_PROVIDER_WARNING
- See Also:
-
-
Method Details
-
terminal
Returns the default system terminal. Terminals should be closed properly using theCloseable.close()method in order to restore the original terminal state.This call is equivalent to:
builder().build()- Returns:
- the default system terminal
- Throws:
IOException- if an error occurs
-
builder
-
name
-
streams
-
system
-
systemOutput
Indicates which standard stream should be used when displaying to the terminal. The default is to use the system output stream. Building a system terminal will fail if one of the stream specified is not linked to the controlling terminal.- Parameters:
systemOutput- The mode to choose the output stream.- Returns:
- The builder.
-
provider
Forces the usage of the give terminal provider.- Parameters:
provider- TheTerminalProvider's name to use when creating the Terminal.- Returns:
- The builder.
-
providers
Sets the list of providers to try when creating the terminal. If not specified, the system propertyPROP_PROVIDERSwill be used if set. Else, the valuePROP_PROVIDERS_DEFAULTwill be used.- Parameters:
providers- The list ofTerminalProvider's names to check when creating the Terminal.- Returns:
- The builder.
-
jna
Enables or disables thePROP_PROVIDER_JNA/jnaterminal provider. If not specified, the system propertyPROP_JNAwill be used if set. If not specified, the provider will be checked. -
jansi
Enables or disables thePROP_PROVIDER_JANSI/jansiterminal provider. If not specified, the system propertyPROP_JANSIwill be used if set. If not specified, the provider will be checked. -
jni
Enables or disables thePROP_PROVIDER_JNI/jniterminal provider. If not specified, the system propertyPROP_JNIwill be used if set. If not specified, the provider will be checked. -
exec
Enables or disables thePROP_PROVIDER_EXEC/execterminal provider. If not specified, the system propertyPROP_EXECwill be used if set. If not specified, the provider will be checked. -
ffm
Enables or disables thePROP_PROVIDER_FFM/ffmterminal provider. If not specified, the system propertyPROP_FFMwill be used if set. If not specified, the provider will be checked. -
dumb
Enables or disables thePROP_PROVIDER_DUMB/dumbterminal provider. If not specified, the system propertyPROP_DUMBwill be used if set. If not specified, the provider will be checked. -
type
-
color
-
encoding
Set the encoding to use for reading/writing from the console. Ifnull(the default value), JLine will automatically select aCharset, usually the default system encoding. However, on some platforms (e.g. Windows) it may use a different one depending on theTerminalimplementation.Use
Terminal.encoding()to get theCharsetthat should be used for aTerminal.- Parameters:
encoding- The encoding to use or null to automatically select one- Returns:
- The builder
- Throws:
UnsupportedCharsetException- If the given encoding is not supported- See Also:
-
encoding
Set theCharsetto use for reading/writing from the console. Ifnull(the default value), JLine will automatically select aCharset, usually the default system encoding. However, on some platforms (e.g. Windows) it may use a different one depending on theTerminalimplementation.Use
Terminal.encoding()to get theCharsetthat should be used to read/write from aTerminal.- Parameters:
encoding- The encoding to use or null to automatically select one- Returns:
- The builder
- See Also:
-
codepage
Deprecated.JLine now writes Unicode output independently from the selected code page. Using this option will only make it emulate the selected code page forTerminal.input()andTerminal.output().- Parameters:
codepage- the codepage- Returns:
- The builder
-
attributes
Attributes to use when creating a non system terminal, i.e. when the builder has been given the input and output streams using thestreams(InputStream, OutputStream)method or whensystem(boolean)has been explicitly called withfalse.- Parameters:
attributes- the attributes to use- Returns:
- The builder
- See Also:
-
size
Initial size to use when creating a non system terminal, i.e. when the builder has been given the input and output streams using thestreams(InputStream, OutputStream)method or whensystem(boolean)has been explicitly called withfalse.- Parameters:
size- the initial size- Returns:
- The builder
- See Also:
-
nativeSignals
-
signalHandler
Determines the default value for signal handlers. All signals will be mapped to the given handler.- Parameters:
signalHandler- the default signal handler- Returns:
- The builder
-
paused
Initial paused state of the terminal (defaults to false). By default, the terminal is started, but in some cases, one might want to make sure the input stream is not consumed before needed, in which case the terminal needs to be created in a paused state.- Parameters:
paused- the initial paused state- Returns:
- The builder
- See Also:
-
build
Builds the terminal.- Returns:
- the newly created terminal, never
null - Throws:
IOException- if an error occurs
-
computeSystemOutput
-
computeType
-
computeEncoding
-
getProviders
Get the list of available terminal providers. This list is sorted according to thePROP_PROVIDERSsystem property.- Parameters:
provider- if notnull, only this provider will be checkedexception- if a provider throws an exception, it will be added to this exception as a suppressed exception- Returns:
- a list of terminal providers
-
setTerminalOverride
Deprecated.Allows an application to override the result ofbuild(). The intended use case is to allow a container or server application to control an embedded application that uses a LineReader that uses Terminal constructed with TerminalBuilder.build but provides no public api for setting theLineReaderof theTerminal. For example, the sbt build tool uses aLineReaderto implement an interactive shell. One of its supported commands isconsolewhich invokes the scala REPL. The scala REPL also uses aLineReaderand it is necessary to override theTerminalused by the the REPL to share the sameTerminalinstance used by sbt.When this method is called with a non-null
Terminal, all subsequent calls tobuild()will return the providedTerminalregardless of how theTerminalBuilderwas constructed. The default behavior ofTerminalBuildercan be restored by calling setTerminalOverride with a nullTerminalUsage of setTerminalOverride should be restricted to cases where it isn't possible to update the api of the nested application to accept a
instance.- Parameters:
terminal- theTerminalto globally override
-