Class AbstractConnection
- All Implemented Interfaces:
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 Attributesprotected EventDecoderprotected booleanprotected Consumer<int[]> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the current terminal attributes.Get the close handler.Get SignalHandler.Get the size handler.Consumer<int[]> Get the standard input handler.Get the current theme change 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.Consumer<int[]> Handler that's called for all outputMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.aesh.terminal.Connection
close, close, device, disableGraphemeClusterMode, disableSynchronizedOutput, disableThemeChangeNotification, enableGraphemeClusterMode, enableSynchronizedOutput, enableThemeChangeNotification, enableThemeChangeNotification, enterRawMode, getColorCapability, getColorDepth, getCursorPosition, getTerminalType, inputEncoding, openBlocking, openNonBlocking, outputEncoding, put, queryAnsi16Colors, queryBackgroundColor, queryBatchOsc, queryColorCapability, queryColors, queryCursorColor, queryDeviceAttributes, queryForegroundColor, queryGraphemeClusterMode, queryImageProtocol, queryOsc, queryOsc, queryPaletteColor, queryPaletteColorIfSupported, queryPaletteColors, queryPrimaryDeviceAttributes, querySecondaryDeviceAttributes, querySupportsOscQueries, querySynchronizedOutput, queryTerminal, queryThemeMode, queryWithResponseBuffering, size, supportsAnsi, supportsClipboard, supportsColorQuery, supportsGraphemeClusterMode, supportsHyperlinks, supportsOscCode, supportsOscQueries, supportsOscQueries, supportsPaletteQuery, supportsShellIntegration, supportsSynchronizedOutput, supportsThemeQuery, write, writeCommandFinished, writeCommandFinished, writeCommandStart, writeHyperlink, writeHyperlink, writePromptEnd, writePromptStart
-
Field Details
-
eventDecoder
-
stdout
-
sizeHandler
-
closeHandler
-
attributes
-
reading
protected volatile boolean reading
-
-
Constructor Details
-
AbstractConnection
public AbstractConnection()
-
-
Method Details
-
getSignalHandler
Description copied from interface:ConnectionGet SignalHandler. A handler that's called when a Signal is sent to the terminal- Specified by:
getSignalHandlerin interfaceConnection- Returns:
- Signal handler
-
setSignalHandler
Description copied from interface:ConnectionSpecify the signal handler. A handler that's called when a Signal is sent to the terminal- Specified by:
setSignalHandlerin interfaceConnection- Parameters:
handler- signal handler
-
getStdinHandler
Description copied from interface:ConnectionGet the standard input handler.- Specified by:
getStdinHandlerin 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
-
getSizeHandler
Description copied from interface:ConnectionGet the size handler.- Specified by:
getSizeHandlerin 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
-
getCloseHandler
Description copied from interface:ConnectionGet the close handler.- Specified by:
getCloseHandlerin interfaceConnection- Returns:
- handler thats called when the input stream is closed.
-
setThemeChangeHandler
Description copied from interface:ConnectionSet a handler to be called when the terminal's theme changes.When a handler is registered, the input pipeline will intercept unsolicited
CSI ? 997 ; Ps nresponses and route them to this handler instead of passing them through as input. This prevents theme change notifications from corrupting the readline buffer.Typically used together with
Connection.enableThemeChangeNotification()which tells the terminal to send these notifications.Note: The default implementation is a no-op. Implementations that extend
AbstractConnectionget automatic support viaEventDecoder.- Specified by:
setThemeChangeHandlerin interfaceConnection- Parameters:
handler- the handler to invoke with the new theme, or null to remove- See Also:
-
getThemeChangeHandler
Description copied from interface:ConnectionGet the current theme change handler.- Specified by:
getThemeChangeHandlerin interfaceConnection- Returns:
- the theme change handler, or null if not set
- See Also:
-
reading
public boolean reading()Description copied from interface:ConnectionCheck if the connection is actively reading from the input stream.This returns true after
Connection.openBlocking()orConnection.openNonBlocking()has been called and beforeConnection.close()is called.When reading is active, query methods can use
Connection.setStdinHandler(Consumer)to receive responses. When reading is not active, synchronous I/O must be used.- Specified by:
readingin interfaceConnection- Returns:
- true if the connection is actively reading input
-
getAttributes
Description copied from interface:ConnectionGet the current terminal attributes.- Specified by:
getAttributesin interfaceConnection- Returns:
- the terminal attributes
-
setAttributes
Description copied from interface:ConnectionSet the terminal attributes.- Specified by:
setAttributesin interfaceConnection- Parameters:
attr- the attributes to set
-