Class AbstractConnection

java.lang.Object
org.aesh.terminal.AbstractConnection
All Implemented Interfaces:
Appendable, AutoCloseable, Connection

public abstract class AbstractConnection extends Object implements 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 Details

    • eventDecoder

      protected EventDecoder eventDecoder
    • stdout

      protected Consumer<int[]> stdout
    • sizeHandler

      protected Consumer<Size> sizeHandler
    • closeHandler

      protected Consumer<Void> closeHandler
    • attributes

      protected Attributes attributes
    • reading

      protected volatile boolean reading
  • Constructor Details

    • AbstractConnection

      public AbstractConnection()
  • Method Details

    • terminal

      public TerminalFeatures terminal()
      Description copied from interface: Connection
      Access advanced terminal features: queries, capability detection, semantic output, and mode management.
      Specified by:
      terminal in interface Connection
      Returns:
      the terminal features for this connection
    • signalHandler

      public Consumer<Signal> signalHandler()
      Description copied from interface: Connection
      Get the signal handler.
      Specified by:
      signalHandler in interface Connection
      Returns:
      handler that's called when a Signal is sent to the terminal
    • setSignalHandler

      public void setSignalHandler(Consumer<Signal> handler)
      Description copied from interface: Connection
      Specify the signal handler.
      Specified by:
      setSignalHandler in interface Connection
      Parameters:
      handler - signal handler
    • stdinHandler

      public Consumer<int[]> stdinHandler()
      Description copied from interface: Connection
      Get the standard input handler.
      Specified by:
      stdinHandler in interface Connection
      Returns:
      the stdin handler that processes input as code point arrays
    • setStdinHandler

      public void setStdinHandler(Consumer<int[]> handler)
      Description copied from interface: Connection
      Set the standard input handler.
      Specified by:
      setStdinHandler in interface Connection
      Parameters:
      handler - the handler to process input as code point arrays
    • stdoutHandler

      public Consumer<int[]> stdoutHandler()
      Description copied from interface: Connection
      Handler that's called for all output.
      Specified by:
      stdoutHandler in interface Connection
      Returns:
      output handler
    • sizeHandler

      public Consumer<Size> sizeHandler()
      Description copied from interface: Connection
      Get the size handler.
      Specified by:
      sizeHandler in interface Connection
      Returns:
      handler that's called when the terminal changes size
    • setSizeHandler

      public void setSizeHandler(Consumer<Size> handler)
      Description copied from interface: Connection
      Specify size handler that's called when the terminal changes size.
      Specified by:
      setSizeHandler in interface Connection
      Parameters:
      handler - the size change handler
    • setCloseHandler

      public void setCloseHandler(Consumer<Void> closeHandler)
      Description copied from interface: Connection
      Specify handler that's called when the input stream is closed.
      Specified by:
      setCloseHandler in interface Connection
      Parameters:
      closeHandler - handler
    • closeHandler

      public Consumer<Void> closeHandler()
      Description copied from interface: Connection
      Get the close handler.
      Specified by:
      closeHandler in interface Connection
      Returns:
      handler that's called when the input stream is closed
    • setThemeChangeHandler

      public void setThemeChangeHandler(Consumer<TerminalTheme> handler)
      Description copied from interface: Connection
      Set a handler to be called when the terminal's theme changes.
      Specified by:
      setThemeChangeHandler in interface Connection
      Parameters:
      handler - the handler to invoke with the new theme, or null to remove
    • themeChangeHandler

      public Consumer<TerminalTheme> themeChangeHandler()
      Description copied from interface: Connection
      Get the current theme change handler.
      Specified by:
      themeChangeHandler in interface Connection
      Returns:
      the theme change handler, or null if not set
    • reading

      public boolean reading()
      Description copied from interface: Connection
      Check if the connection is actively reading from the input stream.
      Specified by:
      reading in interface Connection
      Returns:
      true if the connection is actively reading input
    • attributes

      public Attributes attributes()
      Description copied from interface: Connection
      Get the current terminal attributes.
      Specified by:
      attributes in interface Connection
      Returns:
      the terminal attributes
    • setAttributes

      public void setAttributes(Attributes attr)
      Description copied from interface: Connection
      Set the terminal attributes.
      Specified by:
      setAttributes in interface Connection
      Parameters:
      attr - the attributes to set