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
FieldsModifier and TypeFieldDescriptionprotected final Set<InfoCmp.Capability> protected final Charsetprotected final Map<Terminal.Signal, Terminal.SignalHandler> protected final Map<InfoCmp.Capability, Integer> protected final Stringprotected Runnableprotected final ColorPaletteprotected Statusprotected final Map<InfoCmp.Capability, String> protected final StringFields inherited from interface org.jline.terminal.Terminal
TYPE_DUMB, TYPE_DUMB_COLOR -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTerminal(String name, String type) AbstractTerminal(String name, String type, Charset encoding, Terminal.SignalHandler signalHandler) -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this terminal supportsTerminal.pause()andTerminal.resume()calls.protected voidfinal voidclose()protected voiddoClose()booleanecho()booleanecho(boolean echo) protected voidechoSignal(Terminal.Signal signal) encoding()Returns theCharsetthat should be used to encode characters forTerminal.input()andTerminal.output().voidflush()booleangetBooleanCapability(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.booleanReturnstrueif the terminal has support for focus tracking.booleanReturnstrueif the terminal has support for mouse.protected voidvoidpause()Stop reading the input stream.voidpause(boolean wait) Stop reading the input stream and optionally wait for the underlying threads to finish.booleanpaused()Check whether the terminal is currently reading the input stream or not.booleanputs(InfoCmp.Capability capability, Object... params) voidraise(Terminal.Signal signal) Raise the specific signal.Read a MouseEvent from the terminal input stream.readMouseEvent(IntSupplier reader) Read a MouseEvent from the given input stream.voidresume()Resume reading the input stream.voidsetOnClose(Runnable onClose) toString()booleantrackFocus(boolean tracking) Enable or disable focus tracking mode.booleantrackMouse(Terminal.MouseTracking tracking) Change the mouse tracking mouse.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jline.terminal.Terminal
getAttributes, getBufferSize, getHeight, getSize, getWidth, input, output, reader, setAttributes, setSize, writerMethods 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:TerminalRegisters a handler for the givenTerminal.Signal.Note that the JVM does not easily allow catching the
Terminal.Signal.QUITsignal, which causes a thread dump to be displayed. This signal is mainly used when connecting through an SSH socket to a virtual terminal. -
raise
Description copied from interface:TerminalRaise 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 toAttributes.ControlChar.VINTR,Attributes.ControlChar.VQUIT, orAttributes.ControlChar.VSUSP. -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
doClose
- Throws:
IOException
-
echoSignal
-
enterRawMode
- Specified by:
enterRawModein interfaceTerminal
-
echo
-
echo
-
getName
-
getType
-
getKind
-
encoding
Description copied from interface:TerminalReturns theCharsetthat should be used to encode characters forTerminal.input()andTerminal.output(). -
flush
-
puts
-
getBooleanCapability
- Specified by:
getBooleanCapabilityin interfaceTerminal
-
getNumericCapability
- Specified by:
getNumericCapabilityin interfaceTerminal
-
getStringCapability
- Specified by:
getStringCapabilityin interfaceTerminal
-
parseInfoCmp
protected void parseInfoCmp() -
getCursorPosition
Description copied from interface:TerminalQuery 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:
getCursorPositionin interfaceTerminal- Parameters:
discarded- a consumer receiving discarded characters- Returns:
nullif cursor position reporting is not supported or a valid cursor position
-
hasMouseSupport
public boolean hasMouseSupport()Description copied from interface:TerminalReturnstrueif the terminal has support for mouse.- Specified by:
hasMouseSupportin interfaceTerminal- Returns:
- whether mouse is supported by the terminal
- See Also:
-
trackMouse
Description copied from interface:TerminalChange 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_mouseto the input stream. When this character sequence is detected, theTerminal.readMouseEvent()method can be called to actually read the corresponding mouse event.- Specified by:
trackMousein interfaceTerminal- Parameters:
tracking- the mouse tracking mode- Returns:
trueif mouse tracking is supported
-
readMouseEvent
Description copied from interface:TerminalRead a MouseEvent from the terminal input stream. Such an event must have been detected by scanning the terminal'sInfoCmp.Capability.key_mousein the stream immediately before reading the event.- Specified by:
readMouseEventin interfaceTerminal- Returns:
- the decoded mouse event.
- See Also:
-
readMouseEvent
Description copied from interface:TerminalRead a MouseEvent from the given input stream.- Specified by:
readMouseEventin interfaceTerminal- Parameters:
reader- the input supplier- Returns:
- the decoded mouse event
-
hasFocusSupport
public boolean hasFocusSupport()Description copied from interface:TerminalReturnstrueif the terminal has support for focus tracking.- Specified by:
hasFocusSupportin interfaceTerminal- Returns:
- whether focus tracking is supported by the terminal
- See Also:
-
trackFocus
public boolean trackFocus(boolean tracking) Description copied from interface:TerminalEnable 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:
trackFocusin interfaceTerminal- Parameters:
tracking- whether the focus tracking mode should be enabled or not- Returns:
trueif focus tracking is supported
-
checkInterrupted
- Throws:
InterruptedIOException
-
canPauseResume
public boolean canPauseResume()Description copied from interface:TerminalWhether this terminal supportsTerminal.pause()andTerminal.resume()calls.- Specified by:
canPauseResumein interfaceTerminal- Returns:
- whether this terminal supports
Terminal.pause()andTerminal.resume()calls. - See Also:
-
pause
-
pause
Description copied from interface:TerminalStop reading the input stream and optionally wait for the underlying threads to finish.- Specified by:
pausein interfaceTerminal- Parameters:
wait-trueto wait until the terminal is actually paused- Throws:
InterruptedException- if the call has been interrupted
-
resume
-
paused
public boolean paused()Description copied from interface:TerminalCheck 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:TerminalColor support- Specified by:
getPalettein interfaceTerminal
-
toString
-