Class ImageProtocolDetector

java.lang.Object
org.aesh.terminal.image.ImageProtocolDetector

public final class ImageProtocolDetector extends Object
Utility class for detecting terminal image protocol support.

Detection can be done in two ways:

  • Heuristic: Based on TERM type and environment variables (fast, always available)
  • Authoritative: Based on DA1 device attributes query (accurate, requires terminal query)

For best results, use detect(DeviceAttributes, String) which combines both methods.

This class uses TerminalEnvironment for centralized environment detection.

  • Method Details

    • detect

      public static ImageProtocol detect(DeviceAttributes attrs, String termType)
      Detect the image protocol using both device attributes and terminal type.

      This method provides the most accurate detection by:

      1. Checking DA1 attributes for Sixel support (authoritative)
      2. Falling back to heuristic detection based on terminal type
      Parameters:
      attrs - the device attributes from DA1 query (may be null)
      termType - the terminal type string (may be null)
      Returns:
      the detected protocol, or NONE if unknown
    • detectFromTermType

      public static ImageProtocol detectFromTermType(String termType)
      Detect the image protocol based on the terminal type string.

      This is a heuristic method that does not query the terminal. For more accurate detection, use detect(DeviceAttributes, String).

      Parameters:
      termType - the terminal type (e.g., from TERM environment variable)
      Returns:
      the detected protocol, or NONE if unknown
    • detectFromEnvironment

      public static ImageProtocol detectFromEnvironment()
      Detect image protocol from the current terminal environment.

      This method uses TerminalEnvironment to detect the terminal type and determine image protocol support.

      Returns:
      the detected protocol, or NONE if unknown
    • getProtocolForTerminalType

      public static ImageProtocol getProtocolForTerminalType(Device.TerminalType terminalType)
      Get the image protocol supported by a given terminal type.
      Parameters:
      terminalType - the detected terminal type
      Returns:
      the image protocol supported by this terminal
    • checkEnvironment

      public static ImageProtocol checkEnvironment()
      Check environment variables to detect image protocol support.

      This method uses TerminalEnvironment for centralized detection.

      Returns:
      the detected protocol based on environment, or NONE