APIdia Launch Partner
Top Description Inners Fields Methods
jdk.internal.org.jline.terminal

public Interface Terminal

extends Closeable, Flushable
Known Direct Subinterfaces
jdk.internal.org.jline.terminal.spi.TerminalExt
Imports
java.io.Closeable, .Flushable, .InputStream, .OutputStream, .PrintWriter, java.nio.charset.Charset, java.util.function.IntConsumer, .IntSupplier, jdk.internal.org.jline.terminal.impl.NativeSignalHandler, jdk.internal.org.jline.utils.ColorPalette, .InfoCmp.Capability, .NonBlockingReader

A terminal representing a virtual terminal on the computer. Terminals should be closed by calling the close() method in order to restore their original state.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
public static enum
Terminal.Signal

Types of signals.

public static interface
Terminal.SignalHandler

The SignalHandler defines the interface used to trap signals and perform specific behaviors.

Field Summary

Modifier and TypeField and Description
public static final String
TYPE_DUMB

Type used for dumb terminals.

public static final String

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether this terminal supports pause() and resume() calls.
canPauseResume
()

Whether this terminal supports pause() and resume() calls.

public boolean
echo()

public boolean
echo(boolean echo)

public Charset

Returns:

The terminal encoding
encoding
()

Returns the Charset that should be used to encode characters for input() and output().

public Attributes
public void
flush()

Redeclares java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

public Attributes

Returns:

the terminal attributes.
getAttributes
()

Returns the terminal attributes.

public boolean
public default Size

Returns:

the terminal buffer size
getBufferSize
()

Retrieve the size of the window buffer.

public Cursor

Returns:

null if cursor position reporting is not supported or a valid cursor position
getCursorPosition
(IntConsumer
a consumer receiving discarded characters
discarded
)

Query the terminal to report the cursor position.

public default int
public String
public Integer
public ColorPalette
getPalette()

Color support

public Size

Returns:

the visible terminal size
getSize
()

Retrieve the size of the visible window

public String
public String
public default int
public Terminal.SignalHandler

Returns:

the previous signal handler
handle
(Terminal.Signal
the signal to register a handler for
signal
,
Terminal.SignalHandler
the handler
handler
)

Registers a handler for the given Signal.

public boolean

Returns:

whether focus tracking is supported by the terminal
hasFocusSupport
()

Returns true if the terminal has support for focus tracking.

public boolean

Returns:

whether mouse is supported by the terminal
hasMouseSupport
()

Returns true if the terminal has support for mouse.

public InputStream

Returns:

The input stream
input
()

Retrieve the input stream for this terminal.

public OutputStream

Returns:

The output stream
output
()

Retrieve the output stream for this terminal.

public void
pause()

Stop reading the input stream.

public void
pause(boolean
true to wait until the terminal is actually paused
wait
)

Stop reading the input stream and optionally wait for the underlying threads to finish.

public boolean

Returns:

whether the terminal is currently reading the input stream or not
paused
()

Check whether the terminal is currently reading the input stream or not.

public boolean
puts(InfoCmp.Capability capability, Object... params)

public void
raise(Terminal.Signal
the signal to raise
signal
)

Raise the specific signal.

public NonBlockingReader

Returns:

The non blocking reader
reader
()

Retrieve the Reader for this terminal.

public MouseEvent

Returns:

the decoded mouse event.
readMouseEvent
()

Read a MouseEvent from the terminal input stream.

public MouseEvent

Returns:

the decoded mouse event
readMouseEvent
(IntSupplier
the input supplier
reader
)

Read a MouseEvent from the given input stream.

public void
resume()

Resume reading the input stream.

public void
setAttributes(Attributes
the new attributes
attr
)

Set the terminal attributes.

public void
setSize(Size size)

public boolean

Returns:

true if focus tracking is supported
trackFocus
(boolean
whether the focus tracking mode should be enabled or not
tracking
)

Enable or disable focus tracking mode.

public boolean

Returns:

true if mouse tracking is supported
trackMouse
(Terminal.MouseTracking
the mouse tracking mode
tracking
)

Change the mouse tracking mouse.

public PrintWriter

Returns:

The writer
writer
()

Retrieve the Writer for this terminal.

Inherited from java.io.Closeable:
close

Field Detail

TYPE_DUMBback to summary
public static final String TYPE_DUMB

Type used for dumb terminals.

TYPE_DUMB_COLORback to summary
public static final String TYPE_DUMB_COLOR

Method Detail

canPauseResumeback to summary
public boolean canPauseResume()

Whether this terminal supports pause() and resume() calls.

Returns:boolean

whether this terminal supports pause() and resume() calls.

See Also
paused(), pause(), resume()
echoback to summary
public boolean echo()
echoback to summary
public boolean echo(boolean echo)
encodingback to summary
public Charset encoding()

Returns the Charset that should be used to encode characters for input() and output().

Returns:Charset

The terminal encoding

enterRawModeback to summary
public Attributes enterRawMode()
flushback to summary
public void flush()

Redeclares java.io.Flushable.flush.

Doc from java.io.Flushable.flush.

Flushes this stream by writing any buffered output to the underlying stream.

getAttributesback to summary
public Attributes getAttributes()

Returns the terminal attributes. The returned object can be safely modified further used in a call to setAttributes(Attributes).

Returns:Attributes

the terminal attributes.

getBooleanCapabilityback to summary
public boolean getBooleanCapability(InfoCmp.Capability capability)
getBufferSizeback to summary
public default Size getBufferSize()

Retrieve the size of the window buffer. Some terminals can be configured to have a buffer size larger than the visible window size and provide scroll bars. In such cases, this method should attempt to return the size of the whole buffer. The getBufferSize() method can be used to avoid wrapping when using the terminal in a line editing mode, while the getSize() method should be used when using full screen mode.

Returns:Size

the terminal buffer size

See Also
getSize()
getCursorPositionback to summary
public Cursor getCursorPosition(IntConsumer discarded)

Query the terminal to report the cursor position. As the response is read from the input stream, some characters may be read before the cursor position is actually read. Those characters can be given back using org.jline.keymap.BindingReader#runMacro(String)

Parameters
discarded:IntConsumer

a consumer receiving discarded characters

Returns:Cursor

null if cursor position reporting is not supported or a valid cursor position

getHeightback to summary
public default int getHeight()
getNameback to summary
public String getName()
getNumericCapabilityback to summary
public Integer getNumericCapability(InfoCmp.Capability capability)
getPaletteback to summary
public ColorPalette getPalette()

Color support

getSizeback to summary
public Size getSize()

Retrieve the size of the visible window

Returns:Size

the visible terminal size

See Also
getBufferSize()
getStringCapabilityback to summary
public String getStringCapability(InfoCmp.Capability capability)
getTypeback to summary
public String getType()
getWidthback to summary
public default int getWidth()
handleback to summary
public Terminal.SignalHandler handle(Terminal.Signal signal, Terminal.SignalHandler handler)

Registers a handler for the given Signal.

Note that the JVM does not easily allow catching the Signal#QUIT signal, which causes a thread dump to be displayed. This signal is mainly used when connecting through an SSH socket to a virtual terminal.

Parameters
signal:Terminal.Signal

the signal to register a handler for

handler:Terminal.SignalHandler

the handler

Returns:Terminal.SignalHandler

the previous signal handler

hasFocusSupportback to summary
public boolean hasFocusSupport()

Returns true if the terminal has support for focus tracking.

Returns:boolean

whether focus tracking is supported by the terminal

See Also
trackFocus(boolean)
hasMouseSupportback to summary
public boolean hasMouseSupport()

Returns true if the terminal has support for mouse.

Returns:boolean

whether mouse is supported by the terminal

See Also
trackMouse(MouseTracking)
inputback to summary
public InputStream input()

Retrieve the input stream for this terminal. In some rare cases, there may be a need to access the terminal input stream directly. In the usual cases, use the reader() instead.

Returns:InputStream

The input stream

See Also
reader()
outputback to summary
public OutputStream output()

Retrieve the output stream for this terminal. In some rare cases, there may be a need to access the terminal output stream directly. In the usual cases, use the writer() instead.

Returns:OutputStream

The output stream

See Also
writer()
pauseback to summary
public void pause()

Stop reading the input stream.

See Also
resume(), paused()
pauseback to summary
public void pause(boolean wait) throws InterruptedException

Stop reading the input stream and optionally wait for the underlying threads to finish.

Parameters
wait:boolean

true to wait until the terminal is actually paused

Exceptions
InterruptedException:
if the call has been interrupted
pausedback to summary
public boolean paused()

Check whether the terminal is currently reading the input stream or not. In order to process signal as quickly as possible, the terminal need to read the input stream and buffer it internally so that it can detect specific characters in the input stream (Ctrl+C, Ctrl+D, etc...) and raise the appropriate signals. However, there are some cases where this processing should be disabled, for example when handing the terminal control to a subprocess.

Returns:boolean

whether the terminal is currently reading the input stream or not

See Also
pause(), resume()
putsback to summary
public boolean puts(InfoCmp.Capability capability, Object... params)
raiseback to summary
public void raise(Terminal.Signal signal)

Raise the specific signal. This is not method usually called by non system terminals. When accessing a terminal through a SSH or Telnet connection, signals may be conveyed by the protocol and thus need to be raised when reaching the terminal code. The terminals do that automatically when the terminal input stream has a character mapped to Attributes.ControlChar#VINTR, Attributes.ControlChar#VQUIT, or Attributes.ControlChar#VSUSP.

Parameters
signal:Terminal.Signal

the signal to raise

readerback to summary
public NonBlockingReader reader()

Retrieve the Reader for this terminal. This is the standard way to read input from this terminal. The reader is non blocking.

Returns:NonBlockingReader

The non blocking reader

readMouseEventback to summary
public MouseEvent readMouseEvent()

Read a MouseEvent from the terminal input stream. Such an event must have been detected by scanning the terminal's Capability#key_mouse in the stream immediately before reading the event.

Returns:MouseEvent

the decoded mouse event.

See Also
trackMouse(MouseTracking)
readMouseEventback to summary
public MouseEvent readMouseEvent(IntSupplier reader)

Read a MouseEvent from the given input stream.

Parameters
reader:IntSupplier

the input supplier

Returns:MouseEvent

the decoded mouse event

resumeback to summary
public void resume()

Resume reading the input stream.

See Also
pause(), paused()
setAttributesback to summary
public void setAttributes(Attributes attr)

Set the terminal attributes. The terminal will perform a copy of the given attributes.

Parameters
attr:Attributes

the new attributes

setSizeback to summary
public void setSize(Size size)
trackFocusback to summary
public boolean trackFocus(boolean tracking)

Enable or disable focus tracking mode. When focus tracking has been activated, each time the terminal grabs the focus, the string "\33[I" will be sent to the input stream and each time the focus is lost, the string "\33[O" will be sent to the input stream.

Parameters
tracking:boolean

whether the focus tracking mode should be enabled or not

Returns:boolean

true if focus tracking is supported

trackMouseback to summary
public boolean trackMouse(Terminal.MouseTracking tracking)

Change the mouse tracking mouse. To start mouse tracking, this method must be called with a valid mouse tracking mode. Mouse events will be reported by writing the Capability#key_mouse to the input stream. When this character sequence is detected, the readMouseEvent() method can be called to actually read the corresponding mouse event.

Parameters
tracking:Terminal.MouseTracking

the mouse tracking mode

Returns:boolean

true if mouse tracking is supported

writerback to summary
public PrintWriter writer()

Retrieve the Writer for this terminal. This is the standard way to write to this terminal.

Returns:PrintWriter

The writer

jdk.internal.org.jline.terminal back to summary

public final Enum Terminal.MouseTracking

extends Enum<Terminal.MouseTracking>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final Terminal.MouseTracking
Any

Report all motions events, even if no mouse button is down.

public static final Terminal.MouseTracking
Button

Also report button-motion events.

public static final Terminal.MouseTracking
Normal

Track button press and release.

public static final Terminal.MouseTracking
Off

Disable mouse tracking

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Terminal.MouseTracking
public static Terminal.MouseTracking[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

Anyback to summary
public static final Terminal.MouseTracking Any

Report all motions events, even if no mouse button is down.

Buttonback to summary
public static final Terminal.MouseTracking Button

Also report button-motion events. Mouse movements are reported if the mouse pointer has moved to a different character cell.

Normalback to summary
public static final Terminal.MouseTracking Normal

Track button press and release.

Offback to summary
public static final Terminal.MouseTracking Off

Disable mouse tracking

Constructor Detail

MouseTrackingback to summary
private MouseTracking()

Method Detail

valueOfback to summary
public static Terminal.MouseTracking valueOf(String name)
valuesback to summary
public static Terminal.MouseTracking[] values()
jdk.internal.org.jline.terminal back to summary

public final Enum Terminal.Signal

extends Enum<Terminal.Signal>
Class Inheritance

Types of signals.

Field Summary

Modifier and TypeField and Description
public static final Terminal.Signal
public static final Terminal.Signal
public static final Terminal.Signal
public static final Terminal.Signal
public static final Terminal.Signal
public static final Terminal.Signal

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Terminal.Signal
public static Terminal.Signal[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CONTback to summary
public static final Terminal.Signal CONT
INFOback to summary
public static final Terminal.Signal INFO
INTback to summary
public static final Terminal.Signal INT
QUITback to summary
public static final Terminal.Signal QUIT
TSTPback to summary
public static final Terminal.Signal TSTP
WINCHback to summary
public static final Terminal.Signal WINCH

Constructor Detail

Signalback to summary
private Signal()

Method Detail

valueOfback to summary
public static Terminal.Signal valueOf(String name)
valuesback to summary
public static Terminal.Signal[] values()
jdk.internal.org.jline.terminal back to summary

public Interface Terminal.SignalHandler

Known Direct Implementers
jdk.internal.org.jline.terminal.impl.NativeSignalHandler

The SignalHandler defines the interface used to trap signals and perform specific behaviors.
See Also
Terminal.Signal, Terminal#handle(Signal, SignalHandler)

Field Summary

Modifier and TypeField and Description
public static final Terminal.SignalHandler
SIG_DFL

The SIG_DFL value can be used to specify that the JVM default behavior should be used to handle this signal.

public static final Terminal.SignalHandler
SIG_IGN

The SIG_IGN value can be used to ignore this signal and not perform any special processing.

Method Summary

Modifier and TypeMethod and Description
public void
handle(Terminal.Signal
the signal
signal
)

Handle the signal.

Field Detail

SIG_DFLback to summary
public static final Terminal.SignalHandler SIG_DFL

The SIG_DFL value can be used to specify that the JVM default behavior should be used to handle this signal.

SIG_IGNback to summary
public static final Terminal.SignalHandler SIG_IGN

The SIG_IGN value can be used to ignore this signal and not perform any special processing.

Method Detail

handleback to summary
public void handle(Terminal.Signal signal)

Handle the signal.

Parameters
signal:Terminal.Signal

the signal