public final class TerminalBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
PROP_CODEPAGE |
static String |
PROP_COLOR_DISTANCE |
static String |
PROP_DISABLE_ALTERNATE_CHARSET |
static String |
PROP_DUMB |
static String |
PROP_DUMB_COLOR |
static String |
PROP_ENCODING |
static String |
PROP_EXEC |
static String |
PROP_JANSI |
static String |
PROP_JNA |
static String |
PROP_NON_BLOCKING_READS |
static String |
PROP_TYPE |
| Modifier and Type | Method and Description |
|---|---|
TerminalBuilder |
attributes(Attributes attributes)
Attributes to use when creating a non system terminal,
i.e.
|
Terminal |
build() |
static TerminalBuilder |
builder()
Creates a new terminal builder instance.
|
TerminalBuilder |
codepage(int 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 for
Terminal.input() and Terminal.output(). |
TerminalBuilder |
dumb(boolean dumb) |
TerminalBuilder |
encoding(Charset encoding)
Set the
Charset to use for reading/writing from the console. |
TerminalBuilder |
encoding(String encoding)
Set the encoding to use for reading/writing from the console.
|
TerminalBuilder |
exec(boolean exec) |
TerminalBuilder |
jansi(boolean jansi) |
TerminalBuilder |
jna(boolean jna) |
TerminalBuilder |
name(String name) |
TerminalBuilder |
nativeSignals(boolean nativeSignals) |
TerminalBuilder |
paused(boolean paused)
Initial paused state of the terminal (defaults to false).
|
static void |
setTerminalOverride(Terminal terminal)
Deprecated.
|
TerminalBuilder |
signalHandler(Terminal.SignalHandler signalHandler) |
TerminalBuilder |
size(Size size)
Initial size to use when creating a non system terminal,
i.e.
|
TerminalBuilder |
streams(InputStream in,
OutputStream out) |
TerminalBuilder |
system(boolean system) |
static Terminal |
terminal()
Returns the default system terminal.
|
TerminalBuilder |
type(String type) |
public static final String PROP_ENCODING
public static final String PROP_CODEPAGE
public static final String PROP_TYPE
public static final String PROP_JNA
public static final String PROP_JANSI
public static final String PROP_EXEC
public static final String PROP_DUMB
public static final String PROP_DUMB_COLOR
public static final String PROP_NON_BLOCKING_READS
public static final String PROP_COLOR_DISTANCE
public static final String PROP_DISABLE_ALTERNATE_CHARSET
public static Terminal terminal() throws IOException
Closeable.close()
method in order to restore the original terminal state.
This call is equivalent to:
builder().build()
IOException - if an error occurspublic static TerminalBuilder builder()
public TerminalBuilder name(String name)
public TerminalBuilder streams(InputStream in, OutputStream out)
public TerminalBuilder system(boolean system)
public TerminalBuilder jna(boolean jna)
public TerminalBuilder jansi(boolean jansi)
public TerminalBuilder exec(boolean exec)
public TerminalBuilder dumb(boolean dumb)
public TerminalBuilder type(String type)
public TerminalBuilder encoding(String encoding) throws UnsupportedCharsetException
null (the default value), JLine will automatically select
a Charset, usually the default system encoding. However,
on some platforms (e.g. Windows) it may use a different one depending
on the Terminal implementation.
Use Terminal.encoding() to get the Charset that
should be used for a Terminal.
encoding - The encoding to use or null to automatically select oneUnsupportedCharsetException - If the given encoding is not supportedTerminal.encoding()public TerminalBuilder encoding(Charset encoding)
Charset to use for reading/writing from the console.
If null (the default value), JLine will automatically select
a Charset, usually the default system encoding. However,
on some platforms (e.g. Windows) it may use a different one depending
on the Terminal implementation.
Use Terminal.encoding() to get the Charset that
should be used to read/write from a Terminal.
encoding - The encoding to use or null to automatically select oneTerminal.encoding()@Deprecated public TerminalBuilder codepage(int codepage)
Terminal.input() and Terminal.output().codepage - the codepagepublic TerminalBuilder attributes(Attributes attributes)
streams(InputStream, OutputStream) method
or when system(boolean) has been explicitly called with
false.attributes - the attributes to usesize(Size),
system(boolean)public TerminalBuilder size(Size size)
streams(InputStream, OutputStream) method
or when system(boolean) has been explicitly called with
false.size - the initial sizeattributes(Attributes),
system(boolean)public TerminalBuilder nativeSignals(boolean nativeSignals)
public TerminalBuilder signalHandler(Terminal.SignalHandler signalHandler)
public TerminalBuilder paused(boolean paused)
paused - the initial paused stateTerminal.pause()public Terminal build() throws IOException
IOException@Deprecated public static void setTerminalOverride(Terminal terminal)
build(). 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
the LineReader of the Terminal. For example, the sbt
build tool uses a LineReader to implement an interactive shell.
One of its supported commands is console which invokes
the scala REPL. The scala REPL also uses a LineReader and it
is necessary to override the Terminal used by the the REPL to
share the same Terminal instance used by sbt.
When this method is called with a non-null Terminal, all subsequent
calls to build() will return the provided Terminal regardless
of how the TerminalBuilder was constructed. The default behavior
of TerminalBuilder can be restored by calling setTerminalOverride
with a null Terminal
Usage of setTerminalOverride should be restricted to cases where it
isn't possible to update the api of the nested application to accept
a instance.
terminal - the Terminal to globally overrideCopyright © 2020. All rights reserved.