Class ColorSupport

java.lang.Object
org.jline.terminal.impl.ColorSupport

public class ColorSupport extends Object
Parses OSC 10/11 color query responses from the terminal.

Terminals that support OSC color queries respond with an escape sequence containing the current foreground (OSC 10) or background (OSC 11) color as an rgb:RRRR/GGGG/BBBB value. This class reads and decodes those responses into a packed 24-bit RGB integer.

  • Method Details

    • parseColorResponse

      public static int parseColorResponse(NonBlockingReader reader, int colorType) throws IOException
      Reads an OSC color response from the terminal and returns the color as a 24-bit RGB integer.
      Parameters:
      reader - non-blocking reader connected to the terminal input
      colorType - the OSC color type to match (10 for foreground, 11 for background)
      Returns:
      the color as a packed 24-bit RGB integer (0xRRGGBB), or -1 if no valid response was received
      Throws:
      IOException - if an I/O error occurs while reading from the terminal