public abstract class AbstractTerminal extends Object implements Terminal
Terminal.MouseTracking, Terminal.Signal, Terminal.SignalHandler| Modifier and Type | Field and 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 and Description |
|---|
AbstractTerminal(String name,
String type) |
AbstractTerminal(String name,
String type,
Charset encoding,
Terminal.SignalHandler signalHandler) |
| Modifier and Type | Method and 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, waitgetAttributes, getBufferSize, getHeight, getSize, getWidth, input, output, reader, setAttributes, setSize, writerprotected 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
IOExceptionpublic AbstractTerminal(String name, String type, Charset encoding, Terminal.SignalHandler signalHandler) throws IOException
IOExceptionpublic 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 Closeableclose in interface AutoCloseableIOExceptionprotected void doClose()
throws IOException
IOExceptionprotected void echoSignal(Terminal.Signal signal)
public Attributes enterRawMode()
enterRawMode in interface Terminalpublic String getKind()
public Charset encoding()
TerminalCharset 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 Terminalpublic Integer getNumericCapability(InfoCmp.Capability capability)
getNumericCapability in interface Terminalpublic String getStringCapability(InfoCmp.Capability capability)
getStringCapability in interface Terminalprotected void parseInfoCmp()
public Cursor getCursorPosition(IntConsumer discarded)
Terminalorg.jline.keymap.BindingReader#runMacro(String)getCursorPosition in interface Terminaldiscarded - a consumer receiving discarded charactersnull if cursor position reporting
is not supported or a valid cursor positionpublic boolean hasMouseSupport()
Terminaltrue if the terminal has support for mouse.hasMouseSupport in interface TerminalTerminal.trackMouse(MouseTracking)public boolean trackMouse(Terminal.MouseTracking tracking)
TerminalInfoCmp.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 Terminaltracking - the mouse tracking modetrue if mouse tracking is supportedpublic MouseEvent readMouseEvent()
TerminalInfoCmp.Capability.key_mouse
in the stream immediately before reading the event.readMouseEvent in interface TerminalTerminal.trackMouse(MouseTracking)public MouseEvent readMouseEvent(IntSupplier reader)
TerminalreadMouseEvent in interface Terminalreader - the input supplierpublic boolean hasFocusSupport()
Terminaltrue if the terminal has support for focus tracking.hasFocusSupport in interface TerminalTerminal.trackFocus(boolean)public boolean trackFocus(boolean tracking)
TerminaltrackFocus in interface Terminaltracking - whether the focus tracking mode should be enabled or nottrue if focus tracking is supportedprotected void checkInterrupted()
throws InterruptedIOException
InterruptedIOExceptionpublic boolean canPauseResume()
TerminalTerminal.pause() and Terminal.resume() calls.canPauseResume in interface TerminalTerminal.pause() and Terminal.resume() calls.Terminal.paused(),
Terminal.pause(),
Terminal.resume()public void pause()
Terminalpause in interface TerminalTerminal.resume(),
Terminal.paused()public void pause(boolean wait)
throws InterruptedException
Terminalpause in interface Terminalwait - true to wait until the terminal is actually pausedInterruptedException - if the call has been interruptedpublic void resume()
Terminalresume in interface TerminalTerminal.pause(),
Terminal.paused()public boolean paused()
Terminalpaused in interface TerminalTerminal.pause(),
Terminal.resume()Copyright © 2020. All rights reserved.