summaryrefslogtreecommitdiff
path: root/src/tui
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui')
-rw-r--r--src/tui/tui.zig279
1 files changed, 143 insertions, 136 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index e8a5c44c..68b97ba2 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -6,6 +6,7 @@ const libc = std.c;
const vaxis = @import("vaxis");
const pardes = @import("../pardes.zig");
const JumpTrail = @import("../jump_trail.zig");
+const Art = @import("../Art.zig");
const vaxis_input = @import("../vaxis_input.zig");
const tracy = @import("../tracy.zig");
const look = @import("../look.zig");
@@ -774,21 +775,20 @@ fn terminalSize(cols: u16, rows: u16, pixel_w: u16, pixel_h: u16) @FieldType(par
};
}
-/// A terminal pane's image fragment (`native.exact`): its `src` into its
-/// `dst`, inside one cell row. Kitty scales a source rectangle to whole
+/// A terminal pane's image fragment (one cell row): its `src` into its
+/// `at`, inside that row. Kitty scales a source rectangle to whole
/// cells, so the source is trimmed to the cells' scale rather than the
/// picture stretched: a fragment loses under a cell at its right edge.
/// A full row is declared one row high; a part of one (an image's top or
/// bottom edge) only its columns, its height then following the source.
fn exactKittyPlacement(
- place: pardes.ImagePlace,
+ place: pardes.Placement,
screen_cols: u16,
screen_rows: u16,
screen_pixel_w: u16,
screen_pixel_h: u16,
) ?KittyPlacement {
- if (comptime !pardes.pdf_enabled) return null;
- const g = place.native.geometry orelse return null;
+ const g: pardes.image.NativeGeometry = .{ .src = place.src, .dst = place.at orelse return null };
const cell_w = terminalCellPixels(screen_pixel_w, screen_cols, 8);
const cell_h = terminalCellPixels(screen_pixel_h, screen_rows, 16);
if (g.dst.w == 0 or g.dst.h == 0 or g.src.w == 0 or g.src.h == 0) return null;
@@ -796,7 +796,7 @@ fn exactKittyPlacement(
const pixel_x = g.dst.x % cell_w;
const pixel_y = @min(g.dst.y, cell_h - 1);
const cols: u32 = @max(1, (g.dst.w + cell_w / 2) / cell_w);
- if (cell_x >= place.w) return null;
+ if (cell_x >= place.dst.w) return null;
const declared_w = cols * cell_w;
// At the cells' scale, the source that fills `cols` cells.
var src_w = g.src.w;
@@ -813,7 +813,7 @@ fn exactKittyPlacement(
return .{
.cell_x = std.math.cast(u16, cell_x) orelse return null,
.cell_y = 0,
- .cell_cols = std.math.cast(u16, @min(@as(u32, place.w) - cell_x, (pixel_x + declared_w + cell_w - 1) / cell_w)) orelse return null,
+ .cell_cols = std.math.cast(u16, @min(@as(u32, place.dst.w) - cell_x, (pixel_x + declared_w + cell_w - 1) / cell_w)) orelse return null,
.cell_rows = 1,
.options = .{
.clip_region = .{
@@ -833,28 +833,20 @@ fn exactKittyPlacement(
};
}
+/// A PDF's page over its body: declared to kitty by its columns where it
+/// is as wide as the body (fit to width), else by its rows, and its source
+/// cut so the declared cells never run past its clipped bottom.
fn kittyPlacement(
- place: pardes.ImagePlace,
+ place: pardes.Placement,
screen_cols: u16,
screen_rows: u16,
screen_pixel_w: u16,
screen_pixel_h: u16,
) ?KittyPlacement {
- if (comptime !pardes.pdf_enabled) return null;
- if (place.native.fit == .contain) return null;
const cell_w = terminalCellPixels(screen_pixel_w, screen_cols, 8);
const cell_h = terminalCellPixels(screen_pixel_h, screen_rows, 16);
- const body_w = std.math.mul(u32, place.w, cell_w) catch return null;
- const body_h = std.math.mul(u32, place.h, cell_h) catch return null;
- const geometry = place.native.geometry orelse pardes.image.nativeGeometry(
- place.iw,
- place.ih,
- body_w,
- body_h,
- place.native.fit,
- place.native.pan_x,
- place.native.pan_y,
- ) orelse return null;
+ const geometry: pardes.image.NativeGeometry = .{ .src = place.src, .dst = place.at orelse return null };
+ const fit: enum { width, height } = if (geometry.dst.w >= @as(u32, place.dst.w) * cell_w) .width else .height;
const safe_rows_u32 = geometry.dst.h / cell_h;
if (safe_rows_u32 == 0) return null;
@@ -862,7 +854,7 @@ fn kittyPlacement(
var safe_src_h: u32 = geometry.src.h;
var declared_cols: u32 = 0;
var declared_rows: u32 = 0;
- switch (place.native.fit) {
+ switch (fit) {
.width => {
declared_cols = @intCast(@max(
@as(u64, 1),
@@ -896,7 +888,6 @@ fn kittyPlacement(
(@as(u64, aspect_pixel_w) + cell_w - 1) / cell_w,
);
},
- .contain => unreachable,
}
if (declared_rows == 0 or declared_rows > safe_rows_u32) return null;
@@ -906,15 +897,15 @@ fn kittyPlacement(
const src_h = std.math.cast(u16, safe_src_h) orelse return null;
const cell_x = std.math.cast(u16, geometry.dst.x / cell_w) orelse return null;
const cell_y = std.math.cast(u16, geometry.dst.y / cell_h) orelse return null;
- if (cell_x >= place.w or cell_y >= place.h) return null;
+ if (cell_x >= place.dst.w or cell_y >= place.dst.h) return null;
const pixel_x = std.math.cast(u16, geometry.dst.x % cell_w) orelse return null;
const pixel_y = std.math.cast(u16, geometry.dst.y % cell_h) orelse return null;
const cell_cols = std.math.cast(u16, @min(
- @as(u32, place.w - cell_x),
+ @as(u32, place.dst.w - cell_x),
(@as(u64, pixel_x) + @as(u64, declared_cols) * cell_w + cell_w - 1) / cell_w,
)) orelse return null;
const cell_rows = std.math.cast(u16, @min(
- @as(u32, place.h - cell_y),
+ @as(u32, place.dst.h - cell_y),
(@as(u64, pixel_y) + declared_rows * cell_h + cell_h - 1) / cell_h,
)) orelse return null;
if (cell_cols == 0 or cell_rows == 0) return null;
@@ -927,31 +918,22 @@ fn kittyPlacement(
.options = .{
.clip_region = .{ .x = src_x, .y = src_y, .width = src_w, .height = src_h },
.pixel_offset = if (pixel_x != 0 or pixel_y != 0) .{ .x = pixel_x, .y = pixel_y } else null,
- .size = switch (place.native.fit) {
+ .size = switch (fit) {
.width => .{ .cols = std.math.cast(u16, declared_cols) orelse return null },
.height => .{ .rows = std.math.cast(u16, declared_rows) orelse return null },
- .contain => unreachable,
},
},
};
}
test "a terminal's image fragment goes to kitty cropped to its cells' scale, a full row one row high" {
- if (comptime !pardes.pdf_enabled) return;
- var place = pardes.ImagePlace{
+ var place = pardes.Placement{
.pane = 0,
- .serial = 3,
- .native = .{ .page = 7, .exact = true, .geometry = .{
- .src = .{ .x = 0, .y = 40, .w = 240, .h = 20 },
- .dst = .{ .x = 0, .y = 0, .w = 240, .h = 20 },
- } },
- .x = 99,
- .y = 4,
- .w = 24,
- .h = 1,
- .rgba = &.{},
- .iw = 240,
- .ih = 160,
+ .raster = .{ .ptr = undefined, .w = 240, .h = 160, .stride = 960 },
+ .src = .{ .x = 0, .y = 40, .w = 240, .h = 20 },
+ .dst = .{ .x = 99, .y = 4, .w = 24, .h = 1 },
+ .at = .{ .x = 0, .y = 0, .w = 240, .h = 20 },
+ .key = pardes.Placement.keyOf(3, 7, 0),
};
// 10x20 pixel cells: a whole row, one to one.
const full = exactKittyPlacement(place, 100, 30, 1000, 600).?;
@@ -966,10 +948,8 @@ test "a terminal's image fragment goes to kitty cropped to its cells' scale, a f
// tall, 35 pixels in, 205 wide, which rounds to 21 cells. Its columns
// only, its source no taller than the 13 pixels left in the row at
// that scale.
- place.native.geometry = .{
- .src = .{ .x = 0, .y = 0, .w = 205, .h = 13 },
- .dst = .{ .x = 35, .y = 7, .w = 205, .h = 13 },
- };
+ place.src = .{ .x = 0, .y = 0, .w = 205, .h = 13 };
+ place.at = .{ .x = 35, .y = 7, .w = 205, .h = 13 };
const top = exactKittyPlacement(place, 100, 30, 1000, 600).?;
try std.testing.expectEqual(@as(u16, 3), top.cell_x);
try std.testing.expectEqual(@as(u16, 5), top.options.pixel_offset.?.x);
@@ -982,37 +962,22 @@ test "a terminal's image fragment goes to kitty cropped to its cells' scale, a f
try std.testing.expect(h > 0 and @as(u32, h) * 210 / w <= 13);
// Narrower than its cells round to: the source is cut to their scale.
- place.native.geometry = .{
- .src = .{ .x = 0, .y = 0, .w = 400, .h = 40 },
- .dst = .{ .x = 0, .y = 0, .w = 204, .h = 20 },
- };
+ place.src = .{ .x = 0, .y = 0, .w = 400, .h = 40 };
+ place.at = .{ .x = 0, .y = 0, .w = 204, .h = 20 };
const cut = exactKittyPlacement(place, 100, 30, 1000, 600).?;
try std.testing.expectEqual(@as(?u16, 20), cut.options.size.?.cols);
try std.testing.expectEqual(@as(?u16, 392), cut.options.clip_region.?.width);
}
test "Kitty PDF fragments never declare pixels beyond their clipped bottom" {
- if (comptime !pardes.pdf_enabled) return;
-
- const base = pardes.ImagePlace{
+ // As wide as the body: fit to width.
+ const base = pardes.Placement{
.pane = 0,
- .serial = 1,
- .native = .{
- .revision = 1,
- .page = 0,
- .fit = .width,
- .geometry = .{
- .src = .{ .w = 96, .h = 10 },
- .dst = .{ .y = 195, .w = 304, .h = 29 },
- },
- },
- .x = 0,
- .y = 0,
- .w = 38,
- .h = 14,
- .rgba = &.{},
- .iw = 96,
- .ih = 64,
+ .raster = .{ .ptr = undefined, .w = 96, .h = 64, .stride = 384 },
+ .src = .{ .w = 96, .h = 10 },
+ .dst = .{ .x = 0, .y = 0, .w = 38, .h = 14 },
+ .at = .{ .y = 195, .w = 304, .h = 29 },
+ .key = pardes.Placement.keyOf(1, 0, 1),
};
const width = kittyPlacement(base, 80, 16, 640, 256) orelse
return error.MissingSafeKittyWidthFragment;
@@ -1024,21 +989,62 @@ test "Kitty PDF fragments never declare pixels beyond their clipped bottom" {
const aspect_pixels = (@as(u32, width_size.cols.?) * 8 * width_clip.height.? +
width_clip.width.? - 1) / width_clip.width.?;
const inferred_rows = (aspect_pixels + 15) / 16;
- try std.testing.expect(inferred_rows * 16 <= base.native.geometry.?.dst.h);
+ try std.testing.expect(inferred_rows * 16 <= base.at.?.h);
+ // Narrower than the body: fit to height.
var height = base;
- height.native.fit = .height;
- height.native.geometry.?.src.h = 9;
+ height.at.?.w = 300;
+ height.src.h = 9;
const height_fragment = kittyPlacement(height, 80, 16, 640, 256) orelse
return error.MissingSafeKittyHeightFragment;
try std.testing.expectEqual(@as(u16, 1), height_fragment.options.size.?.rows.?);
try std.testing.expect(@as(u32, height_fragment.options.size.?.rows.?) * 16 <=
- height.native.geometry.?.dst.h);
+ height.at.?.h);
- height.native.geometry.?.dst.h = 13;
+ height.at.?.h = 13;
try std.testing.expect(kittyPlacement(height, 80, 16, 640, 256) == null);
}
+test "on a terminal with no kitty graphics a program's 64x64 image over 8x4 cells is glyph art in every cell, and pixels stay put where it has them" {
+ if (comptime !pardes.pdf_enabled) return;
+ const gpa = std.testing.allocator;
+ const core = try pardes.Pardes.init(gpa, .{ .cols = 120, .rows = 40, .shells = 1 });
+ defer core.deinit();
+ core.update(.{ .resize = .{ .cols = 120, .rows = 40, .cell_pixels = .{ .w = 8, .h = 16 } } });
+ const pane = core.panes[0].?;
+ pane.body.mode = .tty;
+ var frame = std.heap.ArenaAllocator.init(gpa);
+ defer frame.deinit();
+ const a = frame.allocator();
+ const px = try a.alloc(u8, 64 * 64 * 3);
+ for (0..64 * 64) |i| px[i * 3 ..][0..3].* = .{ 13, 77, 231 };
+ const enc = try a.alloc(u8, std.base64.standard.Encoder.calcSize(px.len));
+ _ = std.base64.standard.Encoder.encode(enc, px);
+ core.update(.{ .output = .{ .pane = 0, .bytes = try std.fmt.allocPrint(a, "\x1b[H\x1b[2J\r\nANCHOR>\x1b_Ga=T,i=42,f=24,s=64,v=64,c=8,r=4;{s}\x1b\\\r\n", .{enc}) } });
+ while (core.nextEffect()) |_| {}
+ const s = try core.render(a);
+ try std.testing.expectEqual(@as(usize, 4), s.placements.items.len);
+ var art: Art = .{};
+ defer art.deinit(gpa);
+ try std.testing.expectEqual(@as(*const pardes.Surface, s), try art.frame(gpa, a, s, true, 16));
+ const shown = try art.frame(gpa, a, s, false, 16);
+ const r = core.rects[0];
+ const x0 = r.x + pardes.config.GUTTER + 7;
+ const y0 = core.bodyTop(pane, r) + 1;
+ var painted: usize = 0;
+ for (0..4) |dy| for (0..8) |dx| {
+ const cell = @constCast(shown).at(x0 + @as(u16, @intCast(dx)), y0 + @as(u16, @intCast(dy)));
+ const bg = switch (cell.style.bg) {
+ .rgb => |rgb| rgb,
+ else => continue,
+ };
+ for (Art.commodore) |c| {
+ if (std.mem.eql(u8, &c, &bg)) painted += 1;
+ }
+ };
+ try std.testing.expectEqual(@as(usize, 32), painted);
+}
+
test "host watch closes initial race and reloads rename-over PDF while idle" {
if (comptime !file_watch.supported or !pardes.pdf_enabled) return;
const io = std.testing.io;
@@ -1094,19 +1100,20 @@ test "host watch closes initial race and reloads rename-over PDF while idle" {
var frame = std.heap.ArenaAllocator.init(gpa);
defer frame.deinit();
const surface = try core.render(frame.allocator());
- try std.testing.expect(surface.images.items.len > 0);
- try std.testing.expectEqual(@as(u32, 0), surface.images.items[0].native.page);
+ try std.testing.expect(surface.placements.items.len > 0);
+ const shown = surface.placements.items[0];
+ try std.testing.expectEqual(pardes.Placement.keyOf(pane.serial, 0, pardes.panes.Pdf.rasterForPage(pane.pdf.?, 0).?.revision), shown.key);
}
-fn kittyImageRepresentable(place: pardes.ImagePlace) bool {
- return place.iw > 0 and place.ih > 0 and
- place.iw <= std.math.maxInt(u16) and place.ih <= std.math.maxInt(u16);
+fn kittyImageRepresentable(place: pardes.Placement) bool {
+ return place.raster.w > 0 and place.raster.h > 0 and
+ place.raster.w <= std.math.maxInt(u16) and place.raster.h <= std.math.maxInt(u16);
}
-fn surfaceHasKittyKey(surface: *const pardes.Surface, key: pardes.ImageCacheKey) bool {
- for (surface.images.items) |place| {
- if (comptime pardes.pdf_enabled) if (!kittyImageRepresentable(place)) continue;
- if (place.cacheKey().eql(key)) return true;
+fn surfaceHasKittyKey(surface: *const pardes.Surface, key: u64) bool {
+ for (surface.placements.items) |place| {
+ if (place.art.glyph or !kittyImageRepresentable(place)) continue;
+ if (place.key == key) return true;
}
return false;
}
@@ -1265,6 +1272,7 @@ pub fn remote(init: std.process.Init, opts: pardes.Options, path: []const u8, se
try screen.enter(try vaxis.Tty.init(io, &tty_buf));
defer screen.leave();
defer screen.glide.deinit(gpa);
+ defer screen.art.deinit(gpa);
var paste_buf: std.Io.Writer.Allocating = .init(gpa);
defer paste_buf.deinit();
var loop: Loop = .init(io, &screen.tty, &screen.vx);
@@ -1404,7 +1412,11 @@ const Screen = struct {
killed: ?usize = null,
feed: Feed = .{},
thread: ?std.Io.Future(void) = null,
- kitty: std.AutoHashMap(pardes.ImageCacheKey, vaxis.Image),
+ /// The kitty images it holds, by placement key.
+ kitty: std.AutoHashMap(u64, vaxis.Image),
+ /// The glyph art of the pictures it shows so (all of them without
+ /// kitty graphics).
+ art: Art = .{},
caps_pending: bool = true,
/// Its size as last taken (`Shell.resized`).
size: ?vaxis.Winsize = null,
@@ -1511,6 +1523,7 @@ const Screen = struct {
fn destroy(sc: *Screen) void {
sc.glide.deinit(sc.gpa);
+ sc.art.deinit(sc.gpa);
sc.kitty.deinit();
sc.gpa.free(sc.buf);
sc.gpa.destroy(sc);
@@ -1619,6 +1632,7 @@ fn localSession(
pardes.lsp.setStatusSink(&sh, lspStatusSink);
host_io.setExitWake(loop, wakeForExit);
defer screen.glide.deinit(gpa);
+ defer screen.art.deinit(gpa);
// The terminals of the other views end with the session: each put back,
// its stub told.
defer for (&sh.terms) |*slot| if (slot.*) |sc| if (!sc.primary) {
@@ -1770,7 +1784,7 @@ fn localSession(
}
fn clearNativeImages(
- kitty_handles: *std.AutoHashMap(pardes.ImageCacheKey, vaxis.Image),
+ kitty_handles: *std.AutoHashMap(u64, vaxis.Image),
vx: *vaxis.Vaxis,
tty: *vaxis.Tty,
) void {
@@ -2622,21 +2636,24 @@ const Shell = struct {
const win = vx.window();
// The tty's own motions, on its own clock, from the frame alone.
const now: u64 = s.test_clock orelse @intCast(std.Io.Clock.awake.now(s.io).nanoseconds);
- sc.glide.frame(s.gpa, canonical, now, null, null);
+ // The pictures it shows as glyph art, in a copy of the frame: all
+ // of them where the terminal has no kitty graphics.
+ const cell_h = terminalCellPixels(vx.screen.height_pix, vx.screen.height, 16);
+ const arted = sc.art.frame(s.gpa, s.frame.allocator(), canonical, vx.caps.kitty_graphics, cell_h) catch canonical;
+ sc.glide.frame(s.gpa, arted, now, null, null);
s.core.frames.scroll = @round(sc.glide.follow.offset);
- const glided = glideRows(s.frame.allocator(), canonical, &sc.glide) catch canonical;
+ const glided = glideRows(s.frame.allocator(), arted, &sc.glide) catch arted;
const truecolor = vx.caps.rgb or colortermTruecolor();
const trail_on = s.core.settings.jump_trail and truecolor;
const shown = trailCells(s.frame.allocator(), glided, &sc.trail, trail_on, now) catch glided;
paintCells(win, shown.cells, shown.cols, shown.rows);
if (s.remote) |c| if (c.link.notice_len > 0) noticeLine(win, c.link.notice(), shown.cols, shown.rows);
tz_cells.end();
- for (canonical.images.items) |place| {
- if (comptime pardes.pdf_enabled) {
- if (!kittyImageRepresentable(place)) continue;
- }
- const key = place.cacheKey();
- if (!sc.kitty.contains(key) and vx.caps.kitty_graphics and sc.feed.shm.load(.acquire)) shm: {
+ if (vx.caps.kitty_graphics) for (canonical.placements.items) |place| {
+ if (place.art.glyph or !kittyImageRepresentable(place)) continue;
+ const key = place.key;
+ const rgba = place.raster.bytes();
+ if (!sc.kitty.contains(key) and sc.feed.shm.load(.acquire)) shm: {
var buf: [64]u8 = undefined;
kitty_shm_serial +%= 1;
// Bounded: a segment this many transmissions old was never
@@ -2647,61 +2664,51 @@ const Shell = struct {
if (kittyShmName(&old_buf, kitty_shm_serial - kitty_shm_window)) |old| _ = libc.shm_unlink(old) else |_| {}
}
const name = kittyShmName(&buf, kitty_shm_serial) catch break :shm;
- if (!kittyShmWrite(name, place.rgba)) break :shm;
- if (vx.transmitLocalImagePath(s.gpa, sc.tty.writer(), name, @intCast(place.iw), @intCast(place.ih), .shared_mem, .rgba) catch null) |handle|
+ if (!kittyShmWrite(name, rgba)) break :shm;
+ if (vx.transmitLocalImagePath(s.gpa, sc.tty.writer(), name, @intCast(place.raster.w), @intCast(place.raster.h), .shared_mem, .rgba) catch null) |handle|
sc.kitty.put(key, handle) catch vx.freeImage(sc.tty.writer(), handle.id)
else
_ = libc.shm_unlink(name);
}
- if (!sc.kitty.contains(key) and vx.caps.kitty_graphics) {
+ if (!sc.kitty.contains(key)) {
const enc = std.base64.standard.Encoder;
- if (s.gpa.alloc(u8, enc.calcSize(place.rgba.len))) |b64| {
+ if (s.gpa.alloc(u8, enc.calcSize(rgba.len))) |b64| {
defer s.gpa.free(b64);
- _ = enc.encode(b64, place.rgba);
- if (vx.transmitPreEncodedImage(sc.tty.writer(), b64, @intCast(place.iw), @intCast(place.ih), .rgba) catch null) |handle|
+ _ = enc.encode(b64, rgba);
+ if (vx.transmitPreEncodedImage(sc.tty.writer(), b64, @intCast(place.raster.w), @intCast(place.raster.h), .rgba) catch null) |handle|
sc.kitty.put(key, handle) catch vx.freeImage(sc.tty.writer(), handle.id);
} else |_| {}
}
- if (sc.kitty.get(key)) |cached| {
- if (comptime !pardes.pdf_enabled) {
- const child = win.child(.{ .x_off = place.x, .y_off = place.y, .width = place.w, .height = place.h });
- cached.draw(child, .{ .scale = .contain }) catch {};
- } else {
- if (place.native.exact) {
- if (exactKittyPlacement(place, vx.screen.width, vx.screen.height, vx.screen.width_pix, vx.screen.height_pix)) |placement| {
- // The cell keeps its own glyph and colours
- // (Image.draw would reset them): a fragment
- // short of the cell shows the pane under it.
- const x = place.x + placement.cell_x;
- if (win.readCell(x, place.y)) |under| {
- var cell = under;
- cell.image = .{ .img_id = cached.id, .options = placement.options };
- win.writeCell(x, place.y, cell);
- }
- }
- } else if (place.native.fit == .contain) {
- const child = win.child(.{ .x_off = place.x, .y_off = place.y, .width = place.w, .height = place.h });
- cached.draw(child, .{ .scale = .contain }) catch {};
- } else if (kittyPlacement(
- place,
- vx.screen.width,
- vx.screen.height,
- vx.screen.width_pix,
- vx.screen.height_pix,
- )) |placement| {
- const child = win.child(.{
- .x_off = @as(i17, place.x) + placement.cell_x,
- .y_off = @as(i17, place.y) + placement.cell_y,
- .width = placement.cell_cols,
- .height = placement.cell_rows,
- });
- cached.draw(child, placement.options) catch {};
+ const cached = sc.kitty.get(key) orelse continue;
+ const d = place.dst;
+ if (place.at == null) {
+ // Fitted: kitty's own contain, at the top left.
+ const child = win.child(.{ .x_off = d.x, .y_off = d.y, .width = d.w, .height = d.h });
+ cached.draw(child, .{ .scale = .contain }) catch {};
+ } else if (d.h == 1) {
+ if (exactKittyPlacement(place, vx.screen.width, vx.screen.height, vx.screen.width_pix, vx.screen.height_pix)) |placement| {
+ // The cell keeps its own glyph and colours
+ // (Image.draw would reset them): a fragment
+ // short of the cell shows the pane under it.
+ const x = d.x + placement.cell_x;
+ if (win.readCell(x, d.y)) |under| {
+ var cell = under;
+ cell.image = .{ .img_id = cached.id, .options = placement.options };
+ win.writeCell(x, d.y, cell);
}
}
+ } else if (kittyPlacement(place, vx.screen.width, vx.screen.height, vx.screen.width_pix, vx.screen.height_pix)) |placement| {
+ const child = win.child(.{
+ .x_off = @as(i17, d.x) + placement.cell_x,
+ .y_off = @as(i17, d.y) + placement.cell_y,
+ .width = placement.cell_cols,
+ .height = placement.cell_rows,
+ });
+ cached.draw(child, placement.options) catch {};
}
- }
+ };
while (true) {
- var stale: [pardes.MAX_PANES]pardes.ImageCacheKey = undefined;
+ var stale: [pardes.MAX_PANES]u64 = undefined;
var stale_len: usize = 0;
var image_iterator = sc.kitty.iterator();
while (image_iterator.next()) |entry| {