Package org.aesh.terminal.image
Class ImageProtocolDetector
java.lang.Object
org.aesh.terminal.image.ImageProtocolDetector
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 Summary
Modifier and TypeMethodDescriptionstatic ImageProtocolCheck environment variables to detect image protocol support.static ImageProtocoldetect(DeviceAttributes attrs, String termType) Detect the image protocol using both device attributes and terminal type.static ImageProtocolDetect image protocol from the current terminal environment.static ImageProtocoldetectFromTermType(String termType) Detect the image protocol based on the terminal type string.static ImageProtocolgetProtocolForTerminalType(Device.TerminalType terminalType) Get the image protocol supported by a given terminal type.
-
Method Details
-
detect
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
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
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
Check environment variables to detect image protocol support.This method uses
TerminalEnvironmentfor centralized detection.- Returns:
- the detected protocol based on environment, or NONE
-