diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 21:02:51 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:08:14 -0300 |
| commit | d8e5fc18f5923c4213de1cb4105a677e725200af (patch) | |
| tree | ec9adccb3ccb3118f1422777180b766cce55ba2b | |
| parent | 5b135dc60d4e9f77be0a4f883439f3200ac30d30 (diff) | |
| download | pardes-d8e5fc18f5923c4213de1cb4105a677e725200af.tar.gz pardes-d8e5fc18f5923c4213de1cb4105a677e725200af.zip | |
fields #41, a view's frontend is one field: windowed, native_images and native_image_patches, the three fields Event.frontend carries, are the session's frontend, a Frontend, so update's frontend arm is p.frontend = f where it copied them one by one; native_image_patches, each process's own, is said so on Frontend (its replica .local), where the session's list said it, so the digest and a dump leave it out as before, and the tape watches frontend where it watched the three (a host's write of patches alone, which only drawing reads, is no longer a set of its own on the tape); the reads in 22 files say p.frontend.native_images (macos.zig's by text, built nowhere here; dump.zig, the persistence agent's, only where it names native_images); views.zig's per-view fields name frontend; a dump written before this change loads it as the default once: an Upgrade or Restore from it comes back as a terminal's view without native images until its frontend says otherwise (a window's says so at once), and the wire's semantics change; gates on tui: core-test 960/960, behaviour-test 238/238, pane-test 171/172 (1 skipped), snap all 108 scripts ok; gui unit-test 1518/1519 (1 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
| -rw-r--r-- | src/Core.zig | 28 | ||||
| -rw-r--r-- | src/Event.zig | 13 | ||||
| -rw-r--r-- | src/Output.zig | 2 | ||||
| -rw-r--r-- | src/TerminalImages.zig | 2 | ||||
| -rw-r--r-- | src/builtins.zig | 8 | ||||
| -rw-r--r-- | src/dump.zig | 2 | ||||
| -rw-r--r-- | src/edit.zig | 2 | ||||
| -rw-r--r-- | src/exec.zig | 2 | ||||
| -rw-r--r-- | src/gui/gui.zig | 14 | ||||
| -rw-r--r-- | src/image.zig | 2 | ||||
| -rw-r--r-- | src/keys.zig | 2 | ||||
| -rw-r--r-- | src/macos.zig | 2 | ||||
| -rw-r--r-- | src/ninep/ctl.zig | 10 | ||||
| -rw-r--r-- | src/pdf_view.zig | 14 | ||||
| -rw-r--r-- | src/tagline.zig | 4 | ||||
| -rw-r--r-- | src/tape.zig | 2 | ||||
| -rw-r--r-- | src/terminal.zig | 10 | ||||
| -rw-r--r-- | src/tui/tui.zig | 12 | ||||
| -rw-r--r-- | src/views.zig | 4 | ||||
| -rw-r--r-- | test/fs_namespace.zig | 4 | ||||
| -rw-r--r-- | test/kitty.zig | 4 | ||||
| -rw-r--r-- | test/pdf.zig | 34 | ||||
| -rw-r--r-- | test/pdf_pointer_bench.zig | 4 | ||||
| -rw-r--r-- | test/pdf_scroll_bench.zig | 2 |
24 files changed, 94 insertions, 89 deletions
diff --git a/src/Core.zig b/src/Core.zig index c5665cb5..0efe447b 100644 --- a/src/Core.zig +++ b/src/Core.zig @@ -23,6 +23,7 @@ const Handover = pardes.Handover; const Host = pardes.Host; const ImagePlace = pardes.ImagePlace; const Jump = pardes.Jump; +const Frontend = @import("Event.zig").Frontend; const Ask = pardes.lsp.Ask; const Key = pardes.Key; const Loc = Jump.Loc; @@ -193,11 +194,10 @@ theme_file_pane: u8 = 0, chrome: colors.ChromeTheme = colors.initial_chrome, /// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES). frames: FrameStats = .{}, -native_images: bool = false, -/// The shell can take a changed image a few rows at a time (a texture row -/// upload, a shared-memory hand-off), so a PDF selection is repainted as -/// it is dragged instead of once on release. -native_image_patches: bool = false, +/// The live view's frontend (Event.frontend): a window, what it draws and +/// the words it takes (builtins.zig `here`); it starts as +/// `Options.windowed` says. +frontend: Frontend = .{ .windowed = false }, quit: bool = false, /// A detached session with no frontend attached: nothing renders, so /// no input ever dismisses a message (Messages.expireUnattended). @@ -218,14 +218,10 @@ pointer_raw_row: u16 = 0, pointer_body_hit: ?Mouse.BodyHit = null, pointer_tag_hit: ?TagHit = null, raw_hover_intent: bool = false, -pointer_inside: bool = false, /// A pixel shell's window, which hears the pointer leave it: only then /// does /status say whether the pointer is over it (a terminal's mouse /// reports never say it left, so a tty would claim it for ever). -/// The live view's frontend is a window (Event.frontend): what it draws, -/// and the words it takes (builtins.zig `here`). It starts as -/// `Options.windowed` says. -windowed: bool = false, +pointer_inside: bool = false, /// The last plain B1 click, for acme's double-click (text.c:881, /// textselect: a second click at the same point within 500 ms). last_click: ?struct { id: usize, on_tag: bool, row: i32, col: i32, ms: i64 } = null, @@ -396,7 +392,7 @@ pub const replica = .{ // A frame, and the timings that make it. "surface", "frames", "chrome", "frame_arena", "scratch", - "needs_frame", "present_skipped", "native_image_patches", + "needs_frame", "present_skipped", "echo", // Drained by every pump before its digest; a replica's queues // are its own. @@ -471,7 +467,7 @@ pub fn create(gpa: std.mem.Allocator, opts: Options) !*Pardes { .pdf_gpa = opts.pdf_allocator orelse gpa, .tree_sitter_gpa = opts.tree_sitter_allocator orelse gpa, .opts = opts, - .windowed = opts.windowed, + .frontend = .{ .windowed = opts.windowed }, .tty_toggle = opts.tty_toggle, .col_tags = @splat(.{ .what = .column, .gpa = gpa }), .global_tag = .{ .what = .workspace, .gpa = gpa }, @@ -1614,7 +1610,7 @@ pub fn update(p: *Pardes, ev: Event) void { if (comptime pdf_enabled) { if (scroll.pane < MAX_PANES) { if (p.panes[scroll.pane]) |pane| { - if (pane.hasPdf() and p.native_images) + if (pane.hasPdf() and p.frontend.native_images) _ = pardes.panes.Pdf.scrollPane(p, pane, @floatCast(scroll.delta_pixels), scroll.glide); } } @@ -1631,9 +1627,7 @@ pub fn update(p: *Pardes, ev: Event) void { }, .handed => |h| p.handover.finish(p, h.seq, h.to, h.failure), .frontend => |f| { - p.windowed = f.windowed; - p.native_images = f.native_images; - p.native_image_patches = f.native_image_patches; + p.frontend = f; }, .pointer_leave => { p.pointer_inside = false; @@ -2126,7 +2120,7 @@ pub const Boot = enum { pub const Options = struct { tty_only: bool = false, - /// The first view's frontend is a window (`Pardes.windowed`), as a + /// The first view's frontend is a window (`Pardes.frontend`), as a /// window's build says: an option, taped with the rest, so that a /// window's build replaying a terminal's session starts as it did. windowed: bool = platform == .gui, diff --git a/src/Event.zig b/src/Event.zig index cc359974..6b2bb8a2 100644 --- a/src/Event.zig +++ b/src/Event.zig @@ -146,4 +146,15 @@ pub const Event = union(enum) { }; /// A view's frontend: what a client of a session elsewhere says it is. -pub const Frontend = struct { windowed: bool, native_images: bool = false, native_image_patches: bool = false }; +pub const Frontend = struct { + windowed: bool, + native_images: bool = false, + /// The shell can take a changed image a few rows at a time (a texture + /// row upload, a shared-memory hand-off), so a PDF selection is + /// repainted as it is dragged instead of once on release. Each + /// process's own: in no digest and no dump (Pardes.replica.local was + /// where it said so). + native_image_patches: bool = false, + + pub const replica = .{ .local = .{"native_image_patches"} }; +}; diff --git a/src/Output.zig b/src/Output.zig index 027502bc..d53ad968 100644 --- a/src/Output.zig +++ b/src/Output.zig @@ -985,7 +985,7 @@ pub fn openConfig(p: *Pardes, id: usize) !void { .theme_file = pardes.colors.loadedThemeFile(p), .compiled_default_shell = config.defaultShell(), .hover_delay_frames = config.look_preview_delay_frames, - .native_images = p.native_images, + .native_images = p.frontend.native_images, .capabilities = builtins.viewCapabilities(p), .state = &p.settings, }); diff --git a/src/TerminalImages.zig b/src/TerminalImages.zig index 06b96f4b..0131568d 100644 --- a/src/TerminalImages.zig +++ b/src/TerminalImages.zig @@ -160,7 +160,7 @@ pub fn draw( const bottom = pages.getBottomRight(.viewport) orelse return; const cw: u32 = @max(1, p.cell_pixels.w); const ch: u32 = @max(1, p.cell_pixels.h); - const pixels = p.native_images and !ti.petscii; + const pixels = p.frontend.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. diff --git a/src/builtins.zig b/src/builtins.zig index 7a9c2df1..5186ac55 100644 --- a/src/builtins.zig +++ b/src/builtins.zig @@ -42,16 +42,16 @@ const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = fal pub const capabilities: config.Runtime.Capabilities = if (desktop) window_capabilities else frontend; /// What the live view's frontend takes: a window's, or a terminal's -/// (`Pardes.windowed`, which its client says, Event.frontend). +/// (`Pardes.frontend`, which its client says, Event.frontend). pub fn viewCapabilities(p: *const Pardes) config.Runtime.Capabilities { if (comptime !desktop) return frontend; - return if (p.windowed) window_capabilities else terminal_capabilities; + return if (p.frontend.windowed) window_capabilities else terminal_capabilities; } /// The live view's frontend, by name (the Settings report's platform). pub fn viewPlatform(p: *const Pardes) []const u8 { if (comptime !desktop) return @tagName(pardes.platform); - return if (p.windowed) "gui" else "tui"; + return if (p.frontend.windowed) "gui" else "tui"; } /// Where a builtin acts: at the pane it runs from, or on the editor as a @@ -183,7 +183,7 @@ pub const registry = struct { /// cannot show) in a window's view alone. The rest of a build's words are /// every view's. pub fn here(p: *const Pardes, b: Builtin()) bool { - return hereFor(b, viewCapabilities(p), !desktop or p.windowed); + return hereFor(b, viewCapabilities(p), !desktop or p.frontend.windowed); } /// `here` for a frontend of these capabilities, windowed or not. diff --git a/src/dump.zig b/src/dump.zig index faf6fb23..455f172d 100644 --- a/src/dump.zig +++ b/src/dump.zig @@ -527,7 +527,7 @@ fn reviveSession(p: *Pardes, previous: ?*Pardes, resumed: bool) !void { // The host's facts, as this host told them. p.cell_pixels = old.cell_pixels; p.row_metrics = old.row_metrics; - p.native_images = old.native_images; + p.frontend.native_images = old.frontend.native_images; // Its panes close here, each noted where it was, as at its end. for (old.panes) |slot| if (slot) |pane| old.noteClosed(pane); p.recent = old.recent.clone(p.recentGpa()); diff --git a/src/edit.zig b/src/edit.zig index 85718293..8691633c 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -350,7 +350,7 @@ pub fn spanHas(r: i32, c: i32, ar: i32, ac: i32, br: i32, bc: i32) bool { /// the active modal selection as text, if any pub fn currentSelText(p: *Pardes, pane: *Pane) ?[]const u8 { - if (comptime pdf_enabled) if (p.native_images) if (pane.pdf) |pv| + if (comptime pdf_enabled) if (p.frontend.native_images) if (pane.pdf) |pv| if (pv.selection != null and pv.selection_text.len > 0) return pv.selection_text; if (!pane.body.vsel.active) return null; return vselText(p, &pane.body); diff --git a/src/exec.zig b/src/exec.zig index 3b68a6fd..2f17733f 100644 --- a/src/exec.zig +++ b/src/exec.zig @@ -269,7 +269,7 @@ fn heldPane(p: *Pardes, first: usize, k: usize) ?*Pane { pub fn heldSelection(p: *Pardes, first: usize) ?[]const u8 { for (0..p.panes.len + 2) |k| { const t = heldPane(p, first, k) orelse continue; - if (comptime pdf_enabled) if (p.native_images) if (t.pdf) |pv| { + if (comptime pdf_enabled) if (p.frontend.native_images) if (t.pdf) |pv| { if (pv.selection != null and pv.selection_text.len > 0) return pv.selection_text; }; diff --git a/src/gui/gui.zig b/src/gui/gui.zig index 99609e5e..d6efa27c 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -1757,9 +1757,9 @@ fn localSession( defer core.deinit(); g.hit_core = core; defer g.hit_core = null; - core.windowed = true; - core.native_images = true; - core.native_image_patches = true; + core.frontend.windowed = true; + core.frontend.native_images = true; + core.frontend.native_image_patches = true; observeGuiFont(g, core); syncTaglineFont(g, core); syncLigatures(g, core); @@ -1895,11 +1895,11 @@ fn localSession( shell.stopPtys(); clearNativeImages(g); g.prepared_images.clearRetainingCapacity(); - nc.native_images = true; - nc.native_image_patches = true; + nc.frontend.native_images = true; + nc.frontend.native_image_patches = true; nc.host = host; if (fs) |f| f.reset(nc); - nc.windowed = true; + nc.frontend.windowed = true; core.deinit(); core = nc; frame_probe = &nc.frames; // the old core's ring went with it @@ -2969,7 +2969,7 @@ fn wheelAt(g: *Gui, in: *Input, w: WheelTurn, mc: MouseCell) void { }; if (hit) |id| { const pdf_target = if (comptime pardes.pdf_enabled) - core.native_images and core.panes[id].?.pdfPage() != null + core.frontend.native_images and core.panes[id].?.pdfPage() != null else false; const pane = core.panes[id].?; diff --git a/src/image.zig b/src/image.zig index aeb0423a..417cc20e 100644 --- a/src/image.zig +++ b/src/image.zig @@ -1054,7 +1054,7 @@ pub fn draw( ) void { ensureDecoded(p, state); if (state.rgba.len == 0 or cols == 0 or rows == 0) return; - if (!state.glyph_art and p.native_images) { + if (!state.glyph_art and p.frontend.native_images) { _ = p.appendImagePlace(.{ .pane = pane_id, .serial = serial, diff --git a/src/keys.zig b/src/keys.zig index dbc31f69..9f16b42a 100644 --- a/src/keys.zig +++ b/src/keys.zig @@ -364,7 +364,7 @@ pub fn handleKey(p: *Pardes, key: Key) void { return; } edit.pinPaneCursor(p, &pane.body); - const explicit = (p.native_images and pane.hasPdfSelection()) or + const explicit = (p.frontend.native_images and pane.hasPdfSelection()) or (pane.body.vsel.active and pane.body.vsel.explicit); if (explicit) { if (exec.chordEachSel(p, pane, cmd)) return; diff --git a/src/macos.zig b/src/macos.zig index d7e9f454..d46f6cd4 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -530,7 +530,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { std.mem.eql(u8, std.mem.span(v), "1") else @import("pardes_config").workspace_tag; - core.native_images = true; + core.frontend.native_images = true; var prompt_rcs = host_io.Shell.prepare(); errdefer prompt_rcs.deinit(); diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9c5b82bf..504a4e2d 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -389,7 +389,7 @@ pub fn statusText(p: *Pardes) []const u8 { // Whether the pointer is over this window: what a grip let go past // another window's edge asks of every window, to find the one it was // let go over (Handover.zig), where no window may know another's place. - if (p.windowed) w.writer.print("pointer {s}\n", .{if (p.pointer_inside) "in" else "out"}) catch {}; + if (p.frontend.windowed) w.writer.print("pointer {s}\n", .{if (p.pointer_inside) "in" else "out"}) catch {}; return w.written(); } @@ -1391,11 +1391,11 @@ test "status in a window says whether the pointer is over it" { // there is a terminal's view. const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - p.windowed = true; + p.frontend.windowed = true; var lines = std.mem.tokenizeScalar(u8, rd(p, root_status, 0, 4096).bytes, '\n'); for (0..3) |_| _ = lines.next(); try testing.expectEqualStrings("pointer out", lines.next().?); - p.windowed = false; + p.frontend.windowed = false; } @@ -1574,9 +1574,9 @@ test "a builtin for one kind of pane is refused on another, and still acts on it // Petscii chose; with them, what it chose. for ([_]bool{ false, true }) |art| { doc.image.?.glyph_art = art; - p.native_images = false; + p.frontend.native_images = false; try testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(p, doc), " petscii:on ") != null); - p.native_images = true; + p.frontend.native_images = true; try testing.expect(std.mem.indexOf(u8, try pardes.tagline.tagPrefix(p, doc), if (art) " petscii:on " else " petscii:off ") != null); } } diff --git a/src/pdf_view.zig b/src/pdf_view.zig index 8e9c1517..bb960139 100644 --- a/src/pdf_view.zig +++ b/src/pdf_view.zig @@ -2329,7 +2329,7 @@ pub fn applyNormal(core: *pardes.Pardes, pane: *pardes.Pane, a: modal.Normal.Act if (comptime !enabled) return; const state = pane.pdf orelse return; const gpa = core.pdf_gpa; - const native = core.native_images; + const native = core.frontend.native_images; const cells: CellPixels = .{ .w = core.cell_pixels.w, .h = core.cell_pixels.h }; const viewport = paneViewport(core, pane); const placed = if (native) paneGeometry(core, pane) else null; @@ -2983,7 +2983,7 @@ pub fn pageAtGridRow(core: *const pardes.Pardes, pane: *const pardes.Pane, row: /// Some page of the pane is placed where it is drawn. pub fn paneNativeReady(core: *const pardes.Pardes, pane: *const pardes.Pane) bool { if (comptime !enabled) return false; - if (!core.native_images) return false; + if (!core.frontend.native_images) return false; const state = if (pane.pdf) |view| view else return false; const view = paneViewport(core, pane) orelse return false; for (state.rasters[0..state.rasters_len]) |*raster| { @@ -2999,7 +2999,7 @@ pub fn nativePageAtGridRow( row: u16, ) ?usize { if (comptime !enabled) return null; - if (!core.native_images) return null; + if (!core.frontend.native_images) return null; const state = if (pane.pdf) |view| view else return null; const page = pageAtGridRow(core, pane, row) orelse return null; const view = paneViewport(core, pane) orelse return null; @@ -3246,7 +3246,7 @@ pub fn highlightInput( .hover_page = hover_page, .hover_color = if (link_hover) core.theme().box else selection_color, .selection_color = selection_color, - .live = core.native_image_patches, + .live = core.frontend.native_image_patches, }; } @@ -3279,7 +3279,7 @@ fn stripAt(state: *State, view: Viewport) f64 { pub fn verticalWheel(core: *pardes.Pardes, pane: *pardes.Pane, direction: i8) void { if (comptime !enabled) return; - if (!core.native_images) { + if (!core.frontend.native_images) { // The text layer: a page a notch. const state = pane.pdf orelse return; if (stepPage(state, core.pdf_gpa, direction)) resetPageChrome(pane); @@ -3293,7 +3293,7 @@ pub fn verticalWheel(core: *pardes.Pardes, pane: *pardes.Pane, direction: i8) vo pub fn horizontalWheel(core: *pardes.Pardes, pane: *pardes.Pane, direction: i8) void { if (comptime !enabled) return; const state = pane.pdf orelse return; - if (!core.native_images or state.fit != .height) return; + if (!core.frontend.native_images or state.fit != .height) return; const placed = paneGeometry(core, pane) orelse return; const cols: u32 = @intCast(@max(1, config.wheel_cols)); _ = panPixels(state, placed, .horizontal, direction, scaledStep(core.cell_pixels.w, cols)); @@ -3310,7 +3310,7 @@ pub fn draw( rail: *pardes.Region, ) bool { if (comptime !enabled) return false; - if (!core.native_images or rect.h <= pane.tag_rows) return false; + if (!core.frontend.native_images or rect.h <= pane.tag_rows) return false; const state = pane.pdf orelse return false; const view = paneViewport(core, pane) orelse return false; const key = TintKey{ .mode = state.tint, .colors = tintColors(core) }; diff --git a/src/tagline.zig b/src/tagline.zig index 9655f537..8d65f8c6 100644 --- a/src/tagline.zig +++ b/src/tagline.zig @@ -117,7 +117,7 @@ pub fn pathPrefix(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]co if (comptime pdf_enabled) if (pane.pdf) |pv| return std.fmt.allocPrint(arena, "{s} [{d}/{d}]", .{ pv.path, pv.page + 1, pv.page_count }); // What is drawn: with no graphics, glyph art whatever `Petscii` says. - if (pane.image) |*state| return panes.Image.tagPrefix(arena, state, state.glyph_art or !p.native_images); + if (pane.image) |*state| return panes.Image.tagPrefix(arena, state, state.glyph_art or !p.frontend.native_images); // A command pane: its directory, the line it runs, and how that went. // Its first line only, cut to 48 bytes at a character's start: a tag's // first row is where the prefix ends, and a line that ran over to a @@ -151,7 +151,7 @@ pub fn pathPrefix(p: *const Pardes, arena: std.mem.Allocator, pane: *Pane) ![]co // A terminal showing kitty graphics says how it draws them, as an image // pane does, and so does one drawing them as glyph art by choice. if (panes.terminal.petscii(pane)) |chosen| { - const on = chosen or !p.native_images; + const on = chosen or !p.frontend.native_images; if (chosen or panes.terminal.hasImages(pane)) return std.fmt.allocPrint(arena, "{s} petscii:{s}", .{ (try shownDir(arena, pane)), if (on) "on" else "off" }); } diff --git a/src/tape.zig b/src/tape.zig index c76fd445..1c58e886 100644 --- a/src/tape.zig +++ b/src/tape.zig @@ -170,7 +170,7 @@ pub const shape = blk: { }; /// Fields a host writes straight into the core between its calls. -const watched = .{ "native_images", "native_image_patches", "present_skipped", "needs_frame", "quit", "windowed", "active", "unattended" }; +const watched = .{ "frontend", "present_skipped", "needs_frame", "quit", "active", "unattended" }; const Kind = enum(u8) { input, done, host, ret, set, digest }; /// A digest record's kind byte (replica.zig reads a unit's last). diff --git a/src/terminal.zig b/src/terminal.zig index 22371a78..6f9e2071 100644 --- a/src/terminal.zig +++ b/src/terminal.zig @@ -3219,7 +3219,7 @@ test "a terminal's kitty graphics image is drawn where its program placed it, an const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; p.active = 0; p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } }); var frame = std.heap.ArenaAllocator.init(gpa); @@ -3278,7 +3278,7 @@ test "ED 3 takes away a kitty placement whose row it erased: it never comes back const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } }); var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -3345,7 +3345,7 @@ test "a virtual kitty placement shows through its placeholder cells, which draw const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; p.update(.{ .resize = .{ .cols = 80, .rows = 24, .cell_pixels = .{ .w = 10, .h = 20 } } }); var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -3397,7 +3397,7 @@ test "without pixels, or by the Petscii builtin, a terminal's image is glyph art }.check; // A shell that draws no pixels (a tty under no kitty graphics): forced. - p.native_images = false; + p.frontend.native_images = false; var s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 0), imagePlaces(s).len); try std.testing.expect(painted(s.at(tx, y)) and painted(s.at(tx + 1, y))); @@ -3407,7 +3407,7 @@ test "without pixels, or by the Petscii builtin, a terminal's image is glyph art // Pixels where they can be drawn; the builtin flips the pane to glyphs // and back. - p.native_images = true; + p.frontend.native_images = true; _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); try std.testing.expectEqual(@as(usize, 1), imagePlaces(s).len); diff --git a/src/tui/tui.zig b/src/tui/tui.zig index 1e4b238e..e8a5c44c 100644 --- a/src/tui/tui.zig +++ b/src/tui/tui.zig @@ -1090,7 +1090,7 @@ test "host watch closes initial race and reloads rename-over PDF while idle" { } try std.testing.expect(std.mem.indexOf(u8, pane.msg[0..pane.msg_len], "reloaded") != null); - core.native_images = true; + core.frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const surface = try core.render(frame.allocator()); @@ -1115,7 +1115,7 @@ const PdfWheelTarget = struct { pane: usize, page: usize }; fn nativePdfWheelTarget(core: *const pardes.Pardes, mouse: vaxis.Mouse) ?PdfWheelTarget { if (comptime !pardes.pdf_enabled) return null; - if (!core.native_images or mouse.type != .press or + if (!core.frontend.native_images or mouse.type != .press or (mouse.button != .wheel_up and mouse.button != .wheel_down) or mouse.col < 0 or mouse.row < 0) return null; const col: u16 = @intCast(mouse.col); @@ -1750,7 +1750,7 @@ fn localSession( sh.from = 0; if (live.on) startInput(loop, live) catch {}; if (live.on) clearNativeImages(&live.kitty, &live.vx, &live.tty); - nc.native_images = live.on and live.vx.caps.kitty_graphics; + nc.frontend.native_images = live.on and live.vx.caps.kitty_graphics; nc.unattended = !live.on; sh.peers.alone_unattended = !live.on; if (fs) |f| f.reset(nc); @@ -2002,7 +2002,7 @@ const Shell = struct { const screen = s.term() orelse return; stopInput(s.io, &screen.thread); screen.leave(); - s.core.native_images = false; + s.core.frontend.native_images = false; s.setAttended(false); // The stub's stdin, stdout and stderr were its terminal too. const null_fd = libc.open("/dev/null", .{ .ACCMODE = .RDWR, .CLOEXEC = true }, @as(libc.mode_t, 0)); @@ -2596,11 +2596,11 @@ const Shell = struct { }; const sc = s.term() orelse return; - s.core.native_image_patches = sc.feed.shm.load(.acquire); + s.core.frontend.native_image_patches = sc.feed.shm.load(.acquire); if (sc.caps_pending and sc.on and sc.vx.queries_done.load(.unordered)) { sc.caps_pending = false; sc.vx.enableDetectedFeatures(sc.tty.writer()) catch {}; - s.core.native_images = sc.vx.caps.kitty_graphics; + s.core.frontend.native_images = sc.vx.caps.kitty_graphics; if (sc.vx.caps.kitty_graphics) kittyShmProbe(sc.tty.writer(), &sc.feed); sc.vx.queueRefresh(); s.core.needs_frame = true; diff --git a/src/views.zig b/src/views.zig index dff25af6..d598e2fc 100644 --- a/src/views.zig +++ b/src/views.zig @@ -37,7 +37,7 @@ pub const fields = [_][:0]const u8{ "col_x", "col_w", "active", "jumps", "active_column", - "native_images", "native_image_patches", "windowed", + "frontend", "drag", "mouse_grab", "window_focused", "focus_told", "hover_col", "hover_row", "pointer_raw_col", "pointer_raw_row", "pointer_body_hit", "pointer_tag_hit", "raw_hover_intent", "pointer_inside", @@ -434,7 +434,7 @@ pub fn open(p: *Pardes) ?u8 { }; const slot = p.parked[k].?; slot.* = .{ .view = .{ .screen_w = p.screen_w, .screen_h = p.screen_h } }; - inline for (sized ++ laid_out ++ .{ "windowed", "native_images", "native_image_patches" }) |name| + inline for (sized ++ laid_out ++ .{"frontend"}) |name| @field(slot.view, name) = @field(p, name); // A query's mark on the jumps is the view's that asked it. slot.view.jumps.force = false; diff --git a/test/fs_namespace.zig b/test/fs_namespace.zig index 00b2461a..d54eb9a2 100644 --- a/test/fs_namespace.zig +++ b/test/fs_namespace.zig @@ -89,7 +89,7 @@ test "transactional restore preserves host capabilities and advances pane identi p.lsp_ask.seq = 41; p.pipe.seq = 73; if (@hasField(pardes.CellPixels, "w")) p.cell_pixels = .{ .w = 9, .h = 18 }; - p.native_images = true; + p.frontend.native_images = true; p.fs.socket_path = "/tmp/session.sock"; p.fs.tcp_address = .{ .ip4 = .loopback(5640) }; try pardes.dump.dumpState(p); @@ -98,7 +98,7 @@ test "transactional restore preserves host capabilities and advances pane identi try std.testing.expectEqual(@as(u32, 41), restored.lsp_ask.seq); try std.testing.expectEqual(@as(u32, 73), restored.pipe.seq); try std.testing.expectEqual(p.cell_pixels, restored.cell_pixels); - try std.testing.expect(restored.native_images); + try std.testing.expect(restored.frontend.native_images); // The dump's pane, its serial too; a new one is past the old session's. try std.testing.expectEqual(pane.serial, restored.panes[0].?.serial); try std.testing.expect(restored.next_serial >= p.next_serial); diff --git a/test/kitty.zig b/test/kitty.zig index 5531242e..daa01060 100644 --- a/test/kitty.zig +++ b/test/kitty.zig @@ -71,7 +71,7 @@ const Rig = struct { std.testing.log_level = .err; // A core boots one shell or the classic three. const p = try Pardes.init(gpa, .{ .cols = 120, .rows = 40, .shells = if (shells > 1) 3 else 1 }); - p.native_images = true; + p.frontend.native_images = true; p.update(.{ .resize = .{ .cols = 120, .rows = 40, .cell_pixels = .{ .w = 10, .h = 20 } } }); for (p.panes) |slot| if (slot) |each| { each.body.mode = .tty; @@ -1310,7 +1310,7 @@ test "kitty: recorded kitten icat and chafa traffic replays: answers whole, imag test "kitty: under a shell that draws no pixels, a 64x64 image over 8x4 cells is glyph art in every cell" { var r = try Rig.init(1); defer r.deinit(); - r.p.native_images = false; + r.p.frontend.native_images = false; r.p.update(.{ .resize = .{ .cols = 120, .rows = 40, .cell_pixels = .{ .w = 8, .h = 16 } } }); r.drain(); // Not the frame's arena: each frame resets that. diff --git a/test/pdf.zig b/test/pdf.zig index 2f14fb2f..b66db1df 100644 --- a/test/pdf.zig +++ b/test/pdf.zig @@ -45,7 +45,7 @@ const PdfLinkTests = struct { const path = try std.fmt.allocPrint(std.testing.allocator, "{s}/links.pdf", .{dir_buf[0..len]}); defer std.testing.allocator.free(path); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 100, .rows = 36 }); - p.native_images = true; + p.frontend.native_images = true; p.panes[0].?.pdf.?.fit = .height; return p; } @@ -375,7 +375,7 @@ test "watched PDF reload replaces MuPDF state and preserves the reading view" { const sections = p.panes[sections_id].?; try std.testing.expect(sections.file.?.content.len > 0); - p.native_images = true; + p.frontend.native_images = true; state.fit = .height; state.tint = .full; state.pan_x = 1234; @@ -492,7 +492,7 @@ test "PDF reload does not re-center an already revealed matching search" { const path = try std.fmt.bufPrint(&path_buf, ".zig-cache/tmp/{s}/search.pdf", .{tmp.sub_path}); const p = try Pardes.init(gpa, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; const pane = p.panes[0].?; const state = pane.pdf.?; try state.setSearchQuery(p.pdf_gpa, "Pardes"); @@ -559,7 +559,7 @@ test "MuPDF pane renders, navigates, searches, and round-trips its page" { try std.testing.expectEqualStrings(expected_tag, initial_tag); try std.testing.expect(std.mem.endsWith(u8, initial_tag, pane_tail)); - p.native_images = true; + p.frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); const first = try p.render(frame.allocator()); @@ -889,7 +889,7 @@ test "a fling's banded pages show the reader exactly what whole pages would" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .file = "docs/design.pdf", .cols = 120, .rows = 40 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; const pane = p.panes[0].?; const pv = pane.pdf.?; var frame = std.heap.ArenaAllocator.init(gpa); @@ -993,7 +993,7 @@ test "a tall page is drawn at the display's resolution, in bands that are the wh defer gpa.free(path); const p = try Pardes.init(gpa, .{ .file = path, .cols = 120, .rows = 40 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; const pane = p.panes[0].?; const pv = pane.pdf.?; var frame = std.heap.ArenaAllocator.init(gpa); @@ -1154,7 +1154,7 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.native_images = true; + p.frontend.native_images = true; // A second pane, then focus it and come back: `Last` has somewhere to go // and the PDF is where the keys land. @@ -1214,7 +1214,7 @@ test "Escape cancels PDF chrome in place, then leaves the pane; Shift-Escape lea try std.testing.expect(pv.selection != null); // A text-only page shows neither: one Escape drops them and goes. - p.native_images = false; + p.frontend.native_images = false; p.update(.{ .key = .{ .cp = Key.escape } }); try std.testing.expectEqual(@as(usize, 0), p.active); try pv.setSearchQuery(p.pdf_gpa, "Pardes"); @@ -1236,7 +1236,7 @@ test "PDF continuous strip renders every intersecting short page" { const pane = p.panes[0].?; const pv = pane.pdf.?; try std.testing.expect(pv.page_count > 3); - p.native_images = true; + p.frontend.native_images = true; // A legal wide MediaBox can make more than three pages intersect one // viewport. Seed tiny matching rasters so this tests transport/cache @@ -1310,7 +1310,7 @@ test "PDF tint and tinted theme changes rebuild every visible raster only" { defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.native_images = true; + p.frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1433,7 +1433,7 @@ test "PDF resize preserves page-relative document position" { defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.native_images = true; + p.frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1484,7 +1484,7 @@ test "PDF pane geometry change preserves its page-relative position" { p.sync(); // rects for the new column, exactly as the two-pane boot did const pane = p.panes[0].?; const pv = pane.pdf.?; - p.native_images = true; + p.frontend.native_images = true; var frame = std.heap.ArenaAllocator.init(gpa); defer frame.deinit(); @@ -1536,7 +1536,7 @@ test "PDF n/N addresses and reveals distinct MuPDF hits on one page" { defer p.deinit(); const pane = p.panes[0].?; const pv = pane.pdf.?; - p.native_images = true; + p.frontend.native_images = true; var page_hits = try pv.document.search(gpa, 0, "Pardes"); defer page_hits.deinit(gpa); @@ -1656,7 +1656,7 @@ test "PDF native mouse selection, Look, and highlights share page geometry" { try std.testing.expect(pane.pdf.?.selection == null); pane.sel[sel_slot].state = .none; - p.native_images = true; + p.frontend.native_images = true; _ = frame.reset(.retain_capacity); const plain = try p.render(frame.allocator()); const plain_revision = plain.images.items[0].native.revision; @@ -2027,7 +2027,7 @@ test "PDF Back and Forward clear selections and land on recorded pages" { if (!pdf_enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .file = "docs/design.pdf", .cols = 80, .rows = 28 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; const pane = p.panes[0].?; const state = pane.pdf.?; try std.testing.expect(state.page_count > 1); @@ -2104,7 +2104,7 @@ test "a PDF's jumps: Back after a far jump returns to the exact offset, two plac if (!pdf_enabled) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .file = jumpPdf(), .cols = 80, .rows = 28 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; const id = p.active; const pane = p.panes[id].?; const pv = pane.pdf.?; @@ -2144,7 +2144,7 @@ test "a PDF's jumps: JumpScope file keeps to the PDF, and a closed PDF reopens a const path = try std.fmt.bufPrint(&path_buf, "{s}/docs/design.pdf", .{cwd}); const p = try Pardes.init(std.testing.allocator, .{ .file = path, .cols = 80, .rows = 28 }); defer p.deinit(); - p.native_images = true; + p.frontend.native_images = true; try std.testing.expectEqual(config.Runtime.JumpScope.file, p.settings.jump_scope); const doc = p.active; const pane = p.panes[doc].?; diff --git a/test/pdf_pointer_bench.zig b/test/pdf_pointer_bench.zig index 573b8766..d6cf0e19 100644 --- a/test/pdf_pointer_bench.zig +++ b/test/pdf_pointer_bench.zig @@ -156,8 +156,8 @@ fn verify(core: *pardes.Pardes, arena: std.mem.Allocator) !void { fn measure(config: Config, round: usize) !u64 { const core = try pardes.Pardes.init(gpa, .{ .file = config.path, .cols = cols, .rows = rows }); defer core.deinit(); - core.native_images = true; - if (comptime @hasField(pardes.Pardes, "native_image_patches")) core.native_image_patches = config.live; + core.frontend.native_images = true; + if (comptime @hasField(pardes.Pardes, "native_image_patches")) core.frontend.native_image_patches = config.live; var run: Run = .{ .core = core, .arena = .init(gpa), .config = config, .round = round }; defer run.arena.deinit(); const cell: pardes.CellPixels = .{ .w = config.cell_w, .h = config.cell_h }; diff --git a/test/pdf_scroll_bench.zig b/test/pdf_scroll_bench.zig index 1a27b828..9ef11a1c 100644 --- a/test/pdf_scroll_bench.zig +++ b/test/pdf_scroll_bench.zig @@ -321,7 +321,7 @@ fn bootCore(config: Config) !*pardes.Pardes { .rows = bench_rows, }); errdefer core.deinit(); - core.native_images = true; + core.frontend.native_images = true; core.update(.{ .resize = .{ .cols = bench_cols, .rows = bench_rows, |
