From c1917b949b9580de8bf0977874a210f0266812da Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 06:24:42 -0300 Subject: kinds #14, the core's PDF code gone: pdf.zig and pdf_view.zig leave and every pdf_enabled branch with them; look, Jump, Recent, dumps (one from before the addon opens as its pane), the watch, mouse, keys, the rail and the tag go through Kind for any kind's pane; test/pdf.zig's behaviours are T1 cases over 9P (addons_pdf.zig) and pane cases (a Shadow over a replica, a file changed under it), the harnesses load pdf.so by path Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/draw.zig | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'src/draw.zig') diff --git a/src/draw.zig b/src/draw.zig index c97e2a6c..8538c6a6 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -28,7 +28,6 @@ const Text = panes.Text; const Rect = layout.Rect; const Region = @import("surface.zig").Region; const TagKind = @import("Layer.zig").Kind; -const pdf_enabled = panes.Pdf.enabled; const wordBoundsAtCol = tagline.wordBoundsAtCol; const BOX_H = pardes.BOX_H; const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET; @@ -67,17 +66,13 @@ pub fn place(p: *Pardes, s: *Surface) void { const doc: u64 = if (pane.file) |f| std.hash.Wyhash.hash(if (f.output != null) f.revision else 0, f.path) else 0; s.addRegion(.{ .kind = .body, .owner = owner, .serial = pane.serial, .active = active, .line = line, .doc = doc, .rect = .{ .x = r.x + config.GUTTER, .y = body_y, .w = r.w - config.GUTTER, .h = body_h } }); var rail: Region = .{ .kind = .rail, .owner = owner, .serial = pane.serial, .active = active, .rect = .{ .x = r.x, .y = body_y, .w = config.GUTTER, .h = body_h } }; - // An image's rail has no thumb; a native PDF's is measured as its - // pages are placed (Pdf.draw); every other pane's is here. + // A kind's rail is its paint's (drawPane); every other pane's is + // here. if (pane.addon == null and body_h > 0) { const sb: struct { total: usize, offset: usize, len: usize } = if (pane.file) |*f| .{ .total = panes.File.nlines(p.gpa, f), .offset = f.scroll, .len = pane.rows, - } else if (pane.pdfPage()) |page| .{ - .total = if (comptime pdf_enabled) pane.pdf.?.page_count else 1, - .offset = page, - .len = 1, } else blk: { const gsb = panes.terminal.scrollbar(pane); break :blk .{ .total = gsb.total, .offset = gsb.offset, .len = gsb.len }; @@ -182,14 +177,6 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { s.rows = v.screen_h; s.cursor = null; s.pointer_shape = .arrow; - if (comptime pdf_enabled) if (p.pdf_hover_preview) |preview| { - if (preview.probe.link != null and preview.pane < p.panes.len) { - if (p.panes[preview.pane]) |pane| { - if (pane.serial == preview.serial and panes.Pdf.paneNativeReady(p, pane)) - s.pointer_shape = .link; - } - } - }; // A look-hover preview means the pointed word is a real Look or Exec // operand: the same plumbing a click would act on. Hosts that model // the pointer per-text (the macOS I-beam) read this as "target" and @@ -319,9 +306,9 @@ pub fn render(p: *Pardes, arena: std.mem.Allocator) !*Surface { if (at.file) |*f| { sb_off = f.scroll; sb_total = panes.File.nlines(p.gpa, f); - } else if (at.pdfPage()) |page| { - sb_off = page; - sb_total = if (comptime pdf_enabled) at.pdf.?.page_count else 0; + } else if (at.addon != null) { + sb_off = 0; + sb_total = 0; } else { const sb = panes.terminal.scrollbar(at); sb_off = sb.offset; @@ -435,8 +422,6 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: if (pane.collapsed) return; const rail = s.region(.rail, id).?; - if (comptime pdf_enabled) - if (pane.hasPdf() and panes.Pdf.draw(p, s, pane, r, id, tx, tw, rail)) return; if (pane.addon != null) { // Below the notice chips: a picture is drawn after the cells (the @@ -445,11 +430,21 @@ fn renderPane(p: *Pardes, s: *Surface, arena: std.mem.Allocator, pane: *Pane, r: const shown = pane.notices.span(); const body_h = (r.h -| pane.tag_rows) -| shown; pardes.Kind.draw(p, s, arena, pane, id, tx, body_y + shown, tw, body_h); - // thumbless, but the same one column as the real scrollbar below — - // that is the whole point of drawing it, and like that one it runs - // past the notice bands so the gutter has no notch in it + // The same one column as the real scrollbar below, running past + // the notice bands so the gutter has no notch in it; its thumb + // where this frame's paint said its window is in its whole (a + // PDF's strip), none for a kind that said nothing (an image). s.fill(rail.rect.x, rail.rect.y, 1, rail.rect.h, .{ .bg = .{ .rgb = chrome.scroll_track } }); s.fill(rail.rect.x + 1, rail.rect.y, 1, rail.rect.h, .{ .bg = pane_bg }); + const k = pane.addon.?; + if (k.thumb_span > 0) { + const track: f32 = @floatFromInt(rail.rect.h); + rail.thumb_y = @intFromFloat(@min(track - 1, @floor(k.thumb_at * track))); + rail.thumb_h = @intFromFloat(@min(track - @as(f32, @floatFromInt(rail.thumb_y)), @max(1, k.thumb_span * track))); + rail.thumb_at = k.thumb_at; + rail.thumb_span = k.thumb_span; + s.fill(rail.rect.x, rail.rect.y + rail.thumb_y, 1, rail.thumb_h, .{ .bg = .{ .rgb = chrome.scroll_thumb } }); + } return; } @@ -566,8 +561,6 @@ fn tagTintRange(pane: *const Pane, tag: []const u8, prefix_len: usize) ?struct { if (k.path.len == 0) return null; start = std.mem.lastIndexOf(u8, tag[0..@min(prefix_len, tag.len)], k.path) orelse return null; break :blk k.path; - } else if (comptime pdf_enabled) blk: { - break :blk if (pane.pdf) |state| state.path else return null; } else return null; const basename = if (std.mem.lastIndexOfScalar(u8, name, '/')) |slash| slash + 1 else 0; if (basename == name.len) return null; -- cgit v1.3