kitty graphics support

This commit is contained in:
Gregor Lohaus
2026-05-27 14:33:41 +02:00
parent a03bc2ec48
commit 5285fb68c9
14 changed files with 651 additions and 0 deletions

View File

@@ -145,6 +145,31 @@ try (Terminal terminal = Ghostty.open(TerminalOptions.of(80, 24))) {
}
```
## Kitty Graphics
Kitty graphics storage can be enabled and inspected:
```java
try (Terminal terminal = Ghostty.open(TerminalOptions.of(80, 24))) {
terminal.setKittyImageStorageLimit(64 * 1024 * 1024);
terminal.setKittyImageMediumFile(true);
terminal.setKittyImageMediumTemporaryFile(true);
terminal.setKittyImageMediumSharedMemory(true);
terminal.write(kittyGraphicsSequenceBytes);
for (KittyPlacement placement : terminal.kittyGraphics().orElseThrow().placements()) {
placement.image().ifPresent(image -> {
// Hand image.data() and placement.renderInfo() to your renderer.
});
}
}
```
The Kitty handles returned by `libghostty-vt` are borrowed from the terminal and are invalidated by mutating terminal calls. The Java API returns snapshots for images and placements to make renderer handoff simpler.
PNG decode callbacks from `ghostty_sys_set(GHOSTTY_SYS_OPT_DECODE_PNG, ...)` are not exposed yet. Raw Kitty image formats can be inspected; PNG image ingestion will need a Java callback bridge or a small native helper that allocates decoded RGBA data through Ghostty's allocator.
## Development Shell
```sh