Package org.jline.terminal.impl
Class AbstractTerminal
java.lang.Object
org.jline.terminal.impl.AbstractTerminal
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,TerminalExt
,Terminal
- Direct Known Subclasses:
AbstractPosixTerminal
,AbstractWindowsTerminal
,DumbTerminal
,LineDisciplineTerminal
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jline.terminal.Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
-
Field Summary
Modifier and TypeFieldDescriptionprotected final Set
<InfoCmp.Capability> protected final Charset
protected final Map
<Terminal.Signal, Terminal.SignalHandler> protected final Map
<InfoCmp.Capability, Integer> protected final String
protected Runnable
protected final ColorPalette
protected Status
protected final Map
<InfoCmp.Capability, String> protected final String
Fields inherited from interface org.jline.terminal.Terminal
TYPE_DUMB, TYPE_DUMB_COLOR
-
Constructor Summary
ConstructorDescriptionAbstractTerminal
(String name, String type) AbstractTerminal
(String name, String type, Charset encoding, Terminal.SignalHandler signalHandler) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether this terminal supportsTerminal.pause()
andTerminal.resume()
calls.protected void
final void
close()
protected void
doClose()
boolean
echo()
boolean
echo
(boolean echo) protected void
echoSignal
(Terminal.Signal signal) encoding()
Returns theCharset
that should be used to encode characters forTerminal.input()
andTerminal.output()
.void
flush()
boolean
getBooleanCapability
(InfoCmp.Capability capability) getCursorPosition
(IntConsumer discarded) Query the terminal to report the cursor position.getKind()
getName()
getNumericCapability
(InfoCmp.Capability capability) Color supportgetStatus
(boolean create) getStringCapability
(InfoCmp.Capability capability) getType()
handle
(Terminal.Signal signal, Terminal.SignalHandler handler) Registers a handler for the givenTerminal.Signal
.boolean
Returnstrue
if the terminal has support for focus tracking.boolean
Returnstrue
if the terminal has support for mouse.protected void
void
pause()
Stop reading the input stream.void
pause
(boolean wait) Stop reading the input stream and optionally wait for the underlying threads to finish.boolean
paused()
Check whether the terminal is currently reading the input stream or not.boolean
puts
(InfoCmp.Capability capability, Object... params) void
raise
(Terminal.Signal signal) Read a MouseEvent from the terminal input stream.readMouseEvent
(IntSupplier reader) Read a MouseEvent from the given input stream.void
resume()
Resume reading the input stream.void
setOnClose
(Runnable onClose) boolean
trackFocus
(boolean tracking) Enable or disable focus tracking mode.boolean
trackMouse
(Terminal.MouseTracking tracking) Change the mouse tracking mouse.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.Terminal
getAttributes, getBufferSize, getHeight, getSize, getWidth, input, output, reader, setAttributes, setSize, writer
Methods inherited from interface org.jline.terminal.spi.TerminalExt
getProvider, getSystemStream
-
Field Details
-
name
-
type
-
encoding
-
handlers
-
bools
-
ints
-
strings
-
palette
-
status
-
onClose
-
-
Constructor Details
-
AbstractTerminal
- Throws:
IOException
-
AbstractTerminal
public AbstractTerminal(String name, String type, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException - Throws:
IOException
-
-
Method Details
-
setOnClose
-
getStatus
-
getStatus
-
handle
Description copied from interface:Terminal
Registers a handler for the givenTerminal.Signal
.Note that the JVM does not easily allow catching the
Terminal.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. -
raise
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
doClose
- Throws:
IOException
-
echoSignal
-
enterRawMode
- Specified by:
enterRawMode
in interfaceTerminal
-
echo
public boolean echo() -
echo
public boolean echo(boolean echo) -
getName
-
getType
-
getKind
-
encoding
Description copied from interface:Terminal
Returns theCharset
that should be used to encode characters forTerminal.input()
andTerminal.output()
. -
flush
public void flush() -
puts
-
getBooleanCapability
- Specified by:
getBooleanCapability
in interfaceTerminal
-
getNumericCapability
- Specified by:
getNumericCapability
in interfaceTerminal
-
getStringCapability
- Specified by:
getStringCapability
in interfaceTerminal
-
parseInfoCmp
protected void parseInfoCmp() -
getCursorPosition
Description copied from interface:Terminal
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 usingorg.jline.keymap.BindingReader#runMacro(String)
- Specified by:
getCursorPosition
in interfaceTerminal
- Parameters:
discarded
- a consumer receiving discarded characters- Returns:
null
if cursor position reporting is not supported or a valid cursor position
-
hasMouseSupport
public boolean hasMouseSupport()Description copied from interface:Terminal
Returnstrue
if the terminal has support for mouse.- Specified by:
hasMouseSupport
in interfaceTerminal
- Returns:
- whether mouse is supported by the terminal
- See Also:
-
trackMouse
Description copied from interface:Terminal
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 theInfoCmp.Capability.key_mouse
to the input stream. When this character sequence is detected, theTerminal.readMouseEvent()
method can be called to actually read the corresponding mouse event.- Specified by:
trackMouse
in interfaceTerminal
- Parameters:
tracking
- the mouse tracking mode- Returns:
true
if mouse tracking is supported
-
readMouseEvent
Description copied from interface:Terminal
Read a MouseEvent from the terminal input stream. Such an event must have been detected by scanning the terminal'sInfoCmp.Capability.key_mouse
in the stream immediately before reading the event.- Specified by:
readMouseEvent
in interfaceTerminal
- Returns:
- the decoded mouse event.
- See Also:
-
readMouseEvent
Description copied from interface:Terminal
Read a MouseEvent from the given input stream.- Specified by:
readMouseEvent
in interfaceTerminal
- Parameters:
reader
- the input supplier- Returns:
- the decoded mouse event
-
hasFocusSupport
public boolean hasFocusSupport()Description copied from interface:Terminal
Returnstrue
if the terminal has support for focus tracking.- Specified by:
hasFocusSupport
in interfaceTerminal
- Returns:
- whether focus tracking is supported by the terminal
- See Also:
-
trackFocus
public boolean trackFocus(boolean tracking) Description copied from interface:Terminal
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.- Specified by:
trackFocus
in interfaceTerminal
- Parameters:
tracking
- whether the focus tracking mode should be enabled or not- Returns:
true
if focus tracking is supported
-
checkInterrupted
- Throws:
InterruptedIOException
-
canPauseResume
public boolean canPauseResume()Description copied from interface:Terminal
Whether this terminal supportsTerminal.pause()
andTerminal.resume()
calls.- Specified by:
canPauseResume
in interfaceTerminal
- Returns:
- whether this terminal supports
Terminal.pause()
andTerminal.resume()
calls. - See Also:
-
pause
public void pause()Description copied from interface:Terminal
Stop reading the input stream. -
pause
Description copied from interface:Terminal
Stop reading the input stream and optionally wait for the underlying threads to finish.- Specified by:
pause
in interfaceTerminal
- Parameters:
wait
-true
to wait until the terminal is actually paused- Throws:
InterruptedException
- if the call has been interrupted
-
resume
public void resume()Description copied from interface:Terminal
Resume reading the input stream. -
paused
public boolean paused()Description copied from interface:Terminal
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. -
getPalette
Description copied from interface:Terminal
Color support- Specified by:
getPalette
in interfaceTerminal
-