Class ImageProtocolDetector
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 Summary
Modifier and TypeMethodDescriptionstatic org.aesh.terminal.detect.ImageProtocolCheck environment variables to detect image protocol support.static org.aesh.terminal.detect.ImageProtocoldetect(DeviceAttributes attrs, String termType) Detect the image protocol using both device attributes and terminal type.static org.aesh.terminal.detect.ImageProtocolDetect image protocol from the current terminal environment.static org.aesh.terminal.detect.ImageProtocoldetectFromTermType(String termType) Detect the image protocol based on the terminal type string.static org.aesh.terminal.detect.ImageProtocolgetProtocolForTerminalType(Device.TerminalType terminalType) Get the image protocol supported by a given terminal type.
-
Method Details
-
detect
public static org.aesh.terminal.detect.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:
- Checking DA1 attributes for Sixel support (authoritative)
- 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
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 org.aesh.terminal.detect.ImageProtocol detectFromEnvironment()Detect image protocol from the current terminal environment.This method uses
TerminalEnvironmentto detect the terminal type and determine image protocol support.- Returns:
- the detected protocol, or NONE if unknown
-
getProtocolForTerminalType
public static org.aesh.terminal.detect.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 org.aesh.terminal.detect.ImageProtocol checkEnvironment()Check environment variables to detect image protocol support.This method uses
TerminalEnvironmentfor centralized detection. When running inside a terminal multiplexer (tmux/screen), the Kitty graphics protocol (APC-based) cannot pass through. In that case, terminals that also support Sixel (DCS-based, which multiplexers can forward) are detected as SIXEL instead.- Returns:
- the detected protocol based on environment, or NONE
-