Package org.aesh.terminal
Class AbstractConnection
java.lang.Object
org.aesh.terminal.AbstractConnection
- All Implemented Interfaces:
Appendable,AutoCloseable,Connection
Abstract base class for
Connection implementations that use an
EventDecoder for signal and input handling.
Provides the common handler plumbing (signal, stdin, stdout, size, close, attributes, reading state) so that subclasses only need to implement device/transport-specific methods.
- Author:
- Ståle W. Pedersen
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Attributesprotected EventDecoderprotected booleanprotected Consumer<int[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the current terminal attributes.Get the close handler.booleanreading()Check if the connection is actively reading from the input stream.voidsetAttributes(Attributes attr) Set the terminal attributes.voidsetCloseHandler(Consumer<Void> closeHandler) Specify handler that's called when the input stream is closed.voidsetSignalHandler(Consumer<Signal> handler) Specify the signal handler.voidsetSizeHandler(Consumer<Size> handler) Specify size handler that's called when the terminal changes size.voidsetStdinHandler(Consumer<int[]> handler) Set the standard input handler.voidsetThemeChangeHandler(Consumer<TerminalTheme> handler) Set a handler to be called when the terminal's theme changes.Get the signal handler.Get the size handler.Consumer<int[]> Get the standard input handler.Consumer<int[]> Handler that's called for all output.terminal()Access advanced terminal features: queries, capability detection, semantic output, and mode management.Get the current theme change handler.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aesh.terminal.Connection
append, append, append, asPrintWriter, asWriter, close, close, device, enterRawMode, inputEncoding, openBlocking, openNonBlocking, outputEncoding, put, size, supportsAnsi, write
-
Field Details
-
eventDecoder
-
stdout
-
sizeHandler
-
closeHandler
-
attributes
-
reading
protected volatile boolean reading
-
-
Constructor Details
-
AbstractConnection
public AbstractConnection()
-
-
Method Details
-
terminal
Description copied from interface:ConnectionAccess advanced terminal features: queries, capability detection, semantic output, and mode management.- Specified by:
terminalin interfaceConnection- Returns:
- the terminal features for this connection
-
signalHandler
Description copied from interface:ConnectionGet the signal handler.- Specified by:
signalHandlerin interfaceConnection- Returns:
- handler that's called when a Signal is sent to the terminal
-
setSignalHandler
Description copied from interface:ConnectionSpecify the signal handler.- Specified by:
setSignalHandlerin interfaceConnection- Parameters:
handler- signal handler
-
stdinHandler
Description copied from interface:ConnectionGet the standard input handler.- Specified by:
stdinHandlerin interfaceConnection- Returns:
- the stdin handler that processes input as code point arrays
-
setStdinHandler
Description copied from interface:ConnectionSet the standard input handler.- Specified by:
setStdinHandlerin interfaceConnection- Parameters:
handler- the handler to process input as code point arrays
-
stdoutHandler
Description copied from interface:ConnectionHandler that's called for all output.- Specified by:
stdoutHandlerin interfaceConnection- Returns:
- output handler
-
sizeHandler
Description copied from interface:ConnectionGet the size handler.- Specified by:
sizeHandlerin interfaceConnection- Returns:
- handler that's called when the terminal changes size
-
setSizeHandler
Description copied from interface:ConnectionSpecify size handler that's called when the terminal changes size.- Specified by:
setSizeHandlerin interfaceConnection- Parameters:
handler- the size change handler
-
setCloseHandler
Description copied from interface:ConnectionSpecify handler that's called when the input stream is closed.- Specified by:
setCloseHandlerin interfaceConnection- Parameters:
closeHandler- handler
-
closeHandler
Description copied from interface:ConnectionGet the close handler.- Specified by:
closeHandlerin interfaceConnection- Returns:
- handler that's called when the input stream is closed
-
setThemeChangeHandler
Description copied from interface:ConnectionSet a handler to be called when the terminal's theme changes.- Specified by:
setThemeChangeHandlerin interfaceConnection- Parameters:
handler- the handler to invoke with the new theme, or null to remove
-
themeChangeHandler
Description copied from interface:ConnectionGet the current theme change handler.- Specified by:
themeChangeHandlerin interfaceConnection- Returns:
- the theme change handler, or null if not set
-
reading
public boolean reading()Description copied from interface:ConnectionCheck if the connection is actively reading from the input stream.- Specified by:
readingin interfaceConnection- Returns:
- true if the connection is actively reading input
-
attributes
Description copied from interface:ConnectionGet the current terminal attributes.- Specified by:
attributesin interfaceConnection- Returns:
- the terminal attributes
-
setAttributes
Description copied from interface:ConnectionSet the terminal attributes.- Specified by:
setAttributesin interfaceConnection- Parameters:
attr- the attributes to set
-