Interface Device
- All Known Implementing Classes:
BaseDevice
- Author:
- Ståle W. Pedersen
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumOSC (Operating System Command) codes that can be queried/set.static enumKnown terminal types and their capabilities. -
Method Summary
Modifier and TypeMethodDescriptiondefault Device.TerminalTypeDetect the terminal type from environment variables and TERM type.booleangetBooleanCapability(Capability capability) Checks if this device has the specified boolean capability.default ColorDepthGet the color depth of this device based on terminfo capabilities.default ImageProtocolGet the image protocol supported by this device.getNumericCapability(Capability capability) Gets the value of a numeric capability.getStringCapability(Capability capability) Gets the value of a string capability.int[]getStringCapabilityAsInts(Capability capability, Object... params) Gets a string capability as an array of code points, with parameter substitution.default booleanCheck if the current terminal is a JetBrains IDE terminal.default booleanCheck if this device is running inside a terminal multiplexer (like tmux or screen).default booleanCheck if tmux passthrough is enabled.booleanOutputs a capability string to the given consumer with parameter substitution.booleanputs(Consumer<int[]> output, Capability capability, Object... params) Outputs a capability string to the given consumer with parameter substitution.default booleanCheck if this device supports Mode 2027 (grapheme cluster segmentation).default booleanCheck if this device supports OSC 8 hyperlinks.default booleanCheck if this device supports displaying images.default booleansupportsOscCode(Device.OscCode oscCode) Check if the current terminal supports a specific OSC code.default booleanCheck if this device supports OSC (Operating System Command) queries.default booleanCheck if this device supports OSC 133 shell integration.default booleanCheck if this device supports Mode 2026 (synchronized output).default booleanCheck if the current terminal supports the CSI ?type()Returns the terminal type identifier for this device.
-
Method Details
-
type
String type()Returns the terminal type identifier for this device.- Returns:
- the terminal type (e.g., "xterm", "ansi", "vt100")
-
getBooleanCapability
Checks if this device has the specified boolean capability.- Parameters:
capability- the capability to check- Returns:
- true if the capability is supported, false otherwise
-
getNumericCapability
Gets the value of a numeric capability.- Parameters:
capability- the capability to retrieve- Returns:
- the numeric value, or null if the capability is not set
-
getStringCapability
Gets the value of a string capability.- Parameters:
capability- the capability to retrieve- Returns:
- the string value, or null if the capability is not set
-
getStringCapabilityAsInts
Gets a string capability as an array of code points, with parameter substitution.- Parameters:
capability- the capability to retrieveparams- optional parameters to substitute into the capability string- Returns:
- the capability string as an int array of code points, or null if not set
-
puts
Outputs a capability string to the given consumer with parameter substitution.- Parameters:
output- the consumer to receive the output as an int arraycapability- the capability to outputparams- optional parameters to substitute into the capability string- Returns:
- true if the capability was found and output, false otherwise
-
puts
Outputs a capability string to the given consumer with parameter substitution.- Parameters:
output- the consumer to receive the output as an int arraycapability- the capability name to look up and outputparams- optional parameters to substitute into the capability string- Returns:
- true if the capability was found and output, false otherwise
-
supportsOscQueries
default boolean supportsOscQueries()Check if this device supports OSC (Operating System Command) queries.OSC queries like OSC 10/11 are used to query foreground/background colors. Not all terminals support these queries, and some terminal multiplexers (like tmux, screen) may intercept or block them.
This method uses
TerminalEnvironmentfor environment-based detection.- Returns:
- true if OSC queries are likely supported
-
supportsGraphemeClusterMode
default boolean supportsGraphemeClusterMode()Check if this device supports Mode 2027 (grapheme cluster segmentation).Mode 2027 tells the terminal to use UAX #29 grapheme cluster segmentation instead of per-codepoint wcwidth for cursor positioning.
This method uses
TerminalEnvironmentfor environment-based detection.- Returns:
- true if Mode 2027 is likely supported
-
supportsSynchronizedOutput
default boolean supportsSynchronizedOutput()Check if this device supports Mode 2026 (synchronized output).Synchronized output prevents screen tearing during rapid terminal redraws by buffering rendering until the mode is disabled.
This method uses
TerminalEnvironmentfor environment-based detection.- Returns:
- true if Mode 2026 is likely supported
-
supportsShellIntegration
default boolean supportsShellIntegration()Check if this device supports OSC 133 shell integration.This method uses
TerminalEnvironmentfor environment-based detection.- Returns:
- true if OSC 133 shell integration is likely supported
-
supportsHyperlinks
default boolean supportsHyperlinks()Check if this device supports OSC 8 hyperlinks.This method uses
TerminalEnvironmentfor environment-based detection.- Returns:
- true if OSC 8 hyperlinks are likely supported
-
detectTerminalType
Detect the terminal type from environment variables and TERM type.This method uses
TerminalEnvironmentwhich parses environment variables once and caches the result.Detection priority:
- IDE-specific environment variables (TERMINAL_EMULATOR)
- Terminal-specific environment variables (KITTY_WINDOW_ID, etc.)
- TERM_PROGRAM environment variable
- TERM type string
- Returns:
- the detected terminal type
-
supportsOscCode
Check if the current terminal supports a specific OSC code.- Parameters:
oscCode- the OSC code to check- Returns:
- true if the terminal likely supports this OSC code
-
supportsThemeQuery
default boolean supportsThemeQuery()Check if the current terminal supports the CSI ? 996 n theme mode query.When supported, the terminal can be queried for its current dark/light mode preference, and can subscribe to unsolicited theme change notifications.
This delegates to
Device.TerminalType.supportsThemeDsr().- Returns:
- true if the terminal supports CSI ? 996 n theme DSR queries
- See Also:
-
isJetBrainsTerminal
default boolean isJetBrainsTerminal()Check if the current terminal is a JetBrains IDE terminal.- Returns:
- true if running in a JetBrains IDE terminal
-
isTmuxPassthroughEnabled
default boolean isTmuxPassthroughEnabled()Check if tmux passthrough is enabled.When running inside tmux, OSC sequences are only passed through to the outer terminal if allow-passthrough is enabled.
- Returns:
- true if running in tmux with passthrough likely enabled
-
getColorDepth
Get the color depth of this device based on terminfo capabilities.Falls back to environment-based detection if terminfo doesn't provide color information.
- Returns:
- the detected color depth
-
isMultiplexer
default boolean isMultiplexer()Check if this device is running inside a terminal multiplexer (like tmux or screen).- Returns:
- true if running inside a multiplexer
-
supportsImages
default boolean supportsImages()Check if this device supports displaying images.- Returns:
- true if images can be displayed
-
getImageProtocol
Get the image protocol supported by this device.Detection is based on terminal type and environment variables. Supported protocols (in priority order):
- KITTY - Kitty, Ghostty, Konsole
- ITERM2 - iTerm2, WezTerm, Mintty, VSCode, Tabby, Hyper
- SIXEL - mlterm, foot, contour (fallback)
- Returns:
- the detected image protocol, or NONE if not supported
-