Package org.jline.terminal.impl
Interface TerminalGraphics
- All Known Implementing Classes:
ITerm2Graphics,KittyGraphics,SixelGraphics
public interface TerminalGraphics
Common interface for terminal graphics protocols.
This interface provides a unified API for displaying images in terminals using various graphics protocols such as Sixel, Kitty Graphics Protocol, and iTerm2 Inline Images Protocol.
Different terminals support different graphics protocols:
- Sixel - Supported by xterm, iTerm2, foot, WezTerm, etc.
- Kitty Graphics Protocol - Supported by Kitty, Ghostty, WezTerm
- iTerm2 Inline Images - Supported by iTerm2
The implementation automatically detects which protocols are supported and uses the best available option.
- Since:
- 3.30.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classImage display options for controlling how images are rendered.static enumGraphics protocol types supported by terminals. -
Method Summary
Modifier and TypeMethodDescriptionconvertImage(BufferedImage image, TerminalGraphics.ImageOptions options) Converts an image to the protocol-specific format.voiddisplayImage(Terminal terminal, BufferedImage image) Displays a BufferedImage on the terminal using this graphics protocol.voiddisplayImage(Terminal terminal, BufferedImage image, TerminalGraphics.ImageOptions options) Displays a BufferedImage on the terminal with custom options.voiddisplayImage(Terminal terminal, File file) Displays an image file on the terminal.voiddisplayImage(Terminal terminal, File file, TerminalGraphics.ImageOptions options) Displays an image file on the terminal with custom options.voiddisplayImage(Terminal terminal, InputStream inputStream) Displays an image from an input stream on the terminal.voiddisplayImage(Terminal terminal, InputStream inputStream, TerminalGraphics.ImageOptions options) Displays an image from an input stream on the terminal with custom options.intGets the priority of this protocol for automatic selection.Gets the graphics protocol type supported by this implementation.booleanisSupported(Terminal terminal) Checks if this graphics protocol is supported by the given terminal.
-
Method Details
-
getProtocol
TerminalGraphics.Protocol getProtocol()Gets the graphics protocol type supported by this implementation.- Returns:
- the protocol type
-
isSupported
Checks if this graphics protocol is supported by the given terminal.- Parameters:
terminal- the terminal to check- Returns:
- true if the protocol is supported, false otherwise
-
getPriority
int getPriority()Gets the priority of this protocol for automatic selection. Higher values indicate higher priority.- Returns:
- the priority value (0-100)
-
displayImage
Displays a BufferedImage on the terminal using this graphics protocol.- Parameters:
terminal- the terminal to display the image onimage- the image to display- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, BufferedImage image, TerminalGraphics.ImageOptions options) throws IOException Displays a BufferedImage on the terminal with custom options.- Parameters:
terminal- the terminal to display the image onimage- the image to displayoptions- display options for the image- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
displayImage
Displays an image file on the terminal.- Parameters:
terminal- the terminal to display the image onfile- the image file to display- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, File file, TerminalGraphics.ImageOptions options) throws IOException Displays an image file on the terminal with custom options.- Parameters:
terminal- the terminal to display the image onfile- the image file to displayoptions- display options for the image- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
displayImage
Displays an image from an input stream on the terminal.- Parameters:
terminal- the terminal to display the image oninputStream- the input stream containing the image data- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
displayImage
void displayImage(Terminal terminal, InputStream inputStream, TerminalGraphics.ImageOptions options) throws IOException Displays an image from an input stream on the terminal with custom options.- Parameters:
terminal- the terminal to display the image oninputStream- the input stream containing the image dataoptions- display options for the image- Throws:
IOException- if an I/O error occursUnsupportedOperationException- if the protocol is not supported
-
convertImage
Converts an image to the protocol-specific format. This method is useful for debugging or when you need the raw protocol data.- Parameters:
image- the image to convertoptions- display options for the image- Returns:
- the protocol-specific representation of the image
- Throws:
IOException- if an I/O error occurs
-