diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-28 21:59:19 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-28 23:11:27 -0300 |
| commit | caffd9c1f8742a17431f7de0a2824d3fc02bfd72 (patch) | |
| tree | 9c51876719a9882e6b3fed58684107c4ab7ee40f /src/TerminalImages.zig | |
| parent | 2e237ef20b6a5d9f680d80a560d144c0f67dff91 (diff) | |
| download | pardes-caffd9c1f8742a17431f7de0a2824d3fc02bfd72.tar.gz pardes-caffd9c1f8742a17431f7de0a2824d3fc02bfd72.zip | |
kitty z-index: a terminal image's z= goes with it, images go to the shell lowest first, and the tty hands z on to the outer terminal (under the text below 0); real clients recorded, replayed and run live
z-index was lost: an ImagePlace had none, so every image went over the cells in hash-map order, a z<0 picture (a background under text) over the text and overlapping images in any order. ImagePlace.z now carries the placement's z (a virtual placement's from its placeholder target), TerminalImages sorts what it appends lowest z first (stable), and the tty's exactKittyPlacement sets vaxis's z_index, so a kitty terminal outside stacks them and puts z<0 under the text. The GUI draws them in that order but still over the cells: under the text there needs a glyph pass after the images (ui.frag's clear_bg_bit) in gui.zig's vertex buffer.
Real clients: test/kitty_harness.zig's PARDES_KITTY_EXPLORE runs commands in the pane under script(1) and prints what pardes placed outside; kitten icat 0.49.2 (--align left/center/right, --place, --scale-up, --unicode-placeholder, --clear, file/memory/stream/detect), chafa 1.18.3, viu and yazi 26.9.1 all landed where they should. Their recorded traffic (test/kitty-fixtures/*.vt) replays through the core (test/kitty.zig) to the cells they drew live. The harness now also runs yazi live (shared memory, a virtual placement, placeholders), checks z=-1 outside, and runs a second pardes under a terminal without kitty graphics: no graphics command reaches it and the image is glyph art in all 32 cells. The harness empties NO_COLOR (zig build sets it, and vaxis drew no colour at all under the harness) by setenv, not unsetenv, which compacts the environment std captured.
Also: tests that a pane's image follows pardes's own scrollback, an edited copy taller than its rows, a narrow pane's edge, Collapse and a cell-size change; and a knownGap: images do not survive a dump (Dump, Handover, a pane reopened from the Store), whose VT text has none.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/TerminalImages.zig')
| -rw-r--r-- | src/TerminalImages.zig | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/TerminalImages.zig b/src/TerminalImages.zig index f3333460..f26b5852 100644 --- a/src/TerminalImages.zig +++ b/src/TerminalImages.zig @@ -162,6 +162,14 @@ pub fn draw( const ch: u32 = @max(1, p.cell_pixels.h); const pixels = p.native_images and !ti.petscii; const ctx: Ctx = .{ .ti = ti, .p = p, .s = s, .pane = pane_id, .serial = serial, .tx = tx, .body_y = body_y, .cols = cols, .rows_of = rows_of, .cw = cw, .ch = ch, .pixels = pixels }; + // Handed on lowest z first (the storage's order is a hash map's), the + // order a shell draws them in; equal z keeps the order they came in. + const first = s.nimages; + defer std.sort.insertion(?pardes.ImagePlace, s.images[first..s.nimages], {}, struct { + fn lessThan(_: void, a: ?pardes.ImagePlace, b: ?pardes.ImagePlace) bool { + return (if (a) |x| x.z else 0) < (if (b) |y| y.z else 0); + } + }.lessThan); // Virtual placements: shown through the placeholder cells, one run of // them on a row at a time. The placeholders themselves are not text. @@ -181,7 +189,7 @@ pub fn draw( const target = storage.placeholderTarget(run.image_id, run.placement_id) orelse continue; const rp = run.renderPlacement(&target.placement, &img, cw, ch) catch continue; if (rp.dest_width == 0 or rp.dest_height == 0 or rp.source_width == 0 or rp.source_height == 0) continue; - ctx.place(img, .{ .x = rp.source_x, .y = rp.source_y, .w = rp.source_width, .h = rp.source_height }, .{ + ctx.place(img, target.placement.z, .{ .x = rp.source_x, .y = rp.source_y, .w = rp.source_width, .h = rp.source_height }, .{ .x = @as(i64, at.viewport.x) * cw + rp.offset_x, .y = @as(i64, v) * ch + rp.offset_y, .w = rp.dest_width, @@ -223,7 +231,7 @@ pub fn draw( const sw = if (placed.source_width > 0) @min(placed.source_width, img.width - sx) else img.width - sx; const sh = if (placed.source_height > 0) @min(placed.source_height, img.height - sy) else img.height - sy; if (size.width == 0 or size.height == 0 or sw == 0 or sh == 0) continue; - ctx.place(img, .{ .x = sx, .y = sy, .w = sw, .h = sh }, .{ + ctx.place(img, placed.z, .{ .x = sx, .y = sy, .w = sw, .h = sh }, .{ .x = (@as(i64, at.screen.x) + dx) * cw + placed.x_offset, .y = (@as(i64, at.screen.y) - @as(i64, origin.screen.y) + dy) * ch + placed.y_offset, .w = size.width, @@ -248,7 +256,7 @@ const Ctx = struct { /// Draw `src` of `img` over `dst`, one cell row of it at a time: a row /// is shown, or not, or shown elsewhere, as the body lays it out. - fn place(ctx: Ctx, img: gfx.Image, src: PixelRect, dst: Rect) void { + fn place(ctx: Ctx, img: gfx.Image, z: i32, src: PixelRect, dst: Rect) void { const cw: i64 = ctx.cw; const ch: i64 = ctx.ch; const x0 = @max(dst.x, 0); @@ -294,6 +302,7 @@ const Ctx = struct { .rgba = rgba, .iw = img.width, .ih = img.height, + .z = z, }); continue; } |
