Closeable
, Flushable
, AutoCloseable
, Terminal
AbstractPosixTerminal
, AbstractWindowsTerminal
, DumbTerminal
, LineDisciplineTerminal
public abstract class AbstractTerminal extends Object implements Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler
Modifier and Type | Field | Description |
---|---|---|
protected Set<InfoCmp.Capability> |
bools |
|
protected Charset |
encoding |
|
protected Map<Terminal.Signal,Terminal.SignalHandler> |
handlers |
|
protected Map<InfoCmp.Capability,Integer> |
ints |
|
protected String |
name |
|
protected Runnable |
onClose |
|
protected Status |
status |
|
protected Map<InfoCmp.Capability,String> |
strings |
|
protected String |
type |
TYPE_DUMB, TYPE_DUMB_COLOR
Constructor | Description |
---|---|
AbstractTerminal(String name,
String type) |
|
AbstractTerminal(String name,
String type,
Charset encoding,
Terminal.SignalHandler signalHandler) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
canPauseResume() |
Whether this terminal supports
Terminal.pause() and Terminal.resume() calls. |
protected void |
checkInterrupted() |
|
void |
close() |
|
protected void |
doClose() |
|
boolean |
echo() |
|
boolean |
echo(boolean echo) |
|
protected void |
echoSignal(Terminal.Signal signal) |
|
Charset |
encoding() |
Returns the
Charset that should be used to encode characters
for Terminal.input() and Terminal.output() . |
Attributes |
enterRawMode() |
|
void |
flush() |
|
boolean |
getBooleanCapability(InfoCmp.Capability capability) |
|
Cursor |
getCursorPosition(IntConsumer discarded) |
Query the terminal to report the cursor position.
|
String |
getKind() |
|
String |
getName() |
|
Integer |
getNumericCapability(InfoCmp.Capability capability) |
|
Status |
getStatus() |
|
Status |
getStatus(boolean create) |
|
String |
getStringCapability(InfoCmp.Capability capability) |
|
String |
getType() |
|
Terminal.SignalHandler |
handle(Terminal.Signal signal,
Terminal.SignalHandler handler) |
|
boolean |
hasFocusSupport() |
Returns
true if the terminal has support for focus tracking. |
boolean |
hasMouseSupport() |
Returns
true if the terminal has support for mouse. |
protected void |
parseInfoCmp() |
|
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) |
|
MouseEvent |
readMouseEvent() |
Read a MouseEvent from the terminal input stream.
|
MouseEvent |
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttributes, getBufferSize, getHeight, getSize, getWidth, input, output, reader, setAttributes, setSize, writer
protected final String name
protected final String type
protected final Charset encoding
protected final Map<Terminal.Signal,Terminal.SignalHandler> handlers
protected final Set<InfoCmp.Capability> bools
protected final Map<InfoCmp.Capability,Integer> ints
protected final Map<InfoCmp.Capability,String> strings
protected Status status
protected Runnable onClose
public AbstractTerminal(String name, String type) throws IOException
IOException
public AbstractTerminal(String name, String type, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException
IOException
public void setOnClose(Runnable onClose)
public Status getStatus()
public Status getStatus(boolean create)
public Terminal.SignalHandler handle(Terminal.Signal signal, Terminal.SignalHandler handler)
public void raise(Terminal.Signal signal)
public final void close() throws IOException
close
in interface AutoCloseable
close
in interface Closeable
IOException
protected void doClose() throws IOException
IOException
protected void echoSignal(Terminal.Signal signal)
public Attributes enterRawMode()
enterRawMode
in interface Terminal
public String getKind()
public Charset encoding()
Terminal
Charset
that should be used to encode characters
for Terminal.input()
and Terminal.output()
.public void flush()
public boolean puts(InfoCmp.Capability capability, Object... params)
public boolean getBooleanCapability(InfoCmp.Capability capability)
getBooleanCapability
in interface Terminal
public Integer getNumericCapability(InfoCmp.Capability capability)
getNumericCapability
in interface Terminal
public String getStringCapability(InfoCmp.Capability capability)
getStringCapability
in interface Terminal
protected void parseInfoCmp()
public Cursor getCursorPosition(IntConsumer discarded)
Terminal
org.jline.keymap.BindingReader#runMacro(String)
getCursorPosition
in interface Terminal
discarded
- a consumer receiving discarded charactersnull
if cursor position reporting
is not supported or a valid cursor positionpublic boolean hasMouseSupport()
Terminal
true
if the terminal has support for mouse.hasMouseSupport
in interface Terminal
Terminal.trackMouse(MouseTracking)
public boolean trackMouse(Terminal.MouseTracking tracking)
Terminal
InfoCmp.Capability.key_mouse
to the input stream.
When this character sequence is detected, the Terminal.readMouseEvent()
method can be
called to actually read the corresponding mouse event.trackMouse
in interface Terminal
tracking
- the mouse tracking modetrue
if mouse tracking is supportedpublic MouseEvent readMouseEvent()
Terminal
InfoCmp.Capability.key_mouse
in the stream immediately before reading the event.readMouseEvent
in interface Terminal
Terminal.trackMouse(MouseTracking)
public MouseEvent readMouseEvent(IntSupplier reader)
Terminal
readMouseEvent
in interface Terminal
reader
- the input supplierpublic boolean hasFocusSupport()
Terminal
true
if the terminal has support for focus tracking.hasFocusSupport
in interface Terminal
Terminal.trackFocus(boolean)
public boolean trackFocus(boolean tracking)
Terminal
trackFocus
in interface Terminal
tracking
- whether the focus tracking mode should be enabled or nottrue
if focus tracking is supportedprotected void checkInterrupted() throws InterruptedIOException
InterruptedIOException
public boolean canPauseResume()
Terminal
Terminal.pause()
and Terminal.resume()
calls.canPauseResume
in interface Terminal
Terminal.pause()
and Terminal.resume()
calls.Terminal.paused()
,
Terminal.pause()
,
Terminal.resume()
public void pause()
Terminal
pause
in interface Terminal
Terminal.resume()
,
Terminal.paused()
public void pause(boolean wait) throws InterruptedException
Terminal
pause
in interface Terminal
wait
- true
to wait until the terminal is actually pausedInterruptedException
- if the call has been interruptedpublic void resume()
Terminal
resume
in interface Terminal
Terminal.pause()
,
Terminal.paused()
public boolean paused()
Terminal
paused
in interface Terminal
Terminal.pause()
,
Terminal.resume()
Copyright © 2020. All rights reserved.