From ba10cc4ff30d08d27ad35576df04a03282b6521b Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 22:15:16 -0300 Subject: Term: the two things a speculation writes into a terminal and no rollback puts back move into the pane, which the copy holds and the digest covers: the cell its program last heard the mouse at (Pane.term_mouse, handed to Term.mouse and Term.wheel, which ghostty's encoder reads and writes) and its kitty graphics as glyph art (Pane.term_petscii, which the Petscii builtin flips and the images' draw takes in ImagesAt): the sizing's table (reports/pardes-term-bytes.md, section 1; the brief's step 1c); Parts loses both (a dump of an older build carries them and they are passed over by name: a terminal's Petscii chosen before an Upgrade is off after it), Ops loses petscii and togglePetscii; term-test 17/17, core-test 848/991 (143 skipped), shell-test 1027/1030 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/terminal.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/terminal.zig b/test/terminal.zig index e6c530d5..b7b9cd33 100644 --- a/test/terminal.zig +++ b/test/terminal.zig @@ -34,7 +34,6 @@ const prompt = Term.prompt; const scroll = Term.scroll; const scrollback = Term.scrollback; const commandOutput = Term.commandOutput; -const petscii = Term.petscii; const filterOf = emu.filterOf; const filterPalette = emu.filterPalette; const keyedRgb = emu.keyedRgb; @@ -892,7 +891,7 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet try pardes.dump.dumpState(p); const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); defer restored.deinit(); - try std.testing.expectEqual(@as(?bool, true), petscii(restored.panes[0].?.terminal)); + try std.testing.expect(restored.panes[0].?.term_petscii); try std.testing.expect(p.executeBuiltinLine(0, "Petscii")); _ = frame.reset(.retain_capacity); s = try p.render(frame.allocator()); @@ -904,12 +903,12 @@ test "a new terminal draws its program's images as pixels, and one without image const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 }); defer p.deinit(); - try std.testing.expectEqual(false, petscii(p.panes[0].?.terminal).?); + try std.testing.expect(!p.panes[0].?.term_petscii); // A pane without images says nothing of them. try std.testing.expect(std.mem.indexOf(u8, try tagline.tagPrefix(p, p.panes[0].?), "petscii") == null); const id = p.freeSlot().?; const fresh = try p.newShell(id, ""); - try std.testing.expectEqual(false, petscii(fresh.terminal).?); + try std.testing.expect(!fresh.term_petscii); } test "a program asking the cell size in pixels (CSI 16 t) is told the shell's" { -- cgit v1.3 From 55a5f91305df47cd56d7776f4193b6198208e891 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 22:17:29 -0300 Subject: build: the dead and the doubled options go (the start design's step 1, pardes-build-options change 1): `ShellConfig.prebuilt_shaders`, set at build.zig:147 and read nowhere (the `-Dprebuilt-shaders` flag stays: gui.make hands it to sketchbook and the perf identity names it); `tools.add` and `core.assemble` handed the grammar set and -Dtracy beside the `shell_cfg` that holds them (`ShellConfig.tracy` is the checkout's path now, so Parts and the perf identity read it there); `syntax_zig_grammar`, always equal to `syntax_highlighting`; and the four `syntax_*` bools as the one enum they said four ways, `grammars` (`-Dtree-sitter`'s `TreeSitterGrammars`), read by syntax.zig, Output.zig's Build pane and three tests, with abi/wire.zig hashing it as the four words it was hashed as, so `pardes version`'s semantics line did not move on any product (38b5ae573b965550 on tui, gui, the bare build's two, both statics, FreeBSD; d41689a1f97605b8 with -Dtree-sitter=minimal, as on the base); build.zig and build/ 3,005 -> 2,992 lines; every shape configures (12 configurations) and builds as on the base (tui, gui, bare, the macOS library for Linux and aarch64-macos, static on musl and on the window, FreeBSD, -Dtree-sitter=minimal), and the two that fail on the base fail with the same errors (pardes-isolate: core/builtins.zig:510, core/ninep/ctl.zig:1298; -Dtree-sitter=disabled: core/indent.zig:48); tui core-test 848/991 (143 skipped), shell-test 1027/1030, pane-test 183/184, behaviour-test 275/275 (and -- --replay), term-test 15/15, kitty-test 45/45, lib-test, hxlib 538 cases 0 mismatches, process-test 3 of 144 failed (lspcomplete and lspcompletemoved, the base's, and headersweep-restored, on the flaky list: passed alone, 1364 ms), gui unit-test 1625/1629 (the perf check's BaselineHarnessMismatch, the base's); the test names of every suite equal the base's (ledger); load 15-45 on 16 cores Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/wire.zig | 11 +++++++---- build.zig | 7 +------ build/core.zig | 17 ++++++----------- build/tools.zig | 7 ++----- core/Output.zig | 2 +- core/syntax.zig | 11 +++++------ test/behaviour/panes.zig | 2 +- test/behaviour/settings.zig | 2 +- test/output.zig | 2 +- 9 files changed, 25 insertions(+), 36 deletions(-) (limited to 'test') diff --git a/abi/wire.zig b/abi/wire.zig index b2d32033..26a7131e 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -61,16 +61,19 @@ const family = switch (config.platform) { /// their options and dependencies; -Dstamp-commit stamps one. pub const semantics: u64 = blk: { @setEvalBranchQuota(1_000_000); + // The grammar set as the four words it was hashed as when it was four + // options (highlighting, zig, minimal, full), so the hash stays. + const g = config.grammars; // The two long ones (the dependencies, 2.5 KB, and the tape's shape, // 11 KB) joined on, not formatted: formatting them at comptime was 5 % // of a compile of the core. break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint( "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} workspace_tag {} sources {}\nusize {d} {t}\n", .{ - version, config.version, config.commit orelse "unstamped", - family, config.syntax_highlighting, config.syntax_zig_grammar, - config.syntax_minimal_grammars, config.syntax_full_grammars, config.workspace_tag, - config.embed_sources, @sizeOf(usize), builtin.cpu.arch.endian(), + version, config.version, config.commit orelse "unstamped", + family, g != .disabled, g != .disabled, + g == .minimal or g == .full, g == .full, config.workspace_tag, + config.embed_sources, @sizeOf(usize), builtin.cpu.arch.endian(), }, ) ++ config.deps ++ "\n" ++ pardes.tape.shape); }; diff --git a/build.zig b/build.zig index b81390c4..cf9a851f 100644 --- a/build.zig +++ b/build.zig @@ -142,9 +142,8 @@ pub fn build(b: *std.Build) void { const shell_cfg: core.ShellConfig = .{ .tree_sitter_grammars = tree_sitter_grammars, - .tracy = tracy != null, + .tracy = tracy, .workspace_tag = workspace_tag, - .prebuilt_shaders = prebuilt_shaders, .embed_sources = embed_sources, .commit = if (stamp_commit) core.gitCommit(b) else null, .change = if (stamp_commit) core.jjChange(b) else null, @@ -156,8 +155,6 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, .c_optimize = c_optimize, - .tree_sitter_grammars = tree_sitter_grammars, - .tracy = tracy, .shell_cfg = shell_cfg, .platform = platform, .also_gui = also_gui, @@ -320,8 +317,6 @@ pub fn build(b: *std.Build) void { .shell_cfg = shell_cfg, .target = target, .test_filters = test_filters, - .tracy = tracy, - .tree_sitter_grammars = tree_sitter_grammars, .unit_profile = unit_profile, }); tests.add(b, .{ diff --git a/build/core.zig b/build/core.zig index 974d5c7e..b35c066b 100644 --- a/build/core.zig +++ b/build/core.zig @@ -60,11 +60,11 @@ pub fn command(b: *std.Build, argv: []const []const u8) ?[]const u8 { pub const ShellConfig = struct { tree_sitter_grammars: TreeSitterGrammars, - tracy: bool = false, + /// -Dtracy's checkout, whose client a core that asks compiles in. + tracy: ?[]const u8 = null, /// null = "the platform's own default": the macOS shell hands the row to /// its native menu bar, every other shell keeps the acme topbar. workspace_tag: ?bool = null, - prebuilt_shaders: bool = false, embed_sources: bool = false, commit: ?[]const u8 = null, /// The jj change git HEAD is in, and when this configure ran: the @@ -79,11 +79,8 @@ pub const ShellConfig = struct { pub fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build.Step.Options { const o = b.addOptions(); o.addOption(Platform, "platform", platform); - o.addOption(bool, "syntax_highlighting", cfg.tree_sitter_grammars != .disabled); - o.addOption(bool, "syntax_zig_grammar", cfg.tree_sitter_grammars != .disabled); - o.addOption(bool, "syntax_minimal_grammars", cfg.tree_sitter_grammars == .minimal or cfg.tree_sitter_grammars == .full); - o.addOption(bool, "syntax_full_grammars", cfg.tree_sitter_grammars == .full); - o.addOption(bool, "enable_tracy", cfg.tracy); + o.addOption(TreeSitterGrammars, "grammars", cfg.tree_sitter_grammars); + o.addOption(bool, "enable_tracy", cfg.tracy != null); o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos)); o.addOption(bool, "embed_sources", cfg.embed_sources); o.addOption([]const u8, "version", display_version); @@ -429,8 +426,6 @@ pub fn assemble(b: *std.Build, c: struct { target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, c_optimize: std.lang.Optimize, - tree_sitter_grammars: TreeSitterGrammars, - tracy: ?[]const u8, shell_cfg: ShellConfig, platform: Platform, also_gui: bool, @@ -455,7 +450,7 @@ pub fn assemble(b: *std.Build, c: struct { // nothing else. pardes takes these whatever it builds: the missing ones // are asked for here in one round, the grammars with them, where each // `b.dependency` below would end the configure to fetch its own alone. - const ts = treeSitter(b, io, target, c_optimize, c.tree_sitter_grammars); + const ts = treeSitter(b, io, target, c_optimize, c.shell_cfg.tree_sitter_grammars); inline for (.{ "cloud9", "vaxis", "ghostty", "uucode", "zstbi", "mvzr", "zstd", "xitdb" }) |name| { // A dependency by path (none of these today) has no hash and is always there. const dep = @field(zon.dependencies, name); @@ -623,7 +618,7 @@ pub fn assemble(b: *std.Build, c: struct { .target = target, .optimize = optimize, .cloud9 = cloud9, - .tracy = c.tracy, + .tracy = c.shell_cfg.tracy, .zstd = zstd, .image = image_addon.root_module, .pdf = pdf_built.module, diff --git a/build/tools.zig b/build/tools.zig index 1343fef9..62e9817a 100644 --- a/build/tools.zig +++ b/build/tools.zig @@ -2,7 +2,6 @@ const std = @import("std"); const builtin = @import("builtin"); const Platform = @import("../build.zig").Platform; const PerfBuild = @import("../build.zig").PerfBuild; -const TreeSitterGrammars = @import("../build.zig").TreeSitterGrammars; const core = @import("core.zig"); const testMatch = @import("tests.zig").testMatch; @@ -42,8 +41,6 @@ pub fn add(b: *std.Build, c: struct { shell_cfg: core.ShellConfig, target: std.Build.ResolvedTarget, test_filters: []const []const u8, - tracy: ?[]const u8, - tree_sitter_grammars: TreeSitterGrammars, unit_profile: *std.Build.Step.Compile, }) Tools { const image_harness = program(b, "pardes-image-harness", "test/image_harness.zig", c.target, c.optimize, &.{}); @@ -191,10 +188,10 @@ pub fn add(b: *std.Build, c: struct { .c_optimize = @tagName(c.c_optimize), .terminal_optimize = @tagName(c.ghostty_optimize), .platform = @tagName(c.platform), - .grammars = @tagName(c.tree_sitter_grammars), + .grammars = @tagName(c.shell_cfg.tree_sitter_grammars), .mupdf = c.pdf_addon != null, .jpx = c.enable_jpx, - .tracy = c.tracy != null, + .tracy = c.shell_cfg.tracy != null, .terminal_simd = c.ghostty_simd, .prebuilt_shaders = c.platform == .gui and c.prebuilt_shaders, }); diff --git a/core/Output.zig b/core/Output.zig index 3ac9f521..23409b68 100644 --- a/core/Output.zig +++ b/core/Output.zig @@ -906,7 +906,7 @@ pub fn openBuild(p: *Pardes, id: usize) !void { @tagName(builtin.abi), @tagName(build_options.platform), }); try w.print("grammars {s}\naddons {s}\nsemantics {x:0>16}\n\ndependencies\n{s}", .{ - if (build_options.syntax_full_grammars) "full" else if (build_options.syntax_minimal_grammars) "minimal" else "none", + if (build_options.grammars == .full) "full" else if (build_options.grammars == .minimal) "minimal" else "none", if (@import("builtin_addons").on) "compiled in" else "loaded from /lib/pardes/addons", @import("wire").semantics, build_options.deps, diff --git a/core/syntax.zig b/core/syntax.zig index f95b745a..36aa8c2b 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -7,10 +7,9 @@ const regexp = @import("regexp.zig"); const c_heap = @import("c_heap"); const diff = @import("diff.zig"); -pub const enabled = config.syntax_highlighting; -const zig_grammar = config.syntax_zig_grammar; -const minimal_grammars = config.syntax_minimal_grammars; -const full_grammars = config.syntax_full_grammars; +pub const enabled = config.grammars != .disabled; +const minimal_grammars = config.grammars == .minimal or config.grammars == .full; +const full_grammars = config.grammars == .full; pub const ts = if (enabled) @import("tree-sitter") else struct { pub const Language = opaque {}; @@ -44,7 +43,7 @@ const Spec = struct { fn grammarSelected(comptime g: grammar_manifest.Grammar) bool { return switch (g.tier) { - .zig => zig_grammar, + .zig => enabled, .minimal => minimal_grammars, .full => full_grammars, }; @@ -2169,7 +2168,7 @@ test "a kept tree told its edits parses to the fresh parse's tree, places and al } test "syntax: a grammar handed in at run time colours and walks as the one compiled in" { - if (!zig_grammar) return error.SkipZigTest; + if (!enabled) return error.SkipZigTest; const gpa = std.testing.allocator; start(gpa); defer stop(); diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig index 67155776..8fb85cb7 100644 --- a/test/behaviour/panes.zig +++ b/test/behaviour/panes.zig @@ -888,7 +888,7 @@ test "panes: truncating body empties it, and a stat says the length after" { } test "panes: a rename colours a source its new name's language names, its text unchanged" { - if (!@import("pardes_config").syntax_highlighting) return error.SkipZigTest; + if (@import("pardes_config").grammars == .disabled) return error.SkipZigTest; var s = try Session.initFile(std.testing.allocator, "fn check() void {}\n"); defer s.deinit(); const n = try s.focused(); diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index 66cd97df..bd88b75e 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -158,7 +158,7 @@ test "settings: Back and Forward written to exec keep to the focused file" { }); } -const syntax = @import("pardes_config").syntax_highlighting; +const syntax = @import("pardes_config").grammars != .disabled; /// The style /screen draws the cell `into` cells into the first place /// `text` is drawn. diff --git a/test/output.zig b/test/output.zig index 38e8ba0d..17525616 100644 --- a/test/output.zig +++ b/test/output.zig @@ -786,7 +786,7 @@ test "identical result refresh keeps warm content caches without allocation" { const index = try panes.File.lineIndex(p.gpa, file); const styles = try std.testing.allocator.dupe(u8, file.highlights); defer std.testing.allocator.free(styles); - if (@import("pardes_config").syntax_zig_grammar) try std.testing.expect(styles.len > 0); + if (@import("pardes_config").grammars != .disabled) try std.testing.expect(styles.len > 0); const revision = file.revision; const saved_revision = file.saved_revision; const body_ptr = file.content.ptr; -- cgit v1.3 From a481de9feea08de7b5b82c2471de70abd70d7462 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 23:07:14 -0300 Subject: build: one options module a module set, `pardes_options`, and `build_info` beside it (the start design's step 2, pardes-build-options change 2): `core.module` makes the set's options from the build's `ShellConfig` and the set's `Core` (the platform, now a `Core` field in place of a module handed in; the grammar set; the terminal; pardes-isolate's `isolated`; the addons compiled in and the pdf one with them, `builtin_addons` and `builtin_pdf`; tracy; the workspace tag; embedded sources; the library's `lib`), one module shared by the set's five as `pardes_config` was, and `build_info` (version, commit, change, built, deps) made once in `assemble` and given to every set; the three one-value modules made in both values (`term_options`, `pardes_isolation`, `builtin_addons`), `shellOptions`, the six `Parts` fields that held them, `Parts.tracy` and `Parts.embed_sources` (the `ShellConfig` in `Parts` holds both) and the assembly's two options (`opts`, `gui_opts`) go; the library's `pardes-syntax` and the editor (the library's and hxlib's) get `pardes_options` with no terminal, the editor's with `lib` as before; the sources' imports follow, one identifier a line (abi/wire.zig and core/Output.zig import both, the hash's and the Build pane's lines reading the version, commit and dependencies from `build_info`); test programs see it as before, through the core module's import table (pane-test, behaviour-test); `pardes version`'s semantics line did not move on any product (38b5ae573b965550; d41689a1f97605b8 with -Dtree-sitter=minimal); build.zig and build/ 2,992 -> 2,960 lines (3,005 at the base); every shape configures and builds as on the base, pardes-isolate and -Dtree-sitter=disabled failing with the base's same errors (pardes-isolate reaching them through its own options module); tui core-test 848/991 (143 skipped), shell-test 1027/1030, pane-test 183/184, behaviour-test 275/275 (and -- --replay), term-test 15/15, kitty-test 45/45, lib-test (11/11 in the consumer), hxlib 538 cases 0 mismatches, process-test 2 of 144 failed (lspcomplete and lspcompletemoved, the base's), gui unit-test 1625/1629 (the perf check's BaselineHarnessMismatch, the base's); the test names of every suite equal the base's (ledger); the frame and perf gate (gpu/bo-s2 against tree1) PASS: 77/77 frames byte-identical in Debug, the alternated window corpus2x -0.104% (pictures identical in all 10 runs), the 97 per-operation counts within 0.1% (largest image-frame +0.0345%; against the coordinator's pardes-merge22 gate m22-g, 90 within 5 ppm, deep-sel 8-10 ppm, image-frame up to 85 ppm, its known noise); load 5-25 on 16 cores Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- abi/wire.zig | 13 ++--- build.zig | 13 +++-- build/core.zig | 115 ++++++++++++++++---------------------------- build/library.zig | 2 +- build/tests.zig | 4 +- core/Addon.zig | 4 +- core/Editor.zig | 2 +- core/Output.zig | 15 +++--- core/Term.zig | 2 +- core/Text.zig | 2 +- core/config.zig | 2 +- core/lib_editor.zig | 2 +- core/memory.zig | 2 +- core/root.zig | 10 ++-- core/syntax.zig | 2 +- core/tracy.zig | 2 +- dev/root.zig | 6 +-- docs/next-editor.md | 2 +- docs/next-terminal.md | 4 +- runtime/macos.zig | 2 +- runtime/root.zig | 4 +- test/behaviour/panes.zig | 2 +- test/behaviour/settings.zig | 8 +-- test/output.zig | 2 +- 24 files changed, 96 insertions(+), 126 deletions(-) (limited to 'test') diff --git a/abi/wire.zig b/abi/wire.zig index 26a7131e..1f7d02d2 100644 --- a/abi/wire.zig +++ b/abi/wire.zig @@ -7,7 +7,8 @@ const std = @import("std"); const builtin = @import("builtin"); const pardes = @import("core"); -const config = @import("pardes_config"); +const config = @import("pardes_options"); +const build_info = @import("build_info"); /// 23: a pane of a kind's frame names its rasters by key, their pixels /// crossing before it as strips of 4 MiB at most over the rows it shows @@ -70,12 +71,12 @@ pub const semantics: u64 = blk: { break :blk std.hash.Wyhash.hash(0, std.fmt.comptimePrint( "wire {d}\npardes {s} {s}\n{s} grammars {} {} {} {} workspace_tag {} sources {}\nusize {d} {t}\n", .{ - version, config.version, config.commit orelse "unstamped", - family, g != .disabled, g != .disabled, - g == .minimal or g == .full, g == .full, config.workspace_tag, - config.embed_sources, @sizeOf(usize), builtin.cpu.arch.endian(), + version, build_info.version, build_info.commit orelse "unstamped", + family, g != .disabled, g != .disabled, + g == .minimal or g == .full, g == .full, config.workspace_tag, + config.embed_sources, @sizeOf(usize), builtin.cpu.arch.endian(), }, - ) ++ config.deps ++ "\n" ++ pardes.tape.shape); + ) ++ build_info.deps ++ "\n" ++ pardes.tape.shape); }; /// EndOfStream: the message ends early; WriteFailed: no room for it. diff --git a/build.zig b/build.zig index cf9a851f..fc0c5044 100644 --- a/build.zig +++ b/build.zig @@ -166,7 +166,6 @@ pub fn build(b: *std.Build) void { .pdf_scroll_bench_step = pdf_scroll_bench_step, }); const parts = a.parts; - const opts = a.opts; // Off Linux, whose memfd Addon.zig's loader needs, every core has the // addons compiled in. const compiled_in = target.result.os.tag != .linux; @@ -174,28 +173,28 @@ pub fn build(b: *std.Build) void { // its own flat C ABI instead of runtime/main.zig. Tracy's client and BSD // libutil go to the shell (and Tracy's to the core) alone, as before // core.module. - const root_set = core.module(b, parts, .{ .root = if (platform == .macos) "runtime/macos.zig" else "runtime/main.zig", .config = opts, .builtin_addons = compiled_in, .tracy = true, .util = true }); + const root_set = core.module(b, parts, .{ .root = if (platform == .macos) "runtime/macos.zig" else "runtime/main.zig", .platform = platform, .builtin_addons = compiled_in, .tracy = true, .util = true }); const root_mod = root_set.root; // hxdiff's headless core and pardes-isolate are the primary shell's // configuration compiled two more ways, not two more frontends. - const core_cfg: core.Core = .{ .root = "core/root.zig", .config = opts, .builtin_addons = compiled_in, .tracy = true }; + const core_cfg: core.Core = .{ .root = "core/root.zig", .platform = platform, .builtin_addons = compiled_in, .tracy = true }; const core_set = core.module(b, parts, core_cfg); const core_module = core_set.root; // The core without the terminal module (docs/next-terminal.md, Phase 1): // what core-test is compiled from. No ghostty-vt, wuffs, zstbi or C++; // a shell boot is a scratch pane, a test that needs a terminal skips, // and shell-test runs them all with one. - const lean_cfg: core.Core = .{ .root = "core/root.zig", .config = opts, .builtin_addons = compiled_in, .terminal = false }; + const lean_cfg: core.Core = .{ .root = "core/root.zig", .platform = platform, .builtin_addons = compiled_in, .terminal = false }; const core_lean = core.module(b, parts, lean_cfg); - const isolated_mod: ?*std.Build.Module = if (platform == .tui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = opts, .builtin_addons = compiled_in, .isolated = true }).root else null; + const isolated_mod: ?*std.Build.Module = if (platform == .tui) core.module(b, parts, .{ .root = "runtime/main.zig", .platform = platform, .builtin_addons = compiled_in, .isolated = true }).root else null; // `zig build static`'s: the addons compiled in (Addon.zig). Linked // statically on musl alone, as glibc links only dynamically; the gui's // is dynamic (SDL and the GPU need the display's libraries) with the // addons in it all the same. const static_linkage: ?std.builtin.LinkMode = if (target.result.isMuslLibC()) .static else null; - const static_set: ?core.Modules = if ((platform == .tui and static_linkage != null) or platform == .gui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = opts, .builtin_addons = true }) else null; + const static_set: ?core.Modules = if ((platform == .tui and static_linkage != null) or platform == .gui) core.module(b, parts, .{ .root = "runtime/main.zig", .platform = platform, .builtin_addons = true }) else null; const static_mod: ?*std.Build.Module = if (static_set) |s| s.root else null; - const gui_set: ?core.Modules = if (also_gui) core.module(b, parts, .{ .root = "runtime/main.zig", .config = a.gui_opts.?, .builtin_addons = compiled_in }) else null; + const gui_set: ?core.Modules = if (also_gui) core.module(b, parts, .{ .root = "runtime/main.zig", .platform = .gui, .builtin_addons = compiled_in }) else null; const gui_mod: ?*std.Build.Module = if (gui_set) |s| s.root else null; if (a.pdf.lib) |lib| tools.pdfBenches(b, target, optimize, core_module, lib, pdf_pointer_bench_step, pdf_scroll_bench_step); diff --git a/build/core.zig b/build/core.zig index b35c066b..4e4a748b 100644 --- a/build/core.zig +++ b/build/core.zig @@ -5,7 +5,7 @@ const grammar_manifest = @import("../core/grammar_manifest.zig"); const addons = @import("addons.zig"); const patches = @import("patches.zig"); /// The package manifest, imported UNTYPED on purpose — see the `version` -/// option in `shellOptions` for why that word is load-bearing. +/// option in `buildInfo` for why that word is load-bearing. const zon = @import("../build.zig.zon"); /// Releases are numbered 0.N; the zon holds "0.N.0" because it must be semver, /// and what a user sees drops that ".0". @@ -76,21 +76,34 @@ pub const ShellConfig = struct { lib: bool = false, }; -pub fn shellOptions(b: *std.Build, cfg: ShellConfig, platform: Platform) *std.Build.Step.Options { +/// `pardes_options`: what a module set varies at compile time, one module +/// a configuration, which `module` makes and the set's modules share. +pub fn options(b: *std.Build, cfg: ShellConfig, c: Core, pdf: bool) *std.Build.Step.Options { const o = b.addOptions(); - o.addOption(Platform, "platform", platform); + o.addOption(Platform, "platform", c.platform); o.addOption(TreeSitterGrammars, "grammars", cfg.tree_sitter_grammars); + o.addOption(bool, "terminal", c.terminal); + o.addOption(bool, "isolated", c.isolated); + o.addOption(bool, "builtin_addons", c.builtin_addons); + // ...the pdf one only when it is built (-Dpdf=false leaves it out). + o.addOption(bool, "builtin_pdf", c.builtin_addons and pdf); o.addOption(bool, "enable_tracy", cfg.tracy != null); - o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (platform != .macos)); + o.addOption(bool, "workspace_tag", cfg.workspace_tag orelse (c.platform != .macos)); o.addOption(bool, "embed_sources", cfg.embed_sources); + o.addOption(bool, "lib", cfg.lib); + return o; +} + +/// `build_info`: the version, and the commit, change and time a stamped +/// build was made from (see `stamp_commit`, read at configure time), and +/// every dependency's hash. +pub fn buildInfo(b: *std.Build, cfg: ShellConfig) *std.Build.Step.Options { + const o = b.addOptions(); o.addOption([]const u8, "version", display_version); - // ...and the commit it was built from, when there is one and the build - // is stamped at all (see `stamp_commit`). Read at configure time. o.addOption(?[]const u8, "commit", cfg.commit); o.addOption(?[]const u8, "change", cfg.change); o.addOption(?[]const u8, "built", cfg.built); o.addOption([]const u8, "deps", deps_text); - o.addOption(bool, "lib", cfg.lib); return o; } @@ -237,16 +250,16 @@ pub fn editorModule(b: *std.Build, name: ?[]const u8, target: std.Build.Resolved /// cell's width for j and k's goal column. vaxis: *std.Build.Module, }) *std.Build.Module { - const options: std.Build.Module.CreateOptions = .{ + const create: std.Build.Module.CreateOptions = .{ .target = target, .optimize = optimize, .root_source_file = b.path("core/lib_editor.zig"), .link_libc = true, }; - const m = if (name) |n| b.addModule(n, options) else b.createModule(options); + const m = if (name) |n| b.addModule(n, create) else b.createModule(create); var lib_cfg = cfg; lib_cfg.lib = true; - m.addOptions("pardes_config", shellOptions(b, lib_cfg, .tui)); + m.addOptions("pardes_options", options(b, lib_cfg, .{ .root = "core/lib_editor.zig", .platform = .tui, .terminal = false }, false)); m.addImport("plain", b.createModule(.{ .target = target, .optimize = optimize, .root_source_file = b.path("abi/plain.zig") })); m.addImport("generated_themes", d.themes); d.ts.wire(m); @@ -262,8 +275,10 @@ pub const Parts = struct { target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, cloud9: *std.Build.Module, - /// -Dtracy's checkout, whose client a core that asks compiles in. - tracy: ?[]const u8, + /// The build's options (-Dtracy's checkout, -Dembed-sources...). + cfg: ShellConfig, + /// `build_info`, the same for every set. + info: *std.Build.Step.Options, zstd: *std.Build.Step.Compile, /// The addons, for a core that has them compiled in (Addon.zig); the /// pdf one only when it is built (-Dpdf=false leaves it out). @@ -281,16 +296,6 @@ pub const Parts = struct { uucode: *std.Build.Module, xitdb: *std.Build.Module, doc_typ: *std.Build.Step.Options, - /// -Dembed-sources: the core embeds its sources for /src. - embed_sources: bool, - /// One options module for each value of `terminal`, `isolated` and - /// `on`, shared by every core. - term_on: *std.Build.Step.Options, - term_off: *std.Build.Step.Options, - iso_on: *std.Build.Step.Options, - iso_off: *std.Build.Step.Options, - builtin_on: *std.Build.Step.Options, - builtin_off: *std.Build.Step.Options, }; /// Which core: its root and the few ways the products differ. @@ -299,9 +304,8 @@ pub const Core = struct { /// library), core/root.zig for the core, runtime/root.zig for the /// runtime, or a core file whose tests run on the core's imports. root: []const u8, - /// The shell's options (`pardes_config`): this build's, or the window's - /// in the bare build. - config: *std.Build.Step.Options, + /// This build's, or the window's in the bare build. + platform: Platform, /// The terminal module; without it (core-test) a shell boot is a scratch pane. terminal: bool = true, /// pardes-isolate's: no host but the terminal. @@ -336,7 +340,7 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { // forkpty: in libc proper on glibc>=2.34 and darwin; the BSDs keep it in libutil if (c.util and (p.target.result.os.tag == .freebsd or p.target.result.os.tag == .netbsd or p.target.result.os.tag == .openbsd)) m.linkSystemLibrary("util", .{}); - if (c.tracy) if (p.tracy) |tracy_path| { + if (c.tracy) if (p.cfg.tracy) |tracy_path| { m.addIncludePath(.{ .cwd_relative = tracy_path }); m.addCSourceFile(.{ .file = .{ .cwd_relative = b.pathJoin(&.{ tracy_path, "public", "TracyClient.cpp" }) }, @@ -356,7 +360,7 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { for (p.ts.libs.items) |lib| m.linkLibrary(lib); // The /src tree's files that live outside the core's directory // (fs.zig embeds them under the names they had there). - if (p.embed_sources) for ([_][]const u8{ "runtime/9p.zig", "runtime/9p_io.zig", "runtime/main.zig", "dev/host_io.zig" }) |f| + if (p.cfg.embed_sources) for ([_][]const u8{ "runtime/9p.zig", "runtime/9p_io.zig", "runtime/main.zig", "dev/host_io.zig" }) |f| m.addAnonymousImport(f, .{ .root_source_file = b.path(f) }); const runtime = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path("runtime/root.zig"), .link_libc = true }); const dev = b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path("dev/root.zig"), .link_libc = true }); @@ -364,18 +368,15 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { const root = if (!in_runtime) m else if (std.mem.eql(u8, c.root, "runtime/root.zig")) runtime else b.createModule(.{ .target = p.target, .optimize = p.optimize, .root_source_file = b.path(c.root), .link_libc = true }); // Each options module once, so that the modules share it: a file is in // one module of a compilation. - const term_options = (if (c.terminal) p.term_on else p.term_off).createModule(); const ts_queries = if (p.ts.queries) |q| q.createModule() else null; const doc_typ = p.doc_typ.createModule(); - const pardes_config = c.config.createModule(); - const pardes_isolation = (if (c.isolated) p.iso_on else p.iso_off).createModule(); - const builtin_addons = (if (c.builtin_addons) p.builtin_on else p.builtin_off).createModule(); + const pardes_options = options(b, p.cfg, c, p.pdf != null).createModule(); + const build_info = p.info.createModule(); for ([_]*std.Build.Module{ m, dev, runtime, wire, root }) |x| { x.addImport("cloud9", p.cloud9); if (c.builtin_addons) if (p.pdf) |pdf| x.addImport("pdf_addon", pdf); if (c.builtin_addons) x.addImport("image_addon", p.image); if (c.terminal) x.addImport("term", p.term); - x.addImport("term_options", term_options); x.addImport("plain", p.plain); x.addImport("pardes_addon", p.kind); x.addImport("generated_themes", p.themes); @@ -388,9 +389,8 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { x.addImport("xitdb", p.xitdb); // config.zig's test checks the words and keys docs/typ names exist. x.addImport("doc_typ", doc_typ); - x.addImport("pardes_config", pardes_config); - x.addImport("pardes_isolation", pardes_isolation); - x.addImport("builtin_addons", builtin_addons); + x.addImport("pardes_options", pardes_options); + x.addImport("build_info", build_info); x.addImport("core", m); x.addImport("dev", dev); x.addImport("runtime", runtime); @@ -399,13 +399,9 @@ pub fn module(b: *std.Build, p: Parts, c: Core) Modules { return .{ .root = root, .core = m, .dev = dev, .runtime = runtime, .wire = wire }; } -/// What `assemble` makes besides the parts: the shells' options, the -/// addons, and the terminal's pieces the tests and harnesses name. +/// What `assemble` makes besides the parts: the addons, and the terminal's pieces the tests and harnesses name. pub const Assembly = struct { parts: Parts, - /// The shell's options (`pardes_config`), and the window's in the bare build. - opts: *std.Build.Step.Options, - gui_opts: ?*std.Build.Step.Options, /// What an addon in Zig imports (abi/addon.zig). addon_mod: *std.Build.Module, pdf: addons.Pdf, @@ -418,10 +414,10 @@ pub const Assembly = struct { ghostty_simd: bool, }; -/// Every core's parts, the shells' options and the addons, made once and -/// in this order (the configuration numbers what it generates by it): the -/// one-round lazy fetch, tree-sitter and the themes, the patched packages, -/// zstd, the terminal, and the options modules the cores choose between. +/// Every core's parts and the addons, made once and in this order (the +/// configuration numbers what it generates by it): the one-round lazy +/// fetch, tree-sitter and the themes, the patched packages, zstd, the +/// terminal. pub fn assemble(b: *std.Build, c: struct { target: std.Build.ResolvedTarget, optimize: std.lang.Optimize, @@ -463,9 +459,6 @@ pub fn assemble(b: *std.Build, c: struct { const themes_mod = generatedThemes(b, io, target, optimize); - const opts = shellOptions(b, c.shell_cfg, c.platform); - const gui_opts: ?*std.Build.Step.Options = if (c.also_gui) shellOptions(b, c.shell_cfg, .gui) else null; - const zstbi_dep = b.dependency("zstbi", .{ .target = target, .optimize = c_optimize }); const zstbi_mod = zstbi_dep.module("root"); // vaxis, ghostty, mvzr and zstbi are patched as they are fetched @@ -597,28 +590,13 @@ pub fn assemble(b: *std.Build, c: struct { if (ghostty_vt_for_tests) |x| term_mod.addImport("ghostty-vt", x); if (wuffs_mod) |x| term_mod.addImport("wuffs", x); term_mod.addImport("zstbi", zstbi_mod); - - // One options module for each value a core chooses (`module`). - const term_on = b.addOptions(); - term_on.addOption(bool, "terminal", true); - const term_off = b.addOptions(); - term_off.addOption(bool, "terminal", false); - const iso_off = b.addOptions(); - iso_off.addOption(bool, "isolated", false); - const iso_on = b.addOptions(); - iso_on.addOption(bool, "isolated", true); - const builtin_off = b.addOptions(); - builtin_off.addOption(bool, "on", false); - const builtin_on = b.addOptions(); - builtin_on.addOption(bool, "on", true); - // ...the pdf one only when it is built (-Dpdf=false leaves it out). - builtin_on.addOption(bool, "pdf", pdf_built.lib != null); return .{ .parts = .{ .target = target, .optimize = optimize, .cloud9 = cloud9, - .tracy = c.shell_cfg.tracy, + .cfg = c.shell_cfg, + .info = buildInfo(b, c.shell_cfg), .zstd = zstd, .image = image_addon.root_module, .pdf = pdf_built.module, @@ -633,16 +611,7 @@ pub fn assemble(b: *std.Build, c: struct { .uucode = uucode_mod, .xitdb = xitdb_mod, .doc_typ = c.doc_typ, - .embed_sources = c.shell_cfg.embed_sources, - .term_on = term_on, - .term_off = term_off, - .iso_on = iso_on, - .iso_off = iso_off, - .builtin_on = builtin_on, - .builtin_off = builtin_off, }, - .opts = opts, - .gui_opts = gui_opts, .addon_mod = addon_mod, .pdf = pdf_built, .image_addon = image_addon, diff --git a/build/library.zig b/build/library.zig index ebfd8596..8a23debc 100644 --- a/build/library.zig +++ b/build/library.zig @@ -24,7 +24,7 @@ pub fn build(b: *std.Build) void { }); // A library's options: its grammars, nothing stamped, no window. const cfg: core.ShellConfig = .{ .tree_sitter_grammars = tree_sitter_grammars }; - mod.addOptions("pardes_config", core.shellOptions(b, cfg, .tui)); + mod.addOptions("pardes_options", core.options(b, cfg, .{ .root = "core/lib_syntax.zig", .platform = .tui, .terminal = false }, false)); const ts = core.treeSitter(b, io, target, if (optimize == .debug) .fast else optimize, tree_sitter_grammars); const themes = core.generatedThemes(b, io, target, optimize); mod.addImport("generated_themes", themes); diff --git a/build/tests.zig b/build/tests.zig index 50d3dd02..741eb24a 100644 --- a/build/tests.zig +++ b/build/tests.zig @@ -84,7 +84,7 @@ pub fn add(b: *std.Build, c: struct { if (c.ghostty_vt_for_tests) |x| pane_tests.root_module.addImport("ghostty-vt", x); // The core's own options module, not another over the same file: // a file is in one module of a compilation. - pane_tests.root_module.addImport("pardes_config", c.core_module.import_table.get("pardes_config").?); + pane_tests.root_module.addImport("pardes_options", c.core_module.import_table.get("pardes_options").?); const test_addons = b.addOptions(); test_addons.addOptionPath("image", c.image_addon.getEmittedBin()); test_addons.addOption(bool, "has_pdf", c.pdf_addon != null); @@ -129,7 +129,7 @@ pub fn add(b: *std.Build, c: struct { session_module.addOptions("session_options", session_options); // The build's options alone (platform), never the core: a test of a // window's word knows which build it runs in. - const behaviour_tests = units.root(b, "test/behaviour.zig", true, &.{ .{ .name = "session", .module = session_module }, .{ .name = "pardes_config", .module = c.core_module.import_table.get("pardes_config").? } }); + const behaviour_tests = units.root(b, "test/behaviour.zig", true, &.{ .{ .name = "session", .module = session_module }, .{ .name = "pardes_options", .module = c.core_module.import_table.get("pardes_options").? } }); const behaviour_test_step = b.step("behaviour-test", "run the behavioural tests, through the 9P tree alone (test/behaviour/), and the T1 runner (-- [--seed N]... | --monkey | --replay)"); _ = units.add(b, behaviour_tests, behaviour_test_step); // An addon's own test: `--addon-test` over the fake (the template) diff --git a/core/Addon.zig b/core/Addon.zig index ec2f796a..c542e1f1 100644 --- a/core/Addon.zig +++ b/core/Addon.zig @@ -236,9 +236,9 @@ fn fileOf(fd: c_int) ?[5]i64 { /// library exports. A static binary cannot dlopen, and the loader below /// is Linux's (a memfd): this is how either has image and PDF panes. /// A build with -Dpdf=false has the image addon alone. -const compiled_in: []const *const Kind.Ops = if (!@import("builtin_addons").on) +const compiled_in: []const *const Kind.Ops = if (!@import("pardes_options").builtin_addons) &.{} -else if (@import("builtin_addons").pdf) +else if (@import("pardes_options").builtin_pdf) &.{ &@import("image_addon").pardes_addon, &@import("pdf_addon").pardes_addon } else &.{&@import("image_addon").pardes_addon}; diff --git a/core/Editor.zig b/core/Editor.zig index 9781d857..aaf6ab05 100644 --- a/core/Editor.zig +++ b/core/Editor.zig @@ -10,7 +10,7 @@ const Registers = @import("Registers.zig"); /// The library's build (build.zig `library`): a text with no pane and no /// core, its characters its own. Where an edit reaches a pane it branches /// on this at compile time, so the library never compiles the core. -pub const lib = @import("pardes_config").lib; +pub const lib = @import("pardes_options").lib; const Pardes = if (lib) void else @import("Core.zig"); const Syntax = if (lib) @import("lib_editor.zig").Syntax else void; const modal = @import("modal.zig"); diff --git a/core/Output.zig b/core/Output.zig index 23409b68..08abc154 100644 --- a/core/Output.zig +++ b/core/Output.zig @@ -9,7 +9,8 @@ const Pardes = pardes.Pardes; const modal = @import("modal.zig"); const limits = @import("memory.zig").limits; const builtins = @import("builtins.zig"); -const build_options = @import("pardes_config"); +const build_options = @import("pardes_options"); +const build_info = @import("build_info"); const lsp = @import("lsp/lsp.zig"); const look = @import("look.zig"); const locations = @import("locations.zig"); @@ -896,9 +897,9 @@ pub fn openBuild(p: *Pardes, id: usize) !void { const w = &out.writer; try w.print("{s}\n", .{@import("runtime").upgrade.version_line}); try w.print("commit {s}\nchange {s}\nbuilt {s}\n", .{ - build_options.commit orelse "not stamped (a Debug build with -Dplatform or --prefix)", - build_options.change orelse "not stamped", - build_options.built orelse "not stamped", + build_info.commit orelse "not stamped (a Debug build with -Dplatform or --prefix)", + build_info.change orelse "not stamped", + build_info.built orelse "not stamped", }); try w.print("zig {s}\nmode {s}\ntarget {s}-{s}-{s}\nplatform {s}\n", .{ builtin.zig_version_string, @tagName(builtin.mode), @@ -907,9 +908,9 @@ pub fn openBuild(p: *Pardes, id: usize) !void { }); try w.print("grammars {s}\naddons {s}\nsemantics {x:0>16}\n\ndependencies\n{s}", .{ if (build_options.grammars == .full) "full" else if (build_options.grammars == .minimal) "minimal" else "none", - if (@import("builtin_addons").on) "compiled in" else "loaded from /lib/pardes/addons", + if (build_options.builtin_addons) "compiled in" else "loaded from /lib/pardes/addons", @import("wire").semantics, - build_options.deps, + build_info.deps, }); const content = try out.toOwnedSlice(); return openRead(p, id, .{ .cmd = .Build }, "", content); @@ -918,7 +919,7 @@ pub fn openBuild(p: *Pardes, id: usize) !void { pub fn openChangelog(p: *Pardes, id: usize) !void { var out: std.Io.Writer.Allocating = .init(p.gpa); errdefer out.deinit(); - try out.writer.print("pardes {s}\n\n", .{build_options.version}); + try out.writer.print("pardes {s}\n\n", .{build_info.version}); try out.writer.writeAll(@embedFile("CHANGELOG.md")); const content = try out.toOwnedSlice(); return openRead(p, id, .{ .cmd = .Changelog }, "", content); diff --git a/core/Term.zig b/core/Term.zig index fde36420..3f975df6 100644 --- a/core/Term.zig +++ b/core/Term.zig @@ -15,7 +15,7 @@ const File = @import("File.zig"); const iface = plain.term; /// The terminal module's entries; null in a core built without it. -pub const ops: ?*const iface.Ops = if (@import("term_options").terminal) &@import("term").ops else null; +pub const ops: ?*const iface.Ops = if (@import("pardes_options").terminal) &@import("term").ops else null; /// What a core without a terminal says, once, where one would have been. pub const none = "no terminal in this build"; diff --git a/core/Text.zig b/core/Text.zig index 51d660cf..1b3e6273 100644 --- a/core/Text.zig +++ b/core/Text.zig @@ -113,7 +113,7 @@ refused: bool = false, pub inline fn pane(t: *Text) ?*Pane { // the library's text has none (lib_editor.zig): known at compile time, // so what an edit does with a pane is not compiled there - if (comptime @import("pardes_config").lib) return null; + if (comptime @import("pardes_options").lib) return null; return switch (t.what) { .body => @alignCast(@fieldParentPtr("body", t)), .tag => @alignCast(@fieldParentPtr("tag", t)), diff --git a/core/config.zig b/core/config.zig index 792a7e62..bb04d24d 100644 --- a/core/config.zig +++ b/core/config.zig @@ -39,7 +39,7 @@ comptime { @setEvalBranchQuota(20_000); // A path here is a leaf: no builtin's path is it or runs past it, and // none of it is a builtin's whole path. The library has no builtins. - if (!@import("pardes_config").lib) for (leader_args) |la| for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |path| { + if (!@import("pardes_options").lib) for (leader_args) |la| for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |path| { if (std.mem.startsWith(u8, path, la.path) or std.mem.startsWith(u8, la.path, path)) @compileError("leader_args path collides with " ++ @tagName(b) ++ ": " ++ la.path); }; diff --git a/core/lib_editor.zig b/core/lib_editor.zig index c459241a..3fe631af 100644 --- a/core/lib_editor.zig +++ b/core/lib_editor.zig @@ -3,7 +3,7 @@ //! true`, docs/next-editor.md). In-memory editing with helix's keys: no //! files, commands, builtins, prompts or views, which come back to the //! caller as an `action`. Nothing is copied here: a key runs the editor's -//! own normal.zig and edit.zig, built with `pardes_config.lib`, where a +//! own normal.zig and edit.zig, built with `pardes_options.lib`, where a //! text has no pane and its characters are its own. //! //! The editor is a value of plain data (`Editor(capacity)`): no pointer, diff --git a/core/memory.zig b/core/memory.zig index c628ae49..0e0dba29 100644 --- a/core/memory.zig +++ b/core/memory.zig @@ -1,6 +1,6 @@ const std = @import("std"); const builtin = @import("builtin"); -const config = @import("pardes_config"); +const config = @import("pardes_options"); const KiB = 1024; const MiB = 1024 * KiB; diff --git a/core/root.zig b/core/root.zig index 69ec3ded..df273738 100644 --- a/core/root.zig +++ b/core/root.zig @@ -98,12 +98,12 @@ pub const Host = host_io.Host; pub const frameMark = tracy.frameMark; /// The shell this build is for (build.zig's `-Dplatform`). -pub const platform = @import("pardes_config").platform; +pub const platform = @import("pardes_options").platform; -pub const version = @import("pardes_config").version; -pub const commit: ?[]const u8 = @import("pardes_config").commit; +pub const version = @import("build_info").version; +pub const commit: ?[]const u8 = @import("build_info").commit; -pub const isolated = @import("pardes_isolation").isolated; +pub const isolated = @import("pardes_options").isolated; pub const font_picker = platform == .gui or platform == .macos; @@ -442,7 +442,7 @@ test { // A window's build links the window's C (font.c over FreeType and // HarfBuzz) into each of its programs, and their allocator (ui_malloc // and the rest) is gui.zig's. - if (comptime @import("term_options").terminal and platform == .gui) _ = @import("dev").gui; + if (comptime @import("pardes_options").terminal and platform == .gui) _ = @import("dev").gui; } /// The container-level `var`s core/ may hold (at the top of a file, in a diff --git a/core/syntax.zig b/core/syntax.zig index 36aa8c2b..ba3851ab 100644 --- a/core/syntax.zig +++ b/core/syntax.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const config = @import("pardes_config"); +const config = @import("pardes_options"); const tracy = @import("tracy.zig"); const grammar_manifest = @import("grammar_manifest.zig"); const locations = @import("locations.zig"); diff --git a/core/tracy.zig b/core/tracy.zig index 3b0b8621..56429b1b 100644 --- a/core/tracy.zig +++ b/core/tracy.zig @@ -5,7 +5,7 @@ const std = @import("std"); const builtin = @import("builtin"); -pub const enable = if (builtin.is_test) false else @import("pardes_config").enable_tracy; +pub const enable = if (builtin.is_test) false else @import("pardes_options").enable_tracy; const SourceLocation = extern struct { name: ?[*:0]const u8, diff --git a/dev/root.zig b/dev/root.zig index 2c70783f..fc3ccfa8 100644 --- a/dev/root.zig +++ b/dev/root.zig @@ -26,9 +26,9 @@ test { _ = glide; // The frontends', which main.zig's test block collected: a shell's // build (shell-test); the core without a terminal never compiled them. - if (comptime @import("term_options").terminal) { - if (comptime @import("pardes_config").platform == .tui) _ = tui; - if (comptime @import("pardes_config").platform == .gui) _ = gui; + if (comptime @import("pardes_options").terminal) { + if (comptime @import("pardes_options").platform == .tui) _ = tui; + if (comptime @import("pardes_options").platform == .gui) _ = gui; _ = vaxis_input; } } diff --git a/docs/next-editor.md b/docs/next-editor.md index 120b4c09..e7168256 100644 --- a/docs/next-editor.md +++ b/docs/next-editor.md @@ -7,7 +7,7 @@ Decided 2026-11-17 on the coordinator's leans (survey: `.scratch/sketch/reports/editor-lib.md`); built the same day. One source of truth: the library runs the functions pardes runs, compiled from the -same files with `pardes_config.lib` set; nothing is copied for it. +same files with `pardes_options.lib` set; nothing is copied for it. ## The calls, as built diff --git a/docs/next-terminal.md b/docs/next-terminal.md index 26996897..c77ccd33 100644 --- a/docs/next-terminal.md +++ b/docs/next-terminal.md @@ -184,9 +184,9 @@ What differs from the plan above, and why: - **The ops are a compile-time constant, not handed over at start.** `Term.ops` (core/Term.zig:18) is `&@import("term").ops` when the build's - `term_options.terminal` says the core has a terminal, null otherwise. + `pardes_options.terminal` says the core has a terminal, null otherwise. Every core module but core-test's is given `term`; core-test's - (`core_lean` in build.zig) is not, and its `term_options` say so. A + (`core_lean` in build.zig) is not, and its `pardes_options` say so. A run-time `Pardes.Options.terminal` would have put the table in every test's options and every host's start for no gain: no build ever has two terminals, and a null known at compile time drops the dead code. diff --git a/runtime/macos.zig b/runtime/macos.zig index 408915da..24285c07 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -359,7 +359,7 @@ fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { core.settings.workspace_tag = if (std.c.getenv("PARDES_WORKSPACE_TAG")) |v| std.mem.eql(u8, std.mem.span(v), "1") else - @import("pardes_config").workspace_tag; + @import("pardes_options").workspace_tag; core.view().frontend.native_images = true; var prompt_rcs = host_io.Shell.prepare(); diff --git a/runtime/root.zig b/runtime/root.zig index ec89e734..930f3389 100644 --- a/runtime/root.zig +++ b/runtime/root.zig @@ -22,9 +22,9 @@ test { _ = ninep; // main.zig's test block collected the crash file's: a shell's build // (shell-test); the core without a terminal (core-test) never compiled it. - if (comptime @import("term_options").terminal) _ = crash; + if (comptime @import("pardes_options").terminal) _ = crash; // A window's build links the window's C (font.c over FreeType and // HarfBuzz) into each of its programs, and their allocator (ui_malloc // and the rest) is gui.zig's. - if (comptime @import("term_options").terminal and @import("pardes_config").platform == .gui) _ = @import("dev").gui; + if (comptime @import("pardes_options").terminal and @import("pardes_options").platform == .gui) _ = @import("dev").gui; } diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig index 8fb85cb7..dcde9c4d 100644 --- a/test/behaviour/panes.zig +++ b/test/behaviour/panes.zig @@ -888,7 +888,7 @@ test "panes: truncating body empties it, and a stat says the length after" { } test "panes: a rename colours a source its new name's language names, its text unchanged" { - if (@import("pardes_config").grammars == .disabled) return error.SkipZigTest; + if (@import("pardes_options").grammars == .disabled) return error.SkipZigTest; var s = try Session.initFile(std.testing.allocator, "fn check() void {}\n"); defer s.deinit(); const n = try s.focused(); diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index bd88b75e..cacee701 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -37,7 +37,7 @@ test "settings: Pet is the window's: a terminal's view refuses it; a window take defer s.deinit(); // Which build, from its options, not from the answer: a terminal's view // taking Pet must fail here, not pass as a window. - if (comptime @import("pardes_config").platform == .gui) { + if (comptime @import("pardes_options").platform == .gui) { try std.testing.expectEqualStrings("Pet off", try setting(&s, "Pet")); try s.write("/ctl", "Pet cat\n"); try std.testing.expectEqualStrings("Pet cat", try setting(&s, "Pet")); @@ -106,7 +106,7 @@ test "settings: a bad setting value is quoted, so two different bad values log a test "settings: a setting this frontend cannot show says GUI-only, never run as a command, and DumpDir reads back" { var s = try Session.initFile(std.testing.allocator, "x\n"); defer s.deinit(); - if (comptime @import("pardes_config").platform != .gui) { + if (comptime @import("pardes_options").platform != .gui) { _ = try s.refused("/ctl", "GripWidth 120\n"); try std.testing.expectEqualStrings("GripWidth is GUI-only, invalid here \"GripWidth\"", s.said); // A builtin the GUI alone has, written to a ctl or an exec, never @@ -158,7 +158,7 @@ test "settings: Back and Forward written to exec keep to the focused file" { }); } -const syntax = @import("pardes_config").grammars != .disabled; +const syntax = @import("pardes_options").grammars != .disabled; /// The style /screen draws the cell `into` cells into the first place /// `text` is drawn. @@ -314,7 +314,7 @@ test "settings: the user's startup file loads clean, every word of it known and const ctl = try s.read("/ctl"); for ([_][]const u8{ "Theme monokai_pro_classic\n", "CallstackDepth 64\n", "InactiveDim 5\n", "Shell fish\n", "JumpTrail on\n", "LocationsConfig context:4 tscontext:on tslocations:on layout:stacked\n" }) |line| try expectHas(ctl, line); // The window's words, which a terminal's view leaves to the window. - const window = @import("pardes_config").platform == .gui; + const window = @import("pardes_options").platform == .gui; for ([_][2][]const u8{ .{ "GripWidth", "110" }, .{ "CursorBlink", "off" }, .{ "WindowOpacity", "100" }, .{ "TaglineSize", "80" }, .{ "Pet", "frog" } }) |w| try expectHas(ctl, if (window) s.at("\n{s} {s}\n", .{ w[0], w[1] }) else s.at("\n# {s} unsupported\n", .{w[0]})); } diff --git a/test/output.zig b/test/output.zig index 17525616..dc99be8b 100644 --- a/test/output.zig +++ b/test/output.zig @@ -786,7 +786,7 @@ test "identical result refresh keeps warm content caches without allocation" { const index = try panes.File.lineIndex(p.gpa, file); const styles = try std.testing.allocator.dupe(u8, file.highlights); defer std.testing.allocator.free(styles); - if (@import("pardes_config").grammars != .disabled) try std.testing.expect(styles.len > 0); + if (@import("pardes_options").grammars != .disabled) try std.testing.expect(styles.len > 0); const revision = file.revision; const saved_revision = file.saved_revision; const body_ptr = file.content.ptr; -- cgit v1.3 From 30c6341ea868fc22deca16a5fb51fc19828cc2dc Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 19 Nov 2026 22:06:32 -0300 Subject: test/replicas: --bytes, the soak's clients as replicas of the bytes kind (each terminal fed the pty's bytes its units carry): a client dialling 100 ms into the flood, and at the shell session's end DA, DSR, CSI 16 t, a kitty query (answered on the session's pty once whatever the clients), an image by direct data shown and one by a file stored (a=t; shown, it moves the session's cursor and not a client's: a divergence until the file is taped); a join's cost and the reloads printed; --clients 5 --bytes --seeds 8 at 30/80/207 ms: diverged 0, unequal 0, quiet checks 1691/0 1303/0 1797/0, stops off may_wait 0, corpus 22 of 22, no leak, 2,168-2,321 reloads a run at 24-35 ms each (Debug), a join's step median 75 ms, dumps median 904 KB; the screen-state run beside it: diverged 0, unequal 0, deltas 1916/0 2028/0 1812/0, quiet 618/0 835/0 771/0 Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- test/replicas.zig | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/replicas.zig b/test/replicas.zig index 910c6e57..70edea75 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -53,6 +53,10 @@ const gpa = std.heap.c_allocator; pub const std_options: std.Options = .{ .log_level = .warn }; extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int; var trace = false; +/// `--bytes`: its clients are replicas of the bytes kind, each terminal fed +/// the pty's bytes its units carry into an emulator of its own, joined from +/// a dump with every emulator whole (core/replica.zig `Peers.bytes`). +var bytes_kind = false; /// The PDF the soak opens (`--pdf`), absolute. var pdf_path: ?[]const u8 = null; const frame_us = 16_667; @@ -791,6 +795,9 @@ const Soak = struct { /// encoding cost. framed: bool = false, encode_ns: u64 = 0, + /// The session's pty told the answer to the program's kitty query + /// (`questions`): once, whatever the clients. + kitty_answers: u32 = 0, /// A Peer's queue, swapped out as its writer swaps it (the Peers' /// allocator's). sending: std.ArrayListUnmanaged(u8) = .empty, @@ -809,6 +816,9 @@ const Soak = struct { fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void { const pane = id.index(); const s = of(ctx); + // Only the session's emulator answers its program: a client's + // answers are its tape's, never written (`questions`). + if (std.mem.indexOf(u8, bytes, "\x1b_Gi=31;OK") != null) s.kitty_answers += 1; s.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {}; } @@ -873,6 +883,7 @@ const Soak = struct { pub fn open(s: *Soak, l: *SessionLoop) !pardes.Host { s.l = l; l.peers.threads = false; + l.peers.bytes = bytes_kind; l.peers.flushed = .{ .ctx = s, .f = flushed }; const host: pardes.Host = .{ .ctx = s, .vtable = &vtable }; l.core.host = host; @@ -941,6 +952,9 @@ const Soak = struct { const at: u64 = switch (c) { 0, 1 => s.random.uintLessThan(u64, 100_000), 2 => 1_200_000, + // One joins in the middle of the flood, its emulators loaded + // whole and every other side's reloaded. + 3 => if (bytes_kind) flood_at + 100_000 else 2_300_000, else => 2_000_000 + c * 100_000, }; try net.send(.{ .at = at, .n = 0, .kind = .dial, .who = @intCast(c + 1), .bytes = &.{} }); @@ -1412,6 +1426,11 @@ const Soak = struct { } const rp = try replica.Replica.initDump(gpa, cl.id, cl.view, m.bytes, .{ .cols = cl.cols, .rows = cl.rows, .distrusted = &cl.distrusted }); cl.r = rp; + // Its terminals its own emulators, fed what the units carry. + if (bytes_kind) { + rp.t.screen_state = false; + rp.core().echo = null; + } rp.stats.samples = true; rp.t.local_files = true; rp.echo.now = m.at * 1000; @@ -1449,6 +1468,11 @@ const Soak = struct { totals.flood_us += s.flood_end -| flood_at; for (s.flood_deltas[0..s.clients.len]) |d| totals.flood_deltas += d; const want = pardes.tape.digestOf(core); + if (bytes_kind) std.debug.print("seed {d} rtt {d} ms: a join's step at worst {d} us (the session's reloads and its dump), the last dump {d} KB ({d} KB of state)\n", .{ s.r.seed, s.r.rtt_ms, s.l.peers.join_ns / 1000, s.l.peers.dump_bytes >> 10, s.l.peers.state_bytes >> 10 }); + if (bytes_kind and s.kitty_answers != 1) { + totals.unequal += 1; + std.debug.print("seed {d} rtt {d} ms: the program's kitty query was answered {d} times on the session's pty\n", .{ s.r.seed, s.r.rtt_ms, s.kitty_answers }); + } for (s.clients, 1..) |*cl, id| { totals.resizes += cl.resizes; totals.wakes += cl.wakes; @@ -1560,7 +1584,11 @@ fn run(init: std.process.Init, r: Run, dir: []const u8, totals: *Totals) !void { // flood of `yes`, read 4 KB at a time as a pty gives it. const tui = try screen_state.tuiStream(gpa); defer gpa.free(tui); - const shell_session = try screen_state.shellStream(gpa); + const session_only = try screen_state.shellStream(gpa); + defer gpa.free(session_only); + const asked = if (bytes_kind) try questions(dir) else ""; + defer if (bytes_kind) gpa.free(asked); + const shell_session = try std.mem.concat(gpa, u8, &.{ session_only, asked }); defer gpa.free(shell_session); const yes = try screen_state.yesStream(gpa, @intCast(r.flood_mb * (1 << 20) / 3)); defer gpa.free(yes); @@ -1584,6 +1612,23 @@ fn run(init: std.process.Init, r: Run, dir: []const u8, totals: *Totals) !void { if (soak.err) |err| return err; } +/// What the shell's program asks its terminal at the end of its session +/// (`--bytes`): device attributes, the cursor's place, the cell's size in +/// pixels, a kitty query; then a kitty image by direct data, shown, and one +/// by a file of the session's machine, stored (a=t), which no client loads +/// (P32): absent there, as every live terminal's image is under screen +/// state. Shown (a=T) it would move the session's cursor past it and not a +/// client's: a divergence until the file's bytes are taped (a later step). +fn questions(dir: []const u8) ![]u8 { + var path_buf: [300]u8 = undefined; + const path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/pixels.rgb", .{dir}, 0); + try writeText(path, &@as([12]u8, @splat(0x7f))); + var b64: [400]u8 = undefined; + const name = std.base64.standard.Encoder.encode(&b64, path); + return std.fmt.allocPrint(gpa, "\x1b[c\x1b[6n\x1b[16t\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\r\n" ++ + "\x1b_Ga=T,i=5,f=24,s=2,v=2;AAAAAAAAAAAAAAAA\x1b\\\r\n\x1b_Ga=t,i=6,t=f,f=24,s=2,v=2;{s}\x1b\\\r\n$ ", .{name}); +} + /// A typist: keys 50-200 ms apart, a pause now and then. fn typistGap(random: std.Random) u64 { return if (random.uintLessThan(u8, 12) == 0) random.intRangeAtMost(u64, 300_000, 1_500_000) else random.intRangeAtMost(u64, 50_000, 200_000); @@ -2722,6 +2767,10 @@ pub fn main(init: std.process.Init) !void { echo_mode = true; continue; } + if (std.mem.eql(u8, name, "--bytes")) { + bytes_kind = true; + continue; + } if (i + 1 >= args.len) return error.MissingValue; i += 1; const value = args[i]; @@ -2787,7 +2836,9 @@ pub fn main(init: std.process.Init) !void { defer stop_lines.deinit(gpa); for (rtts) |rtt| { var t: Totals = .{}; + pardes.Term.reloads = .{}; for (first..first + seeds) |seed| try run(init, .{ .seed = seed, .rtt_ms = rtt, .steps = steps, .clients = clients, .flood_mb = flood_mb }, dir, &t); + if (bytes_kind) std.debug.print("rtt {d}: {d} reloads of a terminal at joins, every side (the session's own too), {d} us each, {d} us at worst\n", .{ rtt, pardes.Term.reloads.n, pardes.Term.reloads.ns / @max(1, pardes.Term.reloads.n) / 1000, pardes.Term.reloads.worst_ns / 1000 }); const rollbacks = t.mispredicted + t.foreign; std.debug.print("{d:>4} {d:>6} {d:>7} {d:>7} {d:>6} {d:>6} {d:>6} ({d}+{d}) {d:>5.1}% {d:>6} {d:>5}/{d:<6} {d:>5}/{d:<5} ({d}) {d:>7}/{d:<7} {d:>8} {d:>7}\n", .{ rtt, t.inputs, t.speculated, -- cgit v1.3