diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 11:21:15 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 12:41:12 -0300 |
| commit | cfd2b993feda1b3f7474225bb32db8cac8edc5ae (patch) | |
| tree | 3248246c043fd1865e74adb979a9cb555f918cd6 /src/pardes.zig | |
| parent | c0b2e5d9194ce35b9fbb58d8d6e18de66cb209a8 (diff) | |
| download | pardes-cfd2b993feda1b3f7474225bb32db8cac8edc5ae.tar.gz pardes-cfd2b993feda1b3f7474225bb32db8cac8edc5ae.zip | |
targets: the ESP32-P4 board port goes (src/esp32p4*.zig and src/esp32p4/, -Dplatform=esp32p4 with its pinned riscv32 target, -Desp32p4-cols and -rows, the Peek, Poke, Hexdump and Gpio words and the Board behind them, the board's 9P engine options, the gpio_toggle host slot), and with it every guard and limit only the board needed: terminal_panes and terminal.enabled (ghostty is in every build), memory.limits' board branching (the desktop values stay), MAX_PANES 64 and MAX_COLS 16 fixed, the board's boot buffer and its embedded boot, the pager's and the terminal's emulator-less paths; tests: the board's GPIO, ring and Board ones go, the boot-OOM and transition-grid ones stay under their own names; the perf harness loses the board's fixture, so the Debug baselines of both frontends are recorded again (--only medium --reps 10)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 143 |
1 files changed, 24 insertions, 119 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 32bf9cba..c3d12932 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -58,7 +58,7 @@ pub const pdf = panes.Pdf.pdf; pub const memory = @import("memory.zig"); pub const tape = @import("tape.zig"); pub const walk = @import("walk.zig"); -pub const screen_state = if (terminal_panes) @import("screen_state.zig") else struct {}; +pub const screen_state = @import("screen_state.zig"); pub const views = @import("views.zig"); pub const rollback = @import("rollback.zig"); pub const replica = @import("replica.zig"); @@ -102,7 +102,7 @@ pub const hosted = platform == .tui or platform == .gui or platform == .macos; /// is never the syscall's own. /// /// One per process, like the editor it belongs to. A process that never -/// starts it -- a test, the board, the browser -- has no second thread, and +/// starts it -- a test, the browser -- has no second thread, and /// every yield is a no-op. pub var turn: Turn = .{}; @@ -229,8 +229,6 @@ pub const Turn = struct { pub const can_attach = platform == .tui or platform == .gui; -pub const terminal_panes = platform != .esp32p4; - pub const fonts = if (font_picker) @import("fonts.zig") else struct {}; pub const PdfRasterPolicy = panes.Pdf.RasterPolicy; @@ -250,19 +248,19 @@ pub const pdf_raster_policy: PdfRasterPolicy = switch (platform) { // Both pixel shells rasterize for a real display and can afford it; the // wire-bandwidth argument that shapes the Kitty policy does not apply. .gui, .macos => sdl_pdf_raster_policy, - // Neither hostless platform rasterizes a PDF at all (mupdf is compiled - // out), so the cheaper policy is the honest placeholder. - .web, .esp32p4 => kitty_pdf_raster_policy, + // The web rasterizes no PDF at all (mupdf is compiled out), so the + // cheaper policy is the honest placeholder. + .web => kitty_pdf_raster_policy, }; pub const Pane = panes.Pane; const Text = panes.Text; -/// Pane slots: 64 on a desktop, where a session keeps many files and -/// terminals open; the board keeps its 16. A slot costs its share of the -/// fixed tables (MAX_PANES-sized arrays in the core and its surface) whether -/// or not a pane is in it; a pane itself is allocated when it opens. -pub const MAX_PANES = if (platform == .esp32p4) 16 else 64; +/// Pane slots, where a session keeps many files and terminals open. A slot +/// costs its share of the fixed tables (MAX_PANES-sized arrays in the core +/// and its surface) whether or not a pane is in it; a pane itself is +/// allocated when it opens. +pub const MAX_PANES = 64; pub const Layer = @import("Layer.zig"); pub const RowMetrics = Layer.Metrics; pub const TagHit = Layer.TagHit; @@ -275,9 +273,9 @@ pub const MAX_TAG_ROWS = 8; pub const MAX_TAG_LAYERS = MAX_PANES + MAX_COLS + 1 + MAX_PANES * Pane.Notices.max; pub const NOTICE_LAYER_BASE = MAX_PANES + MAX_COLS + 1; pub const PDF_PAGE_GAP_PX = panes.Pdf.page_gap_px; -/// Columns a session holds: 16 on a desktop (each costs about 8 KB of state, -/// a column tag being most of it), 6 on the board. -pub const MAX_COLS = if (platform == .esp32p4) 6 else 16; +/// Columns a session holds (each costs about 8 KB of state, a column tag +/// being most of it). +pub const MAX_COLS = 16; const column_weight_unit = layout.column_weight_unit; pub const MAX_JUMPS = 64; pub const TOPBAR_H: u16 = 1; @@ -2674,45 +2672,6 @@ pub fn pathUnder(a: []const u8, b: []const u8) bool { const tutor_text = @embedFile("tutor.txt"); -const boot_buffer = - \\x selects a line, Tab runs it. 0x optional. - \\ - \\-- flash: this image's rodata, then its code - \\Hexdump 40000020 40 - \\Hexdump 40050000 40 - \\-- L2MEM: firmware data, then the heap - \\Hexdump 4ff00000 40 - \\Hexdump 4ff40000 40 - \\-- the mask ROM - \\Hexdump 4fc00000 20 - \\-- UART0, the console you are reading on - \\Peek 500ca000 4 - \\-- LP_STORE0: write a word, read it back - \\Poke 5011002c deadbeef - \\Peek 5011002c - \\-- RNG_DATA: not memory. Run it twice. - \\Peek 501101a4 - \\Peek 501101a4 - \\-- the pins: Gpio draws JP1, Gpio 33 flips - \\Gpio - \\Gpio 33 -; - -test "every line of the board's boot buffer renders whole" { - const cols: usize = @import("pardes_config").esp32p4_cols; - var it = std.mem.splitScalar(u8, boot_buffer, '\n'); - while (it.next()) |line| { - std.testing.expect(line.len + 8 <= cols) catch |err| { - std.debug.print("boot buffer line is {d} of {d} usable: \"{s}\"\n", .{ line.len, cols - 8, line }); - return err; - }; - } - // and the tour still visits what it says it visits - try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "Hexdump 40000020") != null); - try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "Poke 5011002c deadbeef") != null); - try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "\nGpio\n") != null); -} - test "Tab N draws every pane's tab N cells wide and clicks count past it; bare Tab says the width; the ctl read and a Dump keep it" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 }); @@ -3663,8 +3622,6 @@ pub const Boot = enum { missing, /// `pardes -`: stdin's text in a +Pager pane, as `vim -` shows it stdin, - /// the firmware's boot buffer, the only pane a board has - embedded, /// the bare tty startup: one shell in raw tty mode, with an empty text /// pane under it so the editor half is there before you want it tty, @@ -3680,7 +3637,6 @@ pub const Boot = enum { if (opts.file != null) return .document; if (opts.missing != null) return .missing; if (opts.stdin_text != null) return .stdin; - if (comptime platform == .esp32p4) return .embedded; if (opts.tty_only) return .tty_shell; // ponytail: 1 and 3 are the only shell counts anyone asked for return if (opts.shells >= 3) .classic else .shell; @@ -4244,12 +4200,6 @@ pub const Pardes = struct { shown.file.?.pager_spans = page.spans; p.oneColumn(); }, - .embedded => { - const content = try p.gpa.dupe(u8, boot_buffer); - errdefer p.gpa.free(content); - _ = try panes.Output.open(p, 0, "", .{ .cmd = .New }, "", content); - p.oneColumn(); - }, .tty, .tty_shell => { _ = try p.newShell(0, ""); p.panes[0].?.body.mode = .tty; @@ -4314,7 +4264,7 @@ pub const Pardes = struct { /// remembered for want of memory is no failure of what opened it), so /// on a host it takes from the process heap, not the editor's, whose /// every failure must be answered. - // ponytail: a host heap for a best-effort list; the board's gpa there. + // ponytail: a host heap for a best-effort list; the browser's gpa there. pub fn recentGpa(p: *const Pardes) std.mem.Allocator { return if (comptime hosted) std.heap.smp_allocator else p.gpa; } @@ -4841,7 +4791,6 @@ pub const Pardes = struct { } fn parkPendingWrite(p: *Pardes, id: usize, bytes: []const u8) void { - if (comptime limits.pending_write_cap == 0) return; if (p.pending_write_bytes + bytes.len > limits.pending_write_cap) return; if (p.pending_write[id]) |*pw| { // Compact what the drain already sent before growing: a burst that @@ -7222,10 +7171,10 @@ pub const Pardes = struct { // What the terminal answers its program (a cursor report, its // attributes) goes as typed bytes go: behind whatever is still // queued for its pty, never ahead of it nor dropped. - if (comptime terminal_panes) if (pane.terminal) |state| { + if (pane.terminal) |state| { p.emitWrite(id, state.reply[0..state.reply_len]); state.reply_len = 0; - }; + } const r = p.rects[id]; // The session's part of the pane's view geometry (File.geometry), // and its context declarations. @@ -7416,7 +7365,7 @@ pub const Pardes = struct { // A terminal's kitty animation, at its next frame. Only a time still // ahead counts: a pane not drawn keeps the last one it was given, // and a past one would wake every frame for nothing. - if (comptime terminal_panes) for (p.panes) |slot| if (slot) |pane| if (panes.terminal.animationDueMs(pane)) |due_ms| { + for (p.panes) |slot| if (slot) |pane| if (panes.terminal.animationDueMs(pane)) |due_ms| { const due = due_ms *| std.time.ns_per_ms; if (due > p.stepped_ns) { const wait = @max(1, (due - p.stepped_ns + animation.frame_ns - 1) / animation.frame_ns); @@ -7435,8 +7384,8 @@ pub const Pardes = struct { return p.cursor_glide.moving() or p.shell_continuous or panes.Pdf.moving(p); } - /// For shells that only need a yes or no: macOS and the board, which - /// keep their own frame banks. + /// For shells that only need a yes or no: macOS, which keeps its own + /// frame bank. pub fn animationActive(p: *const Pardes) bool { return p.nextWake() != null or p.continuous(); } @@ -7600,7 +7549,6 @@ test "argv naming nothing boots an errors pane rather than failing the launch" { } test "raw terminal cursor obeys visibility without hiding modal and tag cursors" { - if (comptime !panes.terminal.enabled) return error.SkipZigTest; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); defer p.deinit(); @@ -7645,7 +7593,6 @@ test "raw terminal cursor obeys visibility without hiding modal and tag cursors" } test "raw terminal cursor follows its active row only while that row is visible" { - if (comptime !panes.terminal.enabled) return error.SkipZigTest; const gpa = std.testing.allocator; for ([_]bool{ false, true }) |tag_bottom| { const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 40, .rows = 12 }); @@ -8291,7 +8238,6 @@ test "a paste larger than the effect ring reaches the program whole and in order test "a bracketed paste larger than the ring still closes its bracket" { if (platform == .web) return; - if (comptime !panes.terminal.enabled) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8315,7 +8261,6 @@ test "a bracketed paste larger than the ring still closes its bracket" { test "a terminal's answer to its program waits behind the paste still queued for its pty" { if (platform == .web) return; - if (comptime !panes.terminal.enabled) return; const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 80, .rows = 24 }); defer p.deinit(); @@ -8474,44 +8419,12 @@ test "entering tty walks the shell cursor to the column clicked past the prompt" try std.testing.expectEqual(@as(usize, 7), lefts); } -const board_cols: u16 = 56; -const board_rows: u16 = 14; - -fn boardBudgetOptions(gpa: std.mem.Allocator, cols: u16, rows: u16) Options { - return .{ - .cols = cols, - .rows = rows, - .tty_only = true, - .frame_allocator = gpa, - .image_allocator = gpa, - .pdf_allocator = gpa, - .tree_sitter_allocator = gpa, - }; -} - -fn bootAndTearDown(gpa: std.mem.Allocator, cols: u16, rows: u16) !void { - const p = try Pardes.init(gpa, boardBudgetOptions(gpa, cols, rows)); +fn bootAndTearDown(gpa: std.mem.Allocator) !void { + const p = try Pardes.init(gpa, .{ .cols = 56, .rows = 14, .tty_only = true, .frame_allocator = gpa, .image_allocator = gpa, .pdf_allocator = gpa, .tree_sitter_allocator = gpa }); p.deinit(); } -test "board heap: every inline ring the board pays for still fits its budget" { - const heap = limits.board_heap_bytes; - - const effect_ring = 128 * @sizeOf(Effect); - // ...and the undo history, the largest in `Pane` once the terminal is out: - // 16 snapshots on the board against 256 on a desktop. - const undo_history = 2 * 16 * @sizeOf(panes.terminal.Snapshot); - const grid = @as(usize, board_cols) * board_rows * (2 * @sizeOf(Cell) + @sizeOf(PanelCellDiff)); - - // Each of the three separately, so a failure names the one that grew - // instead of reporting a total nobody can attribute. - try std.testing.expect(effect_ring <= heap / 8); - try std.testing.expect(undo_history <= heap / 32); - try std.testing.expect(grid <= heap / 8); - try std.testing.expect(effect_ring + undo_history + grid <= heap / 2); -} - -test "board heap: transition grids fit the budget and the surface borrows its snapshots" { +test "transition grids: the surface borrows its snapshots" { const per_cell = 2 * @sizeOf(Cell) + @sizeOf(PanelCellDiff); const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 16, .tty_only = true }); @@ -8538,9 +8451,6 @@ test "board heap: transition grids fit the budget and the surface borrows its sn p.presentation.previous_cells.len * @sizeOf(Cell) + p.presentation.diffs.len * @sizeOf(PanelCellDiff); try std.testing.expectEqual(cells * per_cell, owned); - - try std.testing.expect(@as(usize, board_cols) * board_rows * per_cell <= - limits.board_heap_bytes / 8); } test "LSP failure clears only its matching wait without completion indentation" { @@ -8569,12 +8479,8 @@ test "LSP failure clears only its matching wait without completion indentation" try std.testing.expectEqual(@as(i32, 4), pane.body.cur_col); } -test "board heap: every allocation failure during boot is a clean OutOfMemory" { - try std.testing.checkAllAllocationFailures( - std.testing.allocator, - bootAndTearDown, - .{ board_cols, board_rows }, - ); +test "every allocation failure during boot is a clean OutOfMemory" { + try std.testing.checkAllAllocationFailures(std.testing.allocator, bootAndTearDown, .{}); } test "jump history skips an entry whose pane slot or serial is gone, leaving the selection" { @@ -8692,7 +8598,6 @@ test "Back and Forward take the same steps from the mouse's side buttons and jum } test "jump history terminal rectangle follows output and clears on reflow" { - if (comptime !terminal_panes) return error.SkipZigTest; const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12, .tty_only = true }); defer p.deinit(); const pane = p.panes[0].?; |
