Class DeviceAttributes
Device attributes provide information about terminal capabilities that cannot be determined from terminfo alone. This includes:
- Terminal type and conformance level (VT100, VT220, xterm, etc.)
- Supported features (sixel graphics, mouse, rectangular editing)
- Firmware/version information
Use TerminalFeatures.queryDeviceAttributes(long) to
obtain an instance of this class.
- Author:
- Ståle Pedersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumFeature flags that can be reported in DA1 response.static enumTerminal type identifiers from DA2 response. -
Constructor Summary
ConstructorsConstructorDescriptionDeviceAttributes(int deviceClass, Set<Integer> parameters) Create DeviceAttributes from DA1 response data.DeviceAttributes(int deviceClass, Set<Integer> parameters, DeviceAttributes.TerminalType terminalType, int firmwareVersion, int romCartridge) Create DeviceAttributes from both DA1 and DA2 response data. -
Method Summary
Modifier and TypeMethodDescriptiongetCapabilitySummary(Device.TerminalType envType) Get enhanced terminal capabilities by combining DA1/DA2 data with environment-detected terminal type.intGet the device class / conformance level.Get the set of features reported by the terminal.intGet the firmware version from DA2 response.Get the raw parameter codes from DA1 response.intGet the ROM cartridge registration number from DA2.Get the terminal type from DA2 response.booleanhasDA1()Check if DA1 data is available.booleanhasDA2()Check if DA2 data is available.booleanhasFeature(DeviceAttributes.Feature feature) Check if the terminal supports a specific feature.Infer the color depth from DA1 features.Infer the terminal type from DA1/DA2 attributes.booleanCheck if the terminal likely supports OSC (Operating System Command) queries.booleanmatchesTerminalType(Device.TerminalType expectedType) Validate that this terminal's attributes match the expected features for a given terminal type.merge(DeviceAttributes other) Merge this DeviceAttributes with another, combining data from both.booleanCheck if the terminal supports 132-column mode.booleanCheck if the terminal supports ANSI colors.booleanCheck if the terminal supports mouse/locator.booleanCheck if the terminal supports rectangular editing operations.booleanCheck if the terminal supports Sixel graphics.toString()
-
Constructor Details
-
DeviceAttributes
Create DeviceAttributes from DA1 response data.- Parameters:
deviceClass- the device class (conformance level)parameters- the feature parameter codes from DA1 response
-
DeviceAttributes
public DeviceAttributes(int deviceClass, Set<Integer> parameters, DeviceAttributes.TerminalType terminalType, int firmwareVersion, int romCartridge) Create DeviceAttributes from both DA1 and DA2 response data.- Parameters:
deviceClass- the device class from DA1parameters- the feature parameters from DA1terminalType- the terminal type from DA2firmwareVersion- the firmware version from DA2romCartridge- the ROM cartridge registration from DA2
-
-
Method Details
-
getDeviceClass
public int getDeviceClass()Get the device class / conformance level.Common values:
- 1 or 2: VT100
- 62: VT220
- 63: VT320
- 64: VT420
- Returns:
- the device class, or -1 if not available
-
getFeatures
Get the set of features reported by the terminal.- Returns:
- unmodifiable set of features
-
getRawParameters
Get the raw parameter codes from DA1 response.This includes both recognized and unrecognized parameters.
- Returns:
- unmodifiable set of parameter codes
-
getTerminalType
Get the terminal type from DA2 response.- Returns:
- the terminal type
-
getFirmwareVersion
public int getFirmwareVersion()Get the firmware version from DA2 response.- Returns:
- the firmware version, or -1 if not available
-
getRomCartridge
public int getRomCartridge()Get the ROM cartridge registration number from DA2.- Returns:
- the ROM cartridge number, or -1 if not available
-
hasFeature
Check if the terminal supports a specific feature.- Parameters:
feature- the feature to check- Returns:
- true if the feature is supported
-
supportsSixel
public boolean supportsSixel()Check if the terminal supports Sixel graphics.- Returns:
- true if Sixel is supported
-
supportsAnsiColor
public boolean supportsAnsiColor()Check if the terminal supports ANSI colors.- Returns:
- true if ANSI color is supported
-
supportsMouse
public boolean supportsMouse()Check if the terminal supports mouse/locator.This checks for DEC locator (Ps=16) or ANSI text locator (Ps=29).
- Returns:
- true if mouse/locator is supported
-
supportsRectangularEditing
public boolean supportsRectangularEditing()Check if the terminal supports rectangular editing operations.- Returns:
- true if rectangular editing is supported
-
supports132Columns
public boolean supports132Columns()Check if the terminal supports 132-column mode.- Returns:
- true if 132-column mode is supported
-
hasDA1
public boolean hasDA1()Check if DA1 data is available.- Returns:
- true if DA1 was successfully queried
-
hasDA2
public boolean hasDA2()Check if DA2 data is available.- Returns:
- true if DA2 was successfully queried
-
likelySupportsOscQueries
public boolean likelySupportsOscQueries()Check if the terminal likely supports OSC (Operating System Command) queries.This is inferred from DA1 capabilities. Terminals that report modern features like ANSI color or Sixel graphics typically also support OSC queries for color detection (OSC 10/11), clipboard (OSC 52), etc.
Note: This is an inference, not a guarantee. Some terminals may report these features but not support all OSC commands.
- Returns:
- true if OSC queries are likely supported based on DA1 features
-
merge
Merge this DeviceAttributes with another, combining data from both.This is useful when DA1 and DA2 are queried separately.
- Parameters:
other- the other DeviceAttributes to merge with- Returns:
- a new DeviceAttributes with combined data
-
inferTerminalType
Infer the terminal type from DA1/DA2 attributes.This method attempts to determine which
Device.TerminalTypebest matches the features and capabilities reported by the terminal.Use this in combination with environment-based detection for more accurate terminal identification:
Device.TerminalType envType = device.detectTerminalType(); DeviceAttributes attrs = connection.queryDeviceAttributes(500); Device.TerminalType daType = attrs.inferTerminalType(); // envType is usually more specific, but daType confirms capabilities
- Returns:
- the inferred terminal type, or UNKNOWN if not determinable
-
inferColorDepth
Infer the color depth from DA1 features.This provides an authoritative color depth based on what the terminal actually reports, rather than environment-based heuristics.
- Returns:
- the inferred color depth
-
matchesTerminalType
Validate that this terminal's attributes match the expected features for a given terminal type.This can be used to verify that environment-detected terminal type matches the actual terminal capabilities.
- Parameters:
expectedType- the terminal type detected from environment- Returns:
- true if the attributes are consistent with the expected type
-
getCapabilitySummary
Get enhanced terminal capabilities by combining DA1/DA2 data with environment-detected terminal type.This method returns a summary of capabilities using both sources of information for the most accurate detection.
- Parameters:
envType- the terminal type detected from environment variables- Returns:
- a capabilities summary string
-
toString
-