Class AbstractConnection
java.lang.Object
org.aesh.terminal.AbstractConnection
- All Implemented Interfaces:
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.Get SignalHandler.Get the size handler.Consumer<int[]> Get the standard input 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.Consumer<int[]> Handler that's called for all outputMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Connection
close, close, device, enterRawMode, getColorCapability, getColorDepth, getCursorPosition, getTerminalType, inputEncoding, openBlocking, openNonBlocking, outputEncoding, put, queryAnsi16Colors, queryBackgroundColor, queryBatchOsc, queryColorCapability, queryColors, queryCursorColor, queryDeviceAttributes, queryForegroundColor, queryImageProtocol, queryOsc, queryOsc, queryPaletteColor, queryPaletteColorIfSupported, queryPaletteColors, queryPrimaryDeviceAttributes, querySecondaryDeviceAttributes, querySupportsOscQueries, queryTerminal, queryWithResponseBuffering, size, supportsAnsi, supportsClipboard, supportsColorQuery, supportsOscCode, supportsOscQueries, supportsOscQueries, supportsPaletteQuery, write
-
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.
-
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
-