feat(terminal): port kitty graphics protocol storage and execution

Ports ZIG/src/terminal/kitty/graphics_*.zig:
- image loading for direct, file, temp-file and shared-memory
  transmissions (rustix::shm, no unsafe), chunking, zlib and PNG decode
- image storage with placements (incl. virtual) tracked by PageList pins,
  all delete modes, byte-limit eviction and dirty tracking
- unicode placeholder decoding and placement iteration
- command execution, generic over an ExecTerminal trait

Deviations: storage methods take the PageList explicitly; evicted or
replaced placements now release their tracked pins (Zig leaks them);
file transmissions with S= truncate per the kitty spec. Zig quirks kept
for parity: delete-range matches all placements, eviction stops only
after freeing strictly more than requested, set_limit(0) resets.

Not yet wired: Screen still holds the KittyImages placeholder, so
Terminal does not implement ExecTerminal; integration steps are in
docs/rewrite/notes/ghostty-terminal-kitty.md.

Test Plan:
- cargo test -p ghostty-terminal (66 kitty tests; all Zig tests ported)
This commit is contained in:
ddidderr committed 2026-10-11 22:52:07 +02:00
1 parent db1d4fe41d
commit fb9e33f1f2
12 files changed
+4176

No files matched your search

@@ -0,0 +1,45 @@
//! Kitty graphics render placement (`ZIG/src/terminal/kitty/graphics_render.zig`).
use crate::page_list::Pin;
/// A render placement is a way to position a Kitty graphics image onto
/// the screen. It is broken down into the fields that make it easier to
/// position the image using a renderer.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Placement {
/// The top-left corner of the image in grid coordinates.
pub top_left: Pin,
/// The offset in pixels from the top-left corner of the grid cell.
pub offset_x: u32,
pub offset_y: u32,
/// The source rectangle of the image to render. This doesn't have to
/// match the size the destination size and the renderer is expected
/// to scale the image to fit the destination size.
pub source_x: u32,
pub source_y: u32,
pub source_width: u32,
pub source_height: u32,
/// The final width/height of the image in pixels.
pub dest_width: u32,
pub dest_height: u32,
}
impl Placement {
/// A placement at `top_left` with all other fields zero.
pub fn new(top_left: Pin) -> Self {
Placement {
top_left,
offset_x: 0,
offset_y: 0,
source_x: 0,
source_y: 0,
source_width: 0,
source_height: 0,
dest_width: 0,
dest_height: 0,
}
}
}