Interface Device

All Known Implementing Classes:
BaseDevice

public interface Device
Contains info and capabilities for the device we are connected to.
Author:
Ståle W. Pedersen
  • Method Details

    • type

      String type()
      Returns the terminal type identifier for this device.
      Returns:
      the terminal type (e.g., "xterm", "ansi", "vt100")
    • getBooleanCapability

      boolean getBooleanCapability(Capability capability)
      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

      Integer getNumericCapability(Capability capability)
      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

      String getStringCapability(Capability capability)
      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

      int[] getStringCapabilityAsInts(Capability capability, Object... params)
      Gets a string capability as an array of code points, with parameter substitution.
      Parameters:
      capability - the capability to retrieve
      params - 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

      boolean puts(Consumer<int[]> output, Capability capability, Object... params)
      Outputs a capability string to the given consumer with parameter substitution.
      Parameters:
      output - the consumer to receive the output as an int array
      capability - the capability to output
      params - optional parameters to substitute into the capability string
      Returns:
      true if the capability was found and output, false otherwise
    • puts

      boolean puts(Consumer<int[]> output, String capability, Object... params)
      Outputs a capability string to the given consumer with parameter substitution.
      Parameters:
      output - the consumer to receive the output as an int array
      capability - the capability name to look up and output
      params - 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 TerminalEnvironment for environment-based detection.

      Returns:
      true if OSC queries are likely supported
    • detectTerminalType

      default Device.TerminalType detectTerminalType()
      Detect the terminal type from environment variables and TERM type.

      This method uses TerminalEnvironment which parses environment variables once and caches the result.

      Detection priority:

      1. IDE-specific environment variables (TERMINAL_EMULATOR)
      2. Terminal-specific environment variables (KITTY_WINDOW_ID, etc.)
      3. TERM_PROGRAM environment variable
      4. TERM type string
      Returns:
      the detected terminal type
    • supportsOscCode

      default boolean supportsOscCode(Device.OscCode oscCode)
      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
    • 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

      default ColorDepth 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

      default ImageProtocol 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