Class AbstractConnection
- All Implemented Interfaces:
Appendable, AutoCloseable, Connection
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 AttributesField.Field.protected EventDecoderField.protected booleanField.Field.protected Consumer<int[]> Field. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the current terminal attributes.Get the close handler.Get the current focus event handler.Returns the current status line messages in display order (lowest priority first).Get the current mouse event handler.Get the current printAbove handler.booleanreading()Check if the connection is actively reading from the input stream.registerStatusLine(int priority) Register a persistent status line displayed between scrolling output and the prompt.voidsetAttributes(Attributes attr) Set the terminal attributes.voidsetCloseHandler(Consumer<Void> closeHandler) Specify handler that's called when the input stream is closed.voidsetFocusHandler(Consumer<Boolean> handler) Set the handler for terminal focus events.voidsetMouseHandler(Consumer<MouseEvent> handler) Set a handler to be called when mouse events are received.voidsetPrintAboveHandler(Consumer<String> handler) Set the handler forConnection.printAbove(String)calls.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<org.aesh.terminal.detect.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.Consumer<org.aesh.terminal.detect.TerminalTheme> Get the current theme change handler.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Connection
append, append, append, asPrintWriter, asWriter, close, close, currentRegion, device, enterRawMode, inputEncoding, isInteractive, openBlocking, openNonBlocking, outputEncoding, peek, printAbove, put, setCurrentRegion, size, splitScreen, splitScreen, supportsAnsi, supportsNonBlockingRead, write
-
Field Details
-
eventDecoder
Field. -
stdout
Field. -
sizeHandler
-
closeHandler
-
attributes
Field. -
reading
protected volatile boolean readingField.
-
-
Constructor Details
-
AbstractConnection
protected AbstractConnection()Constructor.
-
-
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
-
setMouseHandler
Description copied from interface:ConnectionSet a handler to be called when mouse events are received.Mouse tracking must be explicitly enabled via
MouseTrackingfor the terminal to send mouse events.- Specified by:
setMouseHandlerin interfaceConnection- Parameters:
handler- the handler to invoke with mouse events, or null to remove- See Also:
-
mouseHandler
Description copied from interface:ConnectionGet the current mouse event handler.- Specified by:
mouseHandlerin interfaceConnection- Returns:
- the mouse handler, or null if not set
-
setFocusHandler
Description copied from interface:ConnectionSet the handler for terminal focus events.When set, the terminal will report focus gained (
true) and focus lost (false) events. Focus tracking must be enabled by sendingESC [ ? 1004 hto the terminal.- Specified by:
setFocusHandlerin interfaceConnection- Parameters:
handler- the focus handler, or null to disable
-
focusHandler
Description copied from interface:ConnectionGet the current focus event handler.- Specified by:
focusHandlerin interfaceConnection- Returns:
- the focus handler, or null if not set
-
registerStatusLine
Description copied from interface:ConnectionRegister a persistent status line displayed between scrolling output and the prompt.Status lines are rendered in priority order: lowest priority at top, highest priority at bottom (closest to the prompt). They persist across
Connection.printAbove(String)calls and are redrawn automatically.If multiple status lines share the same priority, they are ordered by registration time.
- Specified by:
registerStatusLinein interfaceConnection- Parameters:
priority- the display priority (higher = closer to prompt)- Returns:
- a new StatusLine that can be updated or closed
-
getStatusMessages
-
setPrintAboveHandler
Description copied from interface:ConnectionSet the handler forConnection.printAbove(String)calls.This is typically set by the readline implementation during an active readline session, and cleared when the session ends.
- Specified by:
setPrintAboveHandlerin interfaceConnection- Parameters:
handler- the handler, or null to disable
-
printAboveHandler
Description copied from interface:ConnectionGet the current printAbove handler.- Specified by:
printAboveHandlerin interfaceConnection- Returns:
- the 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
-