diff options
71 files changed, 730 insertions, 315 deletions
diff --git a/abi/pardes.h b/abi/pardes.h index 65ca5c60..ca65b8f3 100644 --- a/abi/pardes.h +++ b/abi/pardes.h @@ -191,7 +191,7 @@ typedef enum { PARDES_HAPTIC_LOOK = 2, } pardes_haptic_e; -// ---------------------------------------------------------------- runtime +// ---------------------------------------------------------------- callbacks // What the host lends the core. Three callbacks, because everything else the // core wants done it already does itself: it owns the ptys, and it opens URLs @@ -214,7 +214,7 @@ typedef struct { // pardes_paste, which may be synchronous inside this call. Main thread, // inside pardes_tick. void (*read_clipboard)(void *userdata); -} pardes_runtime_s; +} pardes_callbacks_s; // ---------------------------------------------------------------- lifecycle @@ -223,7 +223,7 @@ typedef struct { // core defers each shell's greeting until it has seen one), and the first // forkpty takes its winsize straight off the core — boot at 80x24 and the // shell draws its first prompt to a width the window never had. -int pardes_init(const pardes_runtime_s *runtime, uint16_t cols, uint16_t rows); +int pardes_init(const pardes_callbacks_s *runtime, uint16_t cols, uint16_t rows); void pardes_deinit(void); // Drain pty output into the core and perform the effects it queued. Call after diff --git a/core/Addon.zig b/core/Addon.zig index ec2f796a..0b60ca9c 100644 --- a/core/Addon.zig +++ b/core/Addon.zig @@ -911,7 +911,7 @@ test "addon reload gives migration the old record version and saves the new vers return if (version == 1 and n == 1 and bytes[0] == 7) Kind.c.PA_OK else 1; } }; - const p = try @import("ninep/testing.zig").withFile(std.testing.allocator, "x\n"); + const p = try @import("ninep/harness.zig").withFile(std.testing.allocator, "x\n"); defer p.deinit(); var old = std.mem.zeroInit(Kind.Ops, .{ .head = std.mem.zeroInit(Kind.c.pa_head, .{ .size = @sizeOf(Kind.c.pa_head), .abi = Kind.abi, .version = 1 }), .open = Fake.open, .paint = Fake.paint, .dump = Fake.save, .load = Fake.load }); @memcpy(old.head.name[0..7], "migrate"); diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index 1b28267e..9b551e9b 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -2,6 +2,66 @@ ## Unreleased +- On a client, and so on a far one, what changes only the editor is + applied at once and only what touches the session's machine waits for + it (a save, a shell's keys, a file read from disk, a program run, a + kind whose state is the session's). Collapse, Newcol, Joincol, a window + resized and a pane's grip dragged beside a shell, Del and Zerox of a + file's pane, a yank to the clipboard, ClipPaste, a Theme after a + ThemeFile and a key that starts an addon's job each waited a round + trip and no longer do; nor does a click into or out of a shell whose + program asked for focus events, which hears of the focus a round trip + after it shows. + +- A client's yank to the system clipboard (`"+y`, ClipYank) fills the + clipboard of the machine the client runs on, ClipPaste pastes that + clipboard, and a link a client looks at opens there; all three went to + the session's machine. + +- `n` and `N` in a kind's pane (+Search, references, errors) step to the + places its rows hold, at once, and no longer stop on a bare word of a + command's output that names a file. + +- On a client, `~`, the default shell, a word run in the session's + directory, `Font`, `Fonts` and DumpDir's check of its directory are the + session's machine's, where a client's own step read its own machine and + could part from the session. + +- An idle client and its session stay idle: a client's quiet check, once + answered, asked again 300 ms later for ever, waking both processes + three times a second. + +- A pardes that starts while another, still running, loads an addon no + longer takes that load for a crash: a client starting while its session + loaded the same game listed it `skipped: it crashed its last load`, and + every key into the game waited for the session, until `Addon load`. + +- A search pattern that stops inside a count or an escape (typing + `a{2}` or `fn main() {`, `a{1,`, `\x`) no longer takes a safe build + down, nor in a fast one finds what the bytes after it made of it: it + is a pattern that does not compile, found as the characters it is. A + class escape holding a lone non-ASCII byte no longer loops without end, + and a half-typed pattern that does not compile (`(`, `[`) no longer + leaks. + +- A client no longer diverges and joins again after a press on a + notice's chip, or a click in a big markdown text's table, in a view + whose frame it had not drawn; a big text's tables are read whole when + it opens (18 ms for 2.7 MB of tables), where they were read 4096 lines + first, then 4 ms a frame. + +- A client no longer crashes when another's input rolls back its own Del + of a pane whose kind's state is not plain, nor drawing a closed + terminal with a kitty image it brought back (`Look @pN`) under a + rollback. A kind's picture drawn for a pane closed meanwhile is let go, + where it was kept for the session's life; `pardes help` with no session + running no longer crashes now and then, freeing its own core while + still answering it. + +- The tag word `Unattach` is `Undock`: a +Search docked under the pane it + answers for leaves it with `Undock`, and stays where it is, a pane of its + own. *Attach* is a client joining a session now; `Unattach` is an + unknown word, with no alias. - The row after a file's last newline, where the cursor can sit and no line is yet, shows `~` in the gutter where its line number was, as helix's does. @@ -21,7 +81,7 @@ `zig build builtins-json -Dplatform=tui`, and a test says when it is stale. -- The text pane is a library too, `pardes-editor` (`src/lib_editor.zig`, +- The text pane is a library too, `pardes-editor` (`core/lib_editor.zig`, docs/next-editor.md): helix's keys on a text kept in memory, for a program that draws it itself (a sketch with a language of its own). It is a value of plain data, every capacity in its type, copied anywhere @@ -42,10 +102,10 @@ where its grammar has an indent query (a `Language`'s `indents`), as a file's does from its own, so a language whose lines end in `)` is not pushed a level in at every line. -- The terminal is a module of its own (`src/term/`: the emulator, its +- The terminal is a module of its own (`core/term/`: the emulator, its screen state for replicas, kitty images, the pager's parse), which never imports the core and is reached through one table of plain-data - entries, `src/Term.zig` the core's side (docs/next-terminal.md). Editing + entries, `core/Term.zig` the core's side (docs/next-terminal.md). Editing a terminal's text is the core's, on a copy of its rows, as before, and predicted echo stays the core's; nothing a session does changes, and a session dumped before loads after. `zig build core-test` builds the core @@ -73,7 +133,7 @@ directory), and only what no rule set takes is Look's own. The default rules keep every look as it was: the browser for a URL, a bare `.diff` or `.patch` stacked in a +Diff, `git show` of a commit hash in a git - work tree are now rules of `src/plumbing`, no longer written into + work tree are now rules of `core/plumbing`, no longer written into Look. `Diff` takes a file or a revision (`Diff fix.patch`, `Diff 3f2a9c1`), and a rule's Diff that cannot declines, so the look goes on. `Plumb` opens your plumbing file (`<config>/plumbing`, `include @@ -94,7 +154,7 @@ takes a message and sends it where they say, to a port pardes reads (`edit`, `web`, a loaded kind) or to a word or command started, with Plan 9's words when it cannot. A session starts with `include basic`, - pardes's rules (`src/plumbing`). Kept in a dump. `$1`-`$9` are refused, + pardes's rules (`core/plumbing`). Kept in a dump. `$1`-`$9` are refused, the regular expressions having no submatches. - A query pane's row looked at on its address (its gutter) opens the @@ -148,7 +208,7 @@ for Zig 0.17 was deleted, and a fresh checkout could not fetch it. - pardes's syntax is a library: a Zig package that depends on pardes is - given the `pardes-syntax` module (`src/lib_syntax.zig`), with the + given the `pardes-syntax` module (`core/lib_syntax.zig`), with the grammars, highlighting, declarations, syntax tree and themes as the editor has them, for a program that draws source text itself. Every dependency but tree-sitter's runtime is lazy in the manifest, so such a @@ -216,12 +276,12 @@ saying so until a Look or a watch of it. A picture's or a PDF's tag has its art words from the first frame. A Debug pardes says a kind's call over 16 ms; `--addon-test` fails on it, and has `view N on|off`. - `src/kinds/addon.zig` wraps the whole header. + `abi/addon.zig` wraps the whole header. - `zig build static -Dplatform=tui -Dtarget=x86_64-linux-musl`: one statically linked `pardes` with the image and PDF addons compiled in (`/addons` lists them `builtin`; `Addon reload` refuses them). It replaces `-Dstatic`, which glibc refused (it links only dynamically). -- Addons in Zig: `src/kinds/addon.zig` (over the same header, nothing of +- Addons in Zig: `abi/addon.zig` (over the same header, nothing of the core) makes a kind's `pa_ops` from a struct of its functions, with the pane's arena as an Allocator, typed keys, a window to `put` text in, a deadline for `tick`, a struct's bytes as its record and its own `zig @@ -246,7 +306,7 @@ installed beside the binaries and loaded at start; a pardes without it shows image files as text. -- Addons speak ABI 2 (src/kinds/pardes_addon.h): `tick` is told +- Addons speak ABI 2 (abi/pardes_addon.h): `tick` is told `PA_FOCUSED` and called again after anything happens to its pane, so a game stands still unfocused asking for nothing; one `paint` a frame; jobs on the host's workers, dropped across a reload; each session its @@ -366,7 +426,7 @@ session kernel-mounted through Linux v9fs, a one-off), with their tests; a kernel mount made by hand still works, as the build notes say. - The terminal frontend is the tui: `zig build -Dplatform=tui`, its code - in `src/tui/` (the binary is still `pardes`, and `--tty` still starts + in `dev/tui/` (the binary is still `pardes`, and `--tty` still starts one shell pane in tty mode). The builtin that opens a terminal pane, `Tty`, is `Term` (`SPC n t`); `Tty` still runs it, as acme's words run theirs. diff --git a/core/Core.zig b/core/Core.zig index fe05c5b4..351c3626 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -287,7 +287,7 @@ session_home: [limits.host_path_cap]u8 = undefined, session_home_len: ?u16 = null, session_shell: [limits.host_path_cap]u8 = undefined, session_shell_len: u16 = 0, -settings: config.Runtime = .{ .font = .{ .tagline_percent = config.gui_tagline_font_percent } }, +settings: config.Settings = .{ .font = .{ .tagline_percent = config.gui_tagline_font_percent } }, locations_config: locations.Config = .{}, locations_cache: locations.Cache = .{}, tty_filter_palette: pardes.Term.FilterPalette = .{}, @@ -295,10 +295,10 @@ font_request_taken: bool = false, custom_theme: ?Theme = null, /// bodyChrome's: the theme it was worked out for, and it. body_chrome: ?struct { theme: Theme, chrome: ChromeTheme } = null, -theme_file_path: config.Runtime.Text(limits.host_path_cap) = .{}, +theme_file_path: config.Settings.Text(limits.host_path_cap) = .{}, /// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and /// what a failed ThemeFile goes back to (colors.revertThemeFile). -theme_file_loaded: config.Runtime.Text(limits.host_path_cap) = .{}, +theme_file_loaded: config.Settings.Text(limits.host_path_cap) = .{}, theme_file_generation: u32 = 0, theme_file_pane: u8 = 0, chrome: colors.ChromeTheme = colors.initial_chrome, @@ -1101,7 +1101,7 @@ fn observeFontInner( p: *Pardes, effective_name: []const u8, effective_size_hundredths: u16, - unit: config.Runtime.FontSizeUnit, + unit: config.Settings.FontSizeUnit, ) bool { if (!p.settings.font.effective_name.set(effective_name)) return false; p.settings.font.effective_size_hundredths = effective_size_hundredths; @@ -1116,7 +1116,7 @@ fn acknowledgeFontInner( p: *Pardes, effective_name: []const u8, effective_size_hundredths: u16, - unit: config.Runtime.FontSizeUnit, + unit: config.Settings.FontSizeUnit, ) bool { if (!p.settings.font.pending or !p.font_request_taken) return false; const changed = !std.mem.eql( @@ -2941,7 +2941,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe // A body's click written back to event is done as the click: sent. A // line written to exec came back as F and runs as the command it was. { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const event = ctlfs.Node.of(file.serial, .event); const h = th.call(p, .{ .tag = 1, .op = .open, .node = event }).reply.handle; defer _ = th.call(p, .{ .tag = 2, .op = .release, .node = event, .handle = h }); @@ -3035,7 +3035,7 @@ test "a REPL bound for a language takes the exec made on a body in it; tags, Exe try std.testing.expect(Sent.len[1] == 0 and file.prompt == .none); // The question is in the log, and a script answers it on the ctl. { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); _ = exec.executeFrom(p, 0, "print(5)", true); var want: [32]u8 = undefined; try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "ask {d} repl a b\n", .{file.serial}))); @@ -3419,7 +3419,7 @@ test "Font keeps requested and acknowledged faces as separate plain state" { try std.testing.expect(!p.settings.font.pending); try std.testing.expectEqualStrings(installed[0].name, p.settings.font.effective_name.get()); try std.testing.expectEqual(@as(u16, 1375), p.settings.font.effective_size_hundredths); - try std.testing.expectEqual(config.Runtime.FontSizeUnit.pixels, p.settings.font.effective_size_unit); + try std.testing.expectEqual(config.Settings.FontSizeUnit.pixels, p.settings.font.effective_size_unit); try std.testing.expect(!p.acknowledgeFont("Duplicate Ack", 1400, .pixels)); try std.testing.expect(p.executeBuiltinLine(p.view().active, cmd)); @@ -3537,7 +3537,7 @@ test "Tab N draws every pane's tab N cells wide and clicks count past it; bare T try std.testing.expect(p.executeBuiltinLine(0, "Tab 0")); try std.testing.expectEqual(@as(u16, 8), p.settings.tab); // The ctl read's tab column, and a Dump's settings. - const ctl_text = @import("ninep/testing.zig").rd(p, ctlfs.Node.of(pane.serial, .ctl), 0, 4096).bytes; + const ctl_text = @import("ninep/harness.zig").rd(p, ctlfs.Node.of(pane.serial, .ctl), 0, 4096).bytes; try std.testing.expect(std.mem.indexOf(u8, ctl_text, " 8 ") != null); try dump.dumpState(p); const restored = try dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon"); diff --git a/core/Dir.zig b/core/Dir.zig index a82887fb..29c5cdc8 100644 --- a/core/Dir.zig +++ b/core/Dir.zig @@ -430,7 +430,7 @@ test "an exec in a directory pane runs in its directory, and its +Errors goes th } test "over 9P a directory pane is a text pane whose name ends in /, its body the listing, ctl's isdir 1, and get reads it again" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const tree = @import("ninep/tree.zig"); var tmp = testing.tmpDir(.{}); defer tmp.cleanup(); diff --git a/core/Effect.zig b/core/Effect.zig index 9b00d8dc..5e821065 100644 --- a/core/Effect.zig +++ b/core/Effect.zig @@ -681,7 +681,7 @@ test "a save path that names no file is refused before anything is rewritten" { } test "a Save the host could not do logs no save record" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const p = try th.withFile(std.testing.allocator, "x\n"); defer p.deinit(); const Failing = struct { diff --git a/core/Handover.zig b/core/Handover.zig index bcf42c31..dde31f8b 100644 --- a/core/Handover.zig +++ b/core/Handover.zig @@ -165,7 +165,7 @@ pub fn finish(h: *Handover, p: *Pardes, seq: u32, to: []const u8, failure: ?[]co const pane = p.panes[id].?; if (pane.file == null or pane.file.?.revision != revision) { // Out of its group, or the owner's close would take it along. - pane.attached_to = null; + pane.docked_to = null; kept += 1; continue; } @@ -277,7 +277,7 @@ pub fn adopt(p: *Pardes, bytes: []const u8) !usize { for (st.owners, 0..) |owner, k| { const at = owner orelse continue; if (at >= n) continue; - p.panes[slots[k]].?.attached_to = p.panes[slots[at]].?.serial; + p.panes[slots[k]].?.docked_to = p.panes[slots[at]].?.serial; } const tc = layout.targetColumn(p, x); var heights: [MAX_PANES]u16 = @splat(0); diff --git a/core/Output.zig b/core/Output.zig index 3ac9f521..ab84ae35 100644 --- a/core/Output.zig +++ b/core/Output.zig @@ -705,7 +705,7 @@ pub fn openThemes(p: *Pardes, id: usize) !void { for (pardes.themes, 0..) |t, i| { if (pardes.colors.groupAt(i)) |title| try out.writer.print("{s}# {s}\n", .{ if (i == 0) "" else "\n", title }); - try out.writer.print(comptime config.Runtime.findAction(.theme).?.word ++ " {s}\n", .{t.name}); + try out.writer.print(comptime config.Settings.findAction(.theme).?.word ++ " {s}\n", .{t.name}); } const content = try out.toOwnedSlice(); try openStepped(p, id, .{ .cmd = .Themes }, content); @@ -716,7 +716,7 @@ pub fn isWalkRow(file: *const File.State, row: usize, line: []const u8) bool { if (usesLocationsConfig(state.from) or std.meta.eql(state.from, Origin{ .query = .callstack })) return isResultRow(file, row); if (!std.meta.eql(state.from, Origin{ .cmd = .Themes })) return true; // Section labels are for reading, not stops in the command walk. - return std.mem.startsWith(u8, std.mem.trimStart(u8, line, " \t"), comptime config.Runtime.findAction(.theme).?.word ++ " "); + return std.mem.startsWith(u8, std.mem.trimStart(u8, line, " \t"), comptime config.Settings.findAction(.theme).?.word ++ " "); } pub fn openFonts(p: *Pardes, id: usize) !void { @@ -733,7 +733,7 @@ fn fontsListed(gpa: std.mem.Allocator, arena: std.mem.Allocator) anyerror![]u8 { var out: std.Io.Writer.Allocating = .init(gpa); errdefer out.deinit(); for (fonts.list(arena, null)) |f| - try out.writer.print(comptime config.Runtime.findAction(.font).?.word ++ " {s}\n", .{f.name}); + try out.writer.print(comptime config.Settings.findAction(.font).?.word ++ " {s}\n", .{f.name}); return out.toOwnedSlice(); } @@ -852,7 +852,7 @@ pub fn openConfig(p: *Pardes, id: usize) !void { var located: std.Io.Writer.Allocating = .init(p.gpa); defer located.deinit(); try p.locations_config.write(&located.writer); - try config.Runtime.writeReport(&out.writer, .{ + try config.Settings.writeReport(&out.writer, .{ .locations = located.written(), .default_dump_dir = p.tape.authority(dumpDirectory, .{@as([]u8, &dir_buf)}), .startup_config_path = p.startupPath(), diff --git a/core/Places.zig b/core/Places.zig index 1416dbd3..9ffbff88 100644 --- a/core/Places.zig +++ b/core/Places.zig @@ -890,5 +890,8 @@ test "a session's places loaded from its dump find what an edit makes as the ses pn.places.fill(p, pn, 0, frame_steps); try std.testing.expectEqual(@as(usize, 3), pn.places.hits.items.len); } + // An edit stamps the text with the wall clock's second (File.edit's + // mtime): the two cores' edits, a moment apart, can fall in two. + b.panes[b.view().active].?.file.?.mtime = a.panes[a.view().active].?.file.?.mtime; try std.testing.expectEqual(pardes.walk.digest(Pardes, a), pardes.walk.digest(Pardes, b)); } diff --git a/core/Query.zig b/core/Query.zig index 02e17a1b..704206e6 100644 --- a/core/Query.zig +++ b/core/Query.zig @@ -200,16 +200,16 @@ fn freeSaved(gpa: std.mem.Allocator, s: Saved) void { gpa.free(s.items); } -/// The owner's query pane (attached to it, or left where it was by -/// Unattach): the one a later search from it reuses. +/// The owner's query pane (docked to it, or left where it was by +/// Undock): the one a later search from it reuses. pub fn ofOwner(p: *Pardes, owner_serial: u32) ?usize { var found: ?usize = null; for (p.panes, 0..) |slot, i| { const pane = slot orelse continue; const q = pane.query orelse continue; if (q.owner != owner_serial) continue; - // the attached one first: an unattached one is a kept result - if (pane.attached_to == owner_serial) return i; + // the docked one first: an undocked one is a kept result + if (pane.docked_to == owner_serial) return i; found = found orelse i; } return found; @@ -1738,7 +1738,7 @@ fn promote(p: *Pardes, qid: usize, id: usize) void { // Its text was read from that file to preview it (displayPreview). f.on_disk = filesystem.localPath(f.path) != null; f.syntax_dirty = true; - pane.attached_to = null; + pane.docked_to = null; if (f.on_disk) p.recent.opened(p.recentGpa(), f.path); if (filesystem.localPath(f.path) != null) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } }); pardes.ctlfs.events.noteLog(p, .rename, pane); @@ -1871,7 +1871,7 @@ pub fn cancel(p: *Pardes, id: usize) void { // A preview made for the query Esc took back has no use: its rows // go to the text whose rows they were. if (previewOf(p, id)) |pid| { - p.panes[pid].?.attached_to = null; + p.panes[pid].?.docked_to = null; p.removePane(pid, owner_id) catch |err| p.reportError(.at(id), "query", err); q.preview = 0; } @@ -2338,7 +2338,7 @@ test "Find: names fuzzy per keystroke, the group born with its +Preview, nothing try std.testing.expectEqual(pv, p.view().active); try std.testing.expectEqual(serial, p.panes[pv].?.serial); try std.testing.expect(p.panes[pv].?.file.?.output == null); - try std.testing.expect(p.panes[pv].?.attached_to == null); + try std.testing.expect(p.panes[pv].?.docked_to == null); layout.compute(p); try std.testing.expectEqualDeep(rect, p.view().rects[pv]); try std.testing.expect(q.frozen); @@ -2738,6 +2738,6 @@ test "a query row's address reaches every way a look arrives: an empty look writ // the whole row written to the pane's look: the place a.body.cur_row = 0; const tree = @import("ninep/tree.zig"); - try std.testing.expectEqual(tree.Status.ok, @import("ninep/testing.zig").wr(p, tree.Node.of(qp.serial, .look), line).reply.status); + try std.testing.expectEqual(tree.Status.ok, @import("ninep/harness.zig").wr(p, tree.Node.of(qp.serial, .look), line).reply.status); try std.testing.expectEqual(@as(i32, 3), a.body.cur_row); } diff --git a/core/builtins.zig b/core/builtins.zig index 6f37e86d..a7340352 100644 --- a/core/builtins.zig +++ b/core/builtins.zig @@ -18,7 +18,7 @@ const keys = @import("keys.zig"); const Jump = @import("Jump.zig"); /// What this build's own frontend draws and its host does: the render's. -pub const frontend: config.Runtime.Capabilities = .{ +pub const frontend: config.Settings.Capabilities = .{ .font_picker = pardes.font_picker, // The tty's font belongs to its emulator. .tagline_font_size = pardes.platform != .tui, @@ -32,15 +32,15 @@ pub const frontend: config.Runtime.Capabilities = .{ /// its own frontend does (`viewCapabilities`), so a terminal's replica of a /// window's session steps as the window's own does, and back. pub const desktop = pardes.platform == .tui or pardes.platform == .gui; -const window_capabilities: config.Runtime.Capabilities = .{ .font_picker = true, .tagline_font_size = true, .window_opacity = true, .pixels = true }; -const terminal_capabilities: config.Runtime.Capabilities = .{ .font_picker = false, .tagline_font_size = false, .window_opacity = false, .pixels = false }; +const window_capabilities: config.Settings.Capabilities = .{ .font_picker = true, .tagline_font_size = true, .window_opacity = true, .pixels = true }; +const terminal_capabilities: config.Settings.Capabilities = .{ .font_picker = false, .tagline_font_size = false, .window_opacity = false, .pixels = false }; /// The words this build has: a desktop build's are the window's. -pub const capabilities: config.Runtime.Capabilities = if (desktop) window_capabilities else frontend; +pub const capabilities: config.Settings.Capabilities = if (desktop) window_capabilities else frontend; /// What the live view's frontend takes: a window's, or a terminal's /// (`Pardes.frontend`, which its client says, Event.frontend). -pub fn viewCapabilities(p: *const Pardes) config.Runtime.Capabilities { +pub fn viewCapabilities(p: *const Pardes) config.Settings.Capabilities { if (comptime !desktop) return frontend; return if (p.view().frontend.windowed) window_capabilities else terminal_capabilities; } @@ -136,10 +136,10 @@ fn manualBuiltinList() []const type { } } -fn settingList() []const config.Runtime.Setting { +fn settingList() []const config.Settings.Setting { comptime { - var list: []const config.Runtime.Setting = &.{}; - for (config.Runtime.settings) |setting| if (setting.enabled(capabilities)) { + var list: []const config.Settings.Setting = &.{}; + for (config.Settings.settings) |setting| if (setting.enabled(capabilities)) { list = list ++ .{setting}; }; return list; @@ -175,7 +175,7 @@ pub const registry = struct { } /// `here` for a frontend of these capabilities, windowed or not. - pub fn hereFor(b: Builtin(), caps: config.Runtime.Capabilities, windowed: bool) bool { + pub fn hereFor(b: Builtin(), caps: config.Settings.Capabilities, windowed: bool) bool { inline for (comptime manualBuiltinList(), 0..) |T, i| if (@backingInt(b) == i) return !@hasDecl(T, "in_window") or windowed; inline for (comptime settingList(), comptime manualBuiltinList().len..) |setting, i| if (@backingInt(b) == i) return setting.enabled(caps); unreachable; @@ -1131,13 +1131,13 @@ pub const Collapse = struct { } }; -/// Unattach a pane from the pane it answers for: it stays where it is, a +/// Undock a pane from the pane it answers for: it stays where it is, a /// pane of its own, and the next search from that pane opens another /// under it. -pub const Unattach = struct { +pub const Undock = struct { pub fn run(c: Ctx) void { - if (c.pane.attached_to == null) return c.p.reportFailure(c.id, "Unattach: not attached to a pane"); - c.pane.attached_to = null; + if (c.pane.docked_to == null) return c.p.reportFailure(c.id, "Undock: not docked to a pane"); + c.pane.docked_to = null; } }; @@ -1873,7 +1873,7 @@ fn testDump(buf: []u8) ![]const u8 { test "capabilities exactly gate setting builtins" { const Builtin = registry.Builtin(); - for (config.Runtime.settings) |setting| { + for (config.Settings.settings) |setting| { const registered = std.meta.stringToEnum(Builtin, setting.word) != null; try std.testing.expectEqual(setting.enabled(capabilities), registered); } diff --git a/core/builtins_json.zig b/core/builtins_json.zig index 3773e5ae..23e15098 100644 --- a/core/builtins_json.zig +++ b/core/builtins_json.zig @@ -65,11 +65,11 @@ pub fn write(w: *std.Io.Writer, addon_sources: []const []const u8) std.Io.Writer try w.writeAll(if (builtins.registry.takesArg(b)) "true" else "false"); try w.writeAll(", \"scope\": "); try str(if (b == .Edit) "both" else if (builtins.registry.scope(b) == .session) "root" else "pane", .{}, w); - const setting = config.Runtime.find(name); + const setting = config.Settings.find(name); try w.writeAll(", \"setting\": "); try w.writeAll(if (setting != null) "true" else "false"); try w.writeAll(", \"choices\": "); - if (setting) |s| if (config.Runtime.choices(s.action)) |v| try str(v, .{}, w) else try w.writeAll("null") else try w.writeAll("null"); + if (setting) |s| if (config.Settings.choices(s.action)) |v| try str(v, .{}, w) else try w.writeAll("null") else try w.writeAll("null"); var buf: [2048]u8 = undefined; const doc = if (setting) |s| s.doc else ctl.summaryOf(name, &buf); try w.writeAll(", \"doc\": "); diff --git a/core/config.zig b/core/config.zig index 792a7e62..0032b03a 100644 --- a/core/config.zig +++ b/core/config.zig @@ -79,7 +79,7 @@ pub const leader_path = paths: { .Mode = null, .Togglettymode = null, .Collapse = null, - .Unattach = null, + .Undock = null, .Undo = null, .Edit = null, .Redo = null, @@ -600,7 +600,7 @@ pub const delete_word_forward: []const Chord = &.{ .{ .cp = 'd', .alt = true }, pub const kill_to_line_start: []const Chord = &.{.{ .cp = 'u', .ctrl = true }}; pub const kill_to_line_end: []const Chord = &.{.{ .cp = 'k', .ctrl = true }}; -pub const Runtime = struct { +pub const Settings = struct { theme: usize = 0, wrap: bool = true, debug: bool = false, @@ -662,7 +662,7 @@ pub const Runtime = struct { tab: u16 = tab_width, callstack_depth: u8 = @import("lsp/lsp.zig").callstack_default_depth, - /// A setting that is one of a few words, each an enum field of Runtime. + /// A setting that is one of a few words, each an enum field of Settings. pub const Choice = enum { pet }; pub const Pet = enum { off, cat, frog }; @@ -710,7 +710,7 @@ pub const Runtime = struct { }; // Validate the complete request before changing any member. - pub fn requestFont(state: *Runtime, path: []const u8, name: []const u8, size_hundredths: u16) bool { + pub fn requestFont(state: *Settings, path: []const u8, name: []const u8, size_hundredths: u16) bool { if (path.len > state.font.requested_path.bytes.len or name.len > state.font.requested_name.bytes.len) return false; if (size_hundredths != 0 and (size_hundredths < 800 or size_hundredths > 7200)) return false; @@ -834,7 +834,7 @@ pub const Runtime = struct { } /// `home`: what `~` is (the session's: Pardes.session_home). - pub fn apply(state: *Runtime, tape: *pardes.tape.Tape, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { + pub fn apply(state: *Settings, tape: *pardes.tape.Tape, setting: Setting, argument: ?[]const u8, home: ?[]const u8) bool { switch (setting.action) { // Every toggle names a bool field of its own, so one line covers // all of them and a new toggle needs no arm here. Bare, a toggle @@ -903,7 +903,7 @@ pub const Runtime = struct { return switch (action) { .toggle => "on, off", .choice => |which| switch (which) { - inline else => |field| comptime words.of(@FieldType(Runtime, @tagName(field))), + inline else => |field| comptime words.of(@FieldType(Settings, @tagName(field))), }, else => null, }; @@ -970,7 +970,7 @@ pub const Runtime = struct { default_dump_dir: []const u8 = "", native_images: bool = false, capabilities: Capabilities, - state: *const Runtime, + state: *const Settings, /// The `LocationsConfig` argument in effect, as it would be typed. locations: []const u8 = "", }; @@ -1068,7 +1068,7 @@ pub const Runtime = struct { } test "a toggle flips when bare and sets when told on or off" { - var state: Runtime = .{}; + var state: Settings = .{}; const verbose = find("Verbose").?; try std.testing.expect(state.verbose); // Bare, it flips: that is what a tagline word does. @@ -1090,7 +1090,7 @@ pub const Runtime = struct { } test "simple setting application mutates only its plain field" { - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expect(apply(&state, &pardes.tape.none, find("Wrap").?, null, null)); try std.testing.expect(!state.wrap); try std.testing.expect(apply(&state, &pardes.tape.none, find("Shell").?, " fish\n", null)); @@ -1100,7 +1100,7 @@ pub const Runtime = struct { test "tagline size validates before mutating live state" { const setting = find("TaglineSize").?; - var state: Runtime = .{}; + var state: Settings = .{}; for ([_][]const u8{ "1", " 82\n", "100" }) |argument| { try std.testing.expect(apply(&state, &pardes.tape.none, setting, argument, null)); @@ -1116,7 +1116,7 @@ pub const Runtime = struct { test "window opacity defaults to opaque validates atomically and retries" { const setting = find("WindowOpacity").?; - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expectEqual(@as(u8, 100), state.window_opacity); try std.testing.expect(state.window_opacity_pending); try std.testing.expectEqual(Capability.window_opacity, availability(setting.action).?); @@ -1141,7 +1141,7 @@ pub const Runtime = struct { } test "font request tuple rejects atomically" { - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expect(requestFont(&state, "/fonts/old.ttf", "Old", 1200)); var too_long: [256]u8 = @splat('x'); try std.testing.expect(!requestFont(&state, "/fonts/new.ttf", &too_long, 1800)); @@ -1168,7 +1168,7 @@ pub const Runtime = struct { // The switches, Theme, Shell, Pager and the shell's own lines are // test/behaviour/settings.zig's, read through the root ctl and the // +DumpConfig pane. - var state: Runtime = .{}; + var state: Settings = .{}; // Every setting, every context line: the report outgrows 4K. var storage: [8192]u8 = undefined; const context: ReportContext = .{ @@ -1219,7 +1219,7 @@ pub const Runtime = struct { "# Native images: on\n", }) |expected| try std.testing.expect(std.mem.indexOf(u8, report, expected) != null); - var defaults: Runtime = .{}; + var defaults: Settings = .{}; var defaults_context = context; defaults_context.startup_config_path = null; defaults_context.platform = "tui"; @@ -1693,7 +1693,7 @@ test "wheel drift guard" { } test { - _ = Runtime; + _ = Settings; _ = User; } @@ -1838,14 +1838,14 @@ test "reference.typ's #fstree is the tree the session serves, file for file" { } test "CallstackDepth is bounded and keeps the last valid runtime limit" { - var state: Runtime = .{}; + var state: Settings = .{}; try std.testing.expectEqual(@as(u8, 8), state.callstack_depth); for ([_][]const u8{ "1", "8", "16", "64" }) |value| { - try std.testing.expect(Runtime.apply(&state, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(Settings.apply(&state, &pardes.tape.none, Settings.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(try std.fmt.parseInt(u8, value, 10), state.callstack_depth); } for ([_][]const u8{ "0", "65", "256", "-1", "+8", "1_6", "eight", "" }) |value| { - try std.testing.expect(!Runtime.apply(&state, &pardes.tape.none, Runtime.find("CallstackDepth").?, value, null)); + try std.testing.expect(!Settings.apply(&state, &pardes.tape.none, Settings.find("CallstackDepth").?, value, null)); try std.testing.expectEqual(@as(u8, 64), state.callstack_depth); } } diff --git a/core/dump.zig b/core/dump.zig index 3b2b22e2..e6cdceec 100644 --- a/core/dump.zig +++ b/core/dump.zig @@ -710,11 +710,11 @@ pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![ // The fields it changes put back after, not the whole pane (88 KB) kept // aside: a store record is made at every close. const cwd = pane.cwd; - const attached_to = pane.attached_to; + const docked_to = pane.docked_to; const terminal = pane.terminal; defer { pane.cwd = cwd; - pane.attached_to = attached_to; + pane.docked_to = docked_to; pane.terminal = terminal; } if (cwd == .inherited) { @@ -722,7 +722,7 @@ pub fn savePane(gpa: std.mem.Allocator, pane: *pardes.panes.Pane, slim: bool) ![ const dir = pane.cwdSlice(); pane.cwd = .{ .owned = @constCast(dir) }; } - pane.attached_to = null; + pane.docked_to = null; if (!slim) return walk.save(pardes.panes.Pane, gpa, pane); pane.terminal = null; const f = if (pane.file) |*file| file else return walk.save(pardes.panes.Pane, gpa, pane); @@ -987,7 +987,7 @@ test "a session with every column it may hold dumps and restores them all" { } test "a restored session's column and workspace tags take more than one selection, and its 9P files have a time" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); @@ -1039,7 +1039,7 @@ test "a pane restored with unsaved text is asked about by Exit, Restore, Del and const id = for (restored.panes, 0..) |slot, i| { if (slot) |candidate| if (candidate.file != null and candidate.file.?.output == null) break i; } else return error.FileLost; - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const node = if (word == .Del or word == .get) ctlfs.Node.of(restored.panes[id].?.serial, .ctl) else @@ -1173,7 +1173,7 @@ test "a session's byte dump read by name, field by field as another build reads test "an old dump's file, a byte dump, is read by -l and by a Restore of its path, for one release" { const gpa = std.testing.allocator; - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const p = try Pardes.init(gpa, .{ .tty_only = true }); defer p.deinit(); _ = try p.setTestFile("kept in a .dump\n"); diff --git a/core/edit_cmd.zig b/core/edit_cmd.zig index 43006503..9f1f7862 100644 --- a/core/edit_cmd.zig +++ b/core/edit_cmd.zig @@ -452,7 +452,7 @@ fn commit(p: *Pardes, pd: *Pending, outputs: []const []const u8) void { } const testing = std.testing; -const th = @import("ninep/testing.zig"); +const th = @import("ninep/harness.zig"); const tree = @import("ninep/tree.zig"); /// The answer of the Edit waiting on its commands: as a host's worker diff --git a/core/exec.zig b/core/exec.zig index 687faa98..1ec47eb3 100644 --- a/core/exec.zig +++ b/core/exec.zig @@ -288,7 +288,7 @@ pub fn withArg(p: *Pardes, txt: []const u8, arg: ?[]const u8) []const u8 { // A switch (Verbose, Wrap) clicked with some other text // selected flips, as it does bare: only `on` or `off` is an argument // for it. What a ctl write gives it is checked strictly instead. - if (config.Runtime.find(commandText(t))) |setting| switch (setting.action) { + if (config.Settings.find(commandText(t))) |setting| switch (setting.action) { .toggle => if (!std.mem.eql(u8, a, "on") and !std.mem.eql(u8, a, "off")) return txt, else => {}, }; @@ -688,7 +688,7 @@ pub fn executeFrom(p: *Pardes, id: usize, txt: []const u8, from_body: bool) ?usi // A builtin or setting this build lacks (Fonts on a terminal) is said, // never run as a shell command. const word = cmd[0 .. std.mem.indexOfAny(u8, cmd, " \t") orelse cmd.len]; - if (builtins.absentWhy(word) orelse if (config.Runtime.find(word) != null) @as([]const u8, "GUI-only") else null) |why| { + if (builtins.absentWhy(word) orelse if (config.Settings.find(word) != null) @as([]const u8, "GUI-only") else null) |why| { var said: pardes.Kind.Buf(96) = .{}; p.reportFailure(id, said.print("{s} is {s}, invalid here", .{ word, why })); return null; @@ -937,7 +937,7 @@ fn applyInitText(p: *Pardes, text: []const u8, settings_only: bool) void { // `#` starts a comment only at a line's start: a value may hold one // (`#ff0000`). if (word.len == 0 or isComment(word)) continue; - const setting = config.Runtime.find(word[0 .. std.mem.indexOfAny(u8, word, " \t") orelse word.len]); + const setting = config.Settings.find(word[0 .. std.mem.indexOfAny(u8, word, " \t") orelse word.len]); // Saved in a pane, its settings run again and its commands do not: // a word that is neither (a typo) is still said, as at startup. if (settings_only and setting == null and std.meta.stringToEnum(Builtin, word[0 .. std.mem.indexOfAny(u8, word, " \t+") orelse word.len]) != null) continue; @@ -996,7 +996,7 @@ pub fn runBuiltinFrom(p: *Pardes, b: Builtin, id: usize, txt: []const u8, arg: ? builtins.registry.dispatch(b, c); } -pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[]const u8) void { +pub fn applySettingBuiltin(p: *Pardes, setting: config.Settings.Setting, arg: ?[]const u8) void { const v = p.view(); const previous_tagline_percent = p.settings.font.tagline_percent; switch (setting.action) { @@ -1015,7 +1015,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] }, .font => { if (comptime !font_picker) return; - const spec = config.Runtime.FontSpec.parse(arg orelse return) orelse return; + const spec = config.Settings.FontSpec.parse(arg orelse return) orelse return; // The session's machine's fonts, a question to its disk: a // client's replay takes the session's answer, never its own. const found = pardes.tape.site(.fonts, p.scratch.allocator(), fontNamed, .{ p.scratch.allocator(), spec.name }); @@ -1039,7 +1039,7 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] var text: pardes.Kind.Buf(340) = .{}; return p.reportFailure(v.active, text.print("Shell: {s}", .{refused})); } - if (!p.settings.apply(p.tape, setting, want, p.sessionHome())) p.reportFailure(v.active, "Shell: takes " ++ comptime config.Runtime.takes(.shell).?); + if (!p.settings.apply(p.tape, setting, want, p.sessionHome())) p.reportFailure(v.active, "Shell: takes " ++ comptime config.Settings.takes(.shell).?); }, // Bare, each says its value, as acme's Tab says the width. inline .tab, .callstack_depth => |_, tag| if (arg == null) { @@ -1047,14 +1047,14 @@ pub fn applySettingBuiltin(p: *Pardes, setting: config.Runtime.Setting, arg: ?[] return p.setMessage(.at(v.active), said.print("{s} {d}", .{ setting.word, @field(p.settings, @tagName(tag)) })); } else if (!p.settings.apply(p.tape, setting, arg, p.sessionHome())) { var said: pardes.Kind.Buf(96) = .{}; - p.reportFailure(v.active, said.print("{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Runtime.takes(tag).? })); + p.reportFailure(v.active, said.print("{s}{s}: takes {s}", .{ setting.word, if (tag == .tab) ": invalid tab width" else "", comptime config.Settings.takes(tag).? })); }, // Said with what it takes: its words, its range. else => if (!p.settings.apply(p.tape, setting, arg, p.sessionHome())) { var buf: [160]u8 = undefined; var text: std.Io.Writer = .fixed(&buf); // A list of values too long for the row is cut. - (if (config.Runtime.takes(setting.action)) |values| text.print("{s}: takes {s}", .{ setting.word, values }) else text.print("{s}: does not take that value", .{setting.word})) catch {}; + (if (config.Settings.takes(setting.action)) |values| text.print("{s}: takes {s}", .{ setting.word, values }) else text.print("{s}: does not take that value", .{setting.word})) catch {}; p.reportFailure(v.active, text.buffered()); }, } diff --git a/core/fs.zig b/core/fs.zig index 0a10825d..0797beb0 100644 --- a/core/fs.zig +++ b/core/fs.zig @@ -11,7 +11,7 @@ const modal = @import("modal.zig"); const look = @import("look.zig"); pub const tree = @import("ninep/tree.zig"); const sources_fs = @import("ninep/sources.zig"); -const th = @import("ninep/testing.zig"); +const th = @import("ninep/harness.zig"); const Pardes = pardes.Pardes; const MAX_PANES = pardes.MAX_PANES; diff --git a/core/keys.zig b/core/keys.zig index 92e78b0e..72e3bb3b 100644 --- a/core/keys.zig +++ b/core/keys.zig @@ -632,7 +632,7 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { p.newScratchBelow(foot); const tail = p.view().active; { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const asked = foot; p.view().active = asked; p.sync(); diff --git a/core/layout.zig b/core/layout.zig index 6ce0845f..9c99dc7d 100644 --- a/core/layout.zig +++ b/core/layout.zig @@ -339,7 +339,7 @@ pub fn movePane(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) void { for (moved[0..count], 0..) |m, j| insert(p, placement.preview_col, j, m); if (count > 1) setColumnWeights(p, placement.preview_col, &heights); if (source_multi) setColumnWeights(p, src.col, &heights); - if (owner != null) p.panes[id].?.attached_to = null; + if (owner != null) p.panes[id].?.docked_to = null; return; }; const af = findPane(p, above) orelse return; @@ -367,7 +367,7 @@ pub fn movePane(p: *Pardes, id: usize, cur_x: u16, cur_y: u16) void { const pane = p.panes[id].?; // Still right under its owner's group: resized there. Anywhere // else it is a pane of its own. - if (af.col != (findPane(p, o) orelse return).col or !descends(p, above, o)) pane.attached_to = null; + if (af.col != (findPane(p, o) orelse return).col or !descends(p, above, o)) pane.docked_to = null; } } @@ -1115,7 +1115,7 @@ pub fn splitBelow(p: *Pardes, src_id: usize, nw: *Pane) void { // ---- Attached panes ---- // // A results pane (+Search, +Callstack, +Diff, +Errors) is ATTACHED to the -// pane it answers for, its owner (Pane.attached_to). The owner and what is +// pane it answers for, its owner (Pane.docked_to). The owner and what is // attached to it, and what is attached to those (a preview under a // +Search), are a GROUP: contiguous in one column, the owner first. A group // is one place to everything else in the layout: an unrelated pane is never @@ -1126,7 +1126,7 @@ pub fn splitBelow(p: *Pardes, src_id: usize, nw: *Pane) void { /// The slot of `id`'s owner, when `id` is attached to a live pane. pub fn ownerOf(p: *const Pardes, id: usize) ?usize { - const serial = (p.panes[id] orelse return null).attached_to orelse return null; + const serial = (p.panes[id] orelse return null).docked_to orelse return null; for (p.panes, 0..) |slot, i| if (slot) |pane| if (pane.serial == serial and i != id) return i; return null; } @@ -1168,10 +1168,10 @@ pub fn groupEnd(p: *const Pardes, c: usize, idx: usize) usize { pub fn keepGroups(p: *Pardes) void { for (0..p.view().ncol) |c| for (p.view().cols[c].panes[0..p.view().cols[c].n], 0..) |id, k| { const pane = p.panes[id] orelse continue; - if (pane.attached_to == null) continue; + if (pane.docked_to == null) continue; const kept = if (ownerOf(p, id)) |owner| k > 0 and descends(p, p.view().cols[c].panes[k - 1], owner) else false; if (kept) continue; - pane.attached_to = null; + pane.docked_to = null; }; } @@ -1206,7 +1206,7 @@ pub fn attachFrom(p: *Pardes, owner: usize, id: usize, rows: u16, giver: usize) insert(p, f.col, groupEnd(p, f.col, f.idx), id); g.vweight = @floatFromInt(oh - give); nw.vweight = @floatFromInt(give); - nw.attached_to = o.serial; + nw.docked_to = o.serial; compute(p); return true; } @@ -1991,9 +1991,9 @@ test "an attachment survives Dump and Restore, and one left away from its owner const restored = try dump.initFromDump(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 40 }, p.dump_out.?); defer restored.deinit(); try std.testing.expectEqual(@as(?usize, 0), ownerOf(restored, s)); - // Unattach: a pane of its own where it stands. - pardes.exec.runBuiltin(p, .Unattach, s, "", null); - try std.testing.expect(p.panes[s].?.attached_to == null); + // Undock: a pane of its own where it stands. + pardes.exec.runBuiltin(p, .Undock, s, "", null); + try std.testing.expect(p.panes[s].?.docked_to == null); // Put above its owner by a route that does not carry groups: detached. const t = try testAttachment(p); try std.testing.expect(attachFrom(p, 0, t, 8, 0)); @@ -2001,7 +2001,7 @@ test "an attachment survives Dump and Restore, and one left away from its owner removePane(p, t); insert(p, 0, 0, t); compute(p); - try std.testing.expect(p.panes[t].?.attached_to == null); + try std.testing.expect(p.panes[t].?.docked_to == null); } test "a new column takes width only from the column that created it" { diff --git a/core/look.zig b/core/look.zig index f7084079..1023a532 100644 --- a/core/look.zig +++ b/core/look.zig @@ -2302,7 +2302,7 @@ test "every entry point to Look takes one expansion: a diff line and a file:12:5 var fx: DiffFixture = undefined; try fx.init(true, &.{.{ "src/x.zig", numbered }}, diff_text); defer fx.tmp.cleanup(); - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); // `column` -1: wherever a click puts it, every other way the same. const Case = struct { text: []const u8, name: []const u8, row: u16, col: u16, sweep: [2]u16, line: i32, column: i32 }; const cases = [_]Case{ @@ -2391,7 +2391,7 @@ test "a tag word looked at by a click and by Enter is one record to an event rea var fx: DiffFixture = undefined; try fx.init(true, &.{.{ "src/x.zig", "line one\n" }}, diff_text); defer fx.tmp.cleanup(); - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 30 }); defer p.deinit(); const pane = try fx.open(p, diff_text); diff --git a/core/mouse.zig b/core/mouse.zig index 8d0aebc8..cdf4892e 100644 --- a/core/mouse.zig +++ b/core/mouse.zig @@ -1500,7 +1500,7 @@ test "mouse thumb buttons navigate once and clear selection gestures" { } test "a chorded exec an event reader holds is told with its argument, and written back runs with it" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const p = try th.withFile(std.testing.allocator, "Msg said\narg-text\n"); defer p.deinit(); const serial = p.panes[0].?.serial; diff --git a/core/ninep/addr.zig b/core/ninep/addr.zig index 72a2d815..fd343363 100644 --- a/core/ninep/addr.zig +++ b/core/ninep/addr.zig @@ -319,7 +319,7 @@ pub const Addr = struct { }; const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const tree = @import("tree.zig"); const Node = tree.Node; const E = tree.E; diff --git a/core/ninep/cols.zig b/core/ninep/cols.zig index 561a5ffa..88d8ef88 100644 --- a/core/ninep/cols.zig +++ b/core/ninep/cols.zig @@ -241,7 +241,7 @@ pub fn remove(p: *Pardes, req: Req, serial: u32, file: tree.ColFile) Reply { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const Node = tree.Node; test "New written to a column's exec makes its scratch in the session's directory, as tagexec's does" { diff --git a/core/ninep/ctl.zig b/core/ninep/ctl.zig index 302b916a..7b4e2754 100644 --- a/core/ninep/ctl.zig +++ b/core/ninep/ctl.zig @@ -298,7 +298,7 @@ pub fn captured(p: *Pardes, req: Req, id: usize, exec: bool, text: []const u8, i // ...and one that takes none, written with one (`Config extra`): // refused as a ctl's is, not run as a shell command of that name. if (std.mem.indexOfAny(u8, cmd, " \t")) |sp| if (std.meta.stringToEnum(Builtin, cmd[0..sp])) |b| { - if (!builtins.registry.takesArg(b) and config.Runtime.find(cmd[0..sp]) == null) { + if (!builtins.registry.takesArg(b) and config.Settings.find(cmd[0..sp]) == null) { p.fs.results_len = 0; return refuse(p, req, "wrong #args in control message", cmd); } @@ -535,7 +535,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? // A setting this build's frontend cannot show (Lift, GripWidth on a // terminal, the window's own words in a terminal's view) is known, // and says so rather than sound misspelt. - if (builtins.absentWhy(word) orelse if (config.Runtime.find(word) != null or std.meta.stringToEnum(Builtin, word) != null) @as([]const u8, "GUI-only") else null) |absent| { + if (builtins.absentWhy(word) orelse if (config.Settings.find(word) != null or std.meta.stringToEnum(Builtin, word) != null) @as([]const u8, "GUI-only") else null) |absent| { var why: pardes.Kind.Buf(64) = .{}; // EINVAL, a request this build cannot take, in words 9ns reads // as that: `invalid`. @@ -553,7 +553,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? ": write it to pane/<n>/ctl"); if (arg.len > 0 and !builtins.registry.takesArg(b)) return refuse(p, req, "wrong #args in control message", line); if (arg.len == 0 and builtins.registry.requiresArg(b)) return refuse(p, req, "wrong #args in control message", line); - const setting = config.Runtime.find(word) orelse return null; + const setting = config.Settings.find(word) orelse return null; const takes = switch (setting.action) { .theme => if (pardes.colors.themeIndex(arg) != null) true else { // `refuse` quotes the line after it, all in the 128 bytes an @@ -565,7 +565,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? var why: pardes.Kind.Buf(256) = .{}; return refuse(p, req, why.print(head ++ "{s}" ++ tail, .{pardes.colors.themesNear(near[0..@min(room, near.len)], arg)}), arg); }, - .font => config.Runtime.FontSpec.parse(arg) != null, + .font => config.Settings.FontSpec.parse(arg) != null, // Bare, it says the width, as from a pane's exec. .tab => arg.len == 0 or (std.fmt.parseInt(u16, arg, 10) catch 0) -% 1 < 16, .callstack_depth => arg.len == 0 or (std.fmt.parseInt(u8, arg, 10) catch 0) -% 1 < pardes.lsp.callstack_max_depth, @@ -578,7 +578,7 @@ fn checkBuiltin(p: *Pardes, req: Req, line: []const u8, scope: builtins.Scope) ? var why: pardes.Kind.Buf(160) = .{}; // The offending word is the value: quoted, so two bad values read, // and log, as two. - return refuseQuoting(p, req, if (config.Runtime.takes(setting.action)) |values| + return refuseQuoting(p, req, if (config.Settings.takes(setting.action)) |values| why.print("bad value in control message; takes {s}", .{values}) else "bad value in control message", arg, ""); @@ -628,13 +628,13 @@ fn writeSettings(p: *Pardes, w: *std.Io.Writer) !void { /// The setting words of `s`, one a line, those a frontend of `caps` takes /// (the root ctl's: the live view's), and the session's LocationsConfig. -fn writeSettingsFor(p: *Pardes, s: *const config.Runtime, w: *std.Io.Writer, caps: config.Runtime.Capabilities) !void { +fn writeSettingsFor(p: *Pardes, s: *const config.Settings, w: *std.Io.Writer, caps: config.Settings.Capabilities) !void { // DumpConfig's words: a `# Word unsupported` comment for what `caps` lacks. var dump_dir: [1024]u8 = undefined; var located_buf: [256]u8 = undefined; var located: std.Io.Writer = .fixed(&located_buf); try p.locations_config.write(&located); - try config.Runtime.writeSettings(w, .{ + try config.Settings.writeSettings(w, .{ .locations = located.buffered(), .theme_name = p.theme().name, .theme_file = pardes.colors.loadedThemeFile(p), @@ -879,7 +879,7 @@ fn writeCommands(p: *const Pardes, w: *std.Io.Writer) !void { }); // A setting that chooses among words: the words, comma-joined. Bare, // it steps to the next of them (a two-valued one flips). - if (config.Runtime.find(@tagName(b))) |setting| if (config.Runtime.choices(setting.action)) |values| { + if (config.Settings.find(@tagName(b))) |setting| if (config.Settings.choices(setting.action)) |values| { try w.writeByte(' '); var parts = std.mem.splitSequence(u8, values, ", "); var first = true; @@ -887,7 +887,7 @@ fn writeCommands(p: *const Pardes, w: *std.Io.Writer) !void { }; // Then ` -- ` and what it does: a setting's doc, else its source's. var summary_buf: [2048]u8 = undefined; - const summary = if (config.Runtime.find(@tagName(b))) |setting| setting.doc else summaryOf(@tagName(b), &summary_buf); + const summary = if (config.Settings.find(@tagName(b))) |setting| setting.doc else summaryOf(@tagName(b), &summary_buf); if (summary.len > 0) { // The sentence whole unless it is long, then cut between words. const kept = @import("../Messages.zig").clip(summary, 240); @@ -1323,7 +1323,7 @@ pub fn get(p: *Pardes, pane: *Pane) GetError!void { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const call = th.call; const rd = th.rd; const wr = th.wr; @@ -1374,7 +1374,7 @@ test "commands lists every builtin with its argument and the ctl that takes it" const b = std.meta.stringToEnum(Builtin, words.next().?).?; if (builtins.registry.takesArg(b)) try testing.expectEqualStrings("arg", words.next().?); try testing.expectEqualStrings(if (b == .Edit) "both" else if (builtins.registry.scope(b) == .session) "root" else "pane", words.next().?); - if (config.Runtime.find(@tagName(b))) |s| if (config.Runtime.choices(s.action) != null) try testing.expect(words.next() != null); + if (config.Settings.find(@tagName(b))) |s| if (config.Settings.choices(s.action) != null) try testing.expect(words.next() != null); // Then, where the source has one, ` -- ` and what it does. if (words.next()) |dashes| try testing.expectEqualStrings("--", dashes); } @@ -1766,7 +1766,7 @@ test "after a ThemeFile the root ctl and DumpConfig say ThemeFile and its path, try testing.expect(std.mem.indexOf(u8, settings, "Theme mine") == null); var storage: [16384]u8 = undefined; var out: std.Io.Writer = .fixed(&storage); - try config.Runtime.writeReport(&out, .{ + try config.Settings.writeReport(&out, .{ .startup_config_path = null, .platform = @tagName(pardes.platform), .theme_name = p.theme().name, @@ -2490,7 +2490,7 @@ test "every word's /commands description is its own doc comment's first sentence continue; }; const word = line[0..std.mem.indexOfScalar(u8, line, ' ').?]; - if (config.Runtime.find(word)) |setting| { + if (config.Settings.find(word)) |setting| { try testing.expect(std.mem.endsWith(u8, line, setting.doc)); continue; } @@ -2890,7 +2890,7 @@ test "the init file reads past a BOM, and every line it fails is a notice and an } test "a setting the other frontend has is passed over in the init file, not failed" { - const other = for (config.Runtime.settings) |s| { + const other = for (config.Settings.settings) |s| { if (!s.enabled(pardes.builtins.capabilities)) break s.word; } else return; // this frontend has them all var text: [64]u8 = undefined; diff --git a/core/ninep/events.zig b/core/ninep/events.zig index 93a1187a..1951a434 100644 --- a/core/ninep/events.zig +++ b/core/ninep/events.zig @@ -828,7 +828,7 @@ pub fn writeEvent(p: *Pardes, asked: Req, id: usize) Reply { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const call = th.call; const rd = th.rd; const wr = th.wr; diff --git a/core/ninep/testing.zig b/core/ninep/harness.zig index cf75d80d..cf75d80d 100644 --- a/core/ninep/testing.zig +++ b/core/ninep/harness.zig diff --git a/core/ninep/pane.zig b/core/ninep/pane.zig index 8be26602..1d514a3c 100644 --- a/core/ninep/pane.zig +++ b/core/ninep/pane.zig @@ -1031,7 +1031,7 @@ pub fn truncate(p: *Pardes, pane: *Pane, file: PaneFile) tree.Status { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const call = th.call; const rd = th.rd; const wr = th.wr; diff --git a/core/ninep/pty.zig b/core/ninep/pty.zig index 6f3a8af0..26bb7661 100644 --- a/core/ninep/pty.zig +++ b/core/ninep/pty.zig @@ -469,7 +469,7 @@ pub fn writeData(p: *Pardes, req: Req, id: usize) Reply { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const events = @import("events.zig"); const call = th.call; const rd = th.rd; diff --git a/core/ninep/screen.zig b/core/ninep/screen.zig index 1e2791b1..1e31bac0 100644 --- a/core/ninep/screen.zig +++ b/core/ninep/screen.zig @@ -83,7 +83,7 @@ pub fn listenersText(p: *Pardes) std.Io.Writer.Error![]const u8 { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const fs = @import("../fs.zig"); const call = th.call; const rd = th.rd; diff --git a/core/ninep/sources.zig b/core/ninep/sources.zig index 1d804e31..540506d4 100644 --- a/core/ninep/sources.zig +++ b/core/ninep/sources.zig @@ -109,7 +109,7 @@ pub fn handle(p: *Pardes, req: Req) Reply { } const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const limits = @import("../memory.zig").limits; test "embedded sources appear under the root only when the build carries them" { diff --git a/core/ninep/tree.zig b/core/ninep/tree.zig index d5a6b2fe..46a4e3d2 100644 --- a/core/ninep/tree.zig +++ b/core/ninep/tree.zig @@ -1504,7 +1504,7 @@ fn writeSend(p: *Pardes, req: Req) Reply { // ---- tests ---- const testing = std.testing; -const th = @import("testing.zig"); +const th = @import("harness.zig"); const config = @import("../config.zig"); const call = th.call; const rd = th.rd; diff --git a/core/panes.zig b/core/panes.zig index b928917a..72ca3eea 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -144,7 +144,7 @@ pub const Pane = struct { /// closes with it (layout.zig, "Attached panes"). An owner that is /// gone, or a pane no longer right under its owner's group, leaves it /// an ordinary pane (layout.keepGroups). - attached_to: ?u32 = null, + docked_to: ?u32 = null, /// This pane is a query pane: its line 1 the query, its rows made live /// from a source (Query.zig, gpa-owned). query: ?*Query = null, @@ -1437,7 +1437,7 @@ pub fn removePane(p: *Pardes, id: usize, to: ?usize) error{OutOfMemory}!void { const pane = p.panes[id] orelse return; // What is attached to it closes with it, first, each giving its rows // back to it: then its rows, theirs among them, go where a pane's go. - for (0..p.panes.len) |k| if (p.panes[k]) |other| if (k != id and other.attached_to == pane.serial) { + for (0..p.panes.len) |k| if (p.panes[k]) |other| if (k != id and other.docked_to == pane.serial) { if (layout.ownerOf(p, k) != id) continue; try p.removePane(k, id); layout.compute(p); diff --git a/core/rollback.zig b/core/rollback.zig index 3d5ab921..c7d0a4e8 100644 --- a/core/rollback.zig +++ b/core/rollback.zig @@ -88,6 +88,9 @@ pub const Epoch = struct { } pub fn deinit(e: *Epoch) void { + // Gone with a copy still held (a test that failed between take and + // restore): the process-wide hold must not point into it. + if (pardes.syntax.held_trees == &e.trees) pardes.syntax.held_trees = null; var it = e.live.iterator(); while (it.next()) |kv| e.child.rawFree(@as([*]u8, @ptrFromInt(kv.key_ptr.*))[0..kv.value_ptr.len], kv.value_ptr.alignment, @returnAddress()); e.live.deinit(e.meta); @@ -579,6 +582,9 @@ test "a copy put back is the core as it was; one let go keeps what was done" { const gpa = e.allocator(); const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml", .image_allocator = gpa, .tree_sitter_allocator = gpa, .frame_allocator = gpa }); p.pump(.{}) catch {}; + const f = for (p.panes) |slot| { + if (slot) |pane| if (pane.file) |*file| break file; + } else return error.NoFile; const before = walk.digest(Pardes, p); var c: Copy = .{}; defer c.deinit(); @@ -588,6 +594,7 @@ test "a copy put back is the core as it was; one let go keeps what was done" { p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.pump(.{}) catch {}; const edited = walk.digest(Pardes, p); + const stamped = f.mtime; try std.testing.expect(edited != before); try std.testing.expect(c.restore()); try std.testing.expectEqual(before, walk.digest(Pardes, p)); @@ -596,6 +603,9 @@ test "a copy put back is the core as it was; one let go keeps what was done" { for (typed) |k| p.update(.{ .key = .{ .cp = k, .text = &.{k} } }); p.update(.{ .key = .{ .cp = pardes.Key.escape } }); p.pump(.{}) catch {}; + // An edit stamps the text with the wall clock's second (File.edit's + // mtime): the same typing in the next second is the same edit. + f.mtime = stamped; try std.testing.expectEqual(edited, walk.digest(Pardes, p)); c.release(); try std.testing.expectEqual(edited, walk.digest(Pardes, p)); diff --git a/core/sam_edit.zig b/core/sam_edit.zig index 0f4a70ba..700c2c01 100644 --- a/core/sam_edit.zig +++ b/core/sam_edit.zig @@ -1158,7 +1158,7 @@ fn expectEdit(text: []const u8, command: []const u8, want: []const u8) !void { } test "an x over 100k lines is 100k searches, each with its own step budget" { - const th = @import("ninep/testing.zig"); + const th = @import("ninep/harness.zig"); const line = &@as([80]u8, @splat('x')) ++ "\n"; const text = try std.testing.allocator.alloc(u8, line.len * 100_000); defer std.testing.allocator.free(text); diff --git a/core/surface.zig b/core/surface.zig index fdcb52c8..6e05f25f 100644 --- a/core/surface.zig +++ b/core/surface.zig @@ -221,7 +221,7 @@ pub const Facts = struct { forward: bool = false, cursor_blink: bool = true, jump_trail: bool = false, - pet: config.Runtime.Pet = .off, + pet: config.Settings.Pet = .off, inactive_dim: u8 = 0, tagline_percent: u8 = 100, diff --git a/core/tagline.zig b/core/tagline.zig index 456a6b6e..fa25b2c1 100644 --- a/core/tagline.zig +++ b/core/tagline.zig @@ -35,9 +35,9 @@ pub const terminal_pane_tail = " " ++ config.terminal_pane_builtins_str; pub const command_pane_tail = " " ++ config.command_pane_builtins_str; pub const dir_pane_tail = " " ++ config.dir_pane_builtins_str; /// A query pane's while its rows are made (Query.zig), and once Enter froze -/// them into text a Save keeps; Unattach leaves it where it stands. +/// them into text a Save keeps; Undock leaves it where it stands. pub const query_live_tail = " Del"; -pub const query_frozen_tail = " Save Unattach Del"; +pub const query_frozen_tail = " Save Undock Del"; /// ...and while its Grep waits at 2000 lines for More (Stream.zig). pub const query_capped_tail = " More Del"; /// A file with changes it has not saved. diff --git a/core/tape.zig b/core/tape.zig index cc4b21b8..61bdcc08 100644 --- a/core/tape.zig +++ b/core/tape.zig @@ -1773,7 +1773,7 @@ test "every place that sets the global tape aside sets the core's field aside: a test "a client's frame drawn between its steps records nothing into its idle tape" { const gpa = std.testing.allocator; - const p = try @import("ninep/testing.zig").withFile(gpa, "x\n"); + const p = try @import("ninep/harness.zig").withFile(gpa, "x\n"); defer p.deinit(); const bytes = try pardes.dump.dumpBytes(p); defer p.gpa.free(bytes); diff --git a/core/views.zig b/core/views.zig index 9985288d..89dcb454 100644 --- a/core/views.zig +++ b/core/views.zig @@ -33,7 +33,7 @@ pub const max = 4; /// A pane's fields that are each view's own: where it is in the view's /// layout, which of its texts has the keyboard, how far it is scrolled, and /// what the view's step measured of it (its tag's rows, its bands). -const pane_fields = [_][:0]const u8{ "focus", "vweight", "collapsed", "attached_to", "hscroll", "tag_scroll", "tag_top", "tag_rows", "view", "notices", "pan", "follow_scroll" }; +const pane_fields = [_][:0]const u8{ "focus", "vweight", "collapsed", "docked_to", "hscroll", "tag_scroll", "tag_top", "tag_rows", "view", "notices", "pan", "follow_scroll" }; /// The body's: its cursor, selections and mode. Its undo stays the pane's. const body_fields = [_][:0]const u8{ "mode", "cur_pinned", "cur_row", "cur_col", "vsel", "sels", "nsel", "select", "sticky_col", "restore_cursor", "last_edit", "reg_wait", "normal", "find_op", "find_ch" }; @@ -43,7 +43,7 @@ pub const PaneView = struct { focus: Pane.Focus = .body, vweight: f32 = 1, collapsed: bool = false, - attached_to: ?u32 = null, + docked_to: ?u32 = null, hscroll: i32 = 0, tag_scroll: u16 = 0, tag_top: u16 = 0, diff --git a/dev/gui/gui.zig b/dev/gui/gui.zig index 1dfc6336..9695bf83 100644 --- a/dev/gui/gui.zig +++ b/dev/gui/gui.zig @@ -595,7 +595,7 @@ fn acknowledgeGuiFont(g: *const Gui, core: *pardes.Pardes) void { /// A replica client's font is the window's raster state: it follows the /// session's request by the face's name on this machine (fonts.fromSession), /// never acknowledging it or otherwise changing the replicated core. -fn syncReplicaFont(g: *Gui, f: *const @FieldType(pardes.config.Runtime, "font"), gpa: std.mem.Allocator) bool { +fn syncReplicaFont(g: *Gui, f: *const @FieldType(pardes.config.Settings, "font"), gpa: std.mem.Allocator) bool { const path = f.requested_path.get(); const name = f.requested_name.get(); if (path.len == 0 and name.len == 0) return false; @@ -5857,7 +5857,7 @@ fn cursorDecor(g: *Gui, gpa: std.mem.Allocator, surface: *const pardes.Surface, /// The triangle overlay: the cursor's glide, over everything. fn buildOverlay( g: *Gui, - which: pardes.config.Runtime.Pet, + which: pardes.config.Settings.Pet, trail_on: bool, surface: *const pardes.Surface, now_ns: u64, @@ -5906,7 +5906,7 @@ fn appendJumpTrail(g: *Gui, on: bool, surface: *const pardes.Surface, now_ns: u6 /// The workspace tag's pet (the Pet setting, gui/pet.zig): in the blank /// end of the grid's first row, past the tag's text, in the tag's colours, /// on the window's own clock. Nothing of it reaches the core. -fn appendWorkspacePet(g: *Gui, which: pardes.config.Runtime.Pet, surface: *const pardes.Surface, builder: *OverlayBuilder) void { +fn appendWorkspacePet(g: *Gui, which: pardes.config.Settings.Pet, surface: *const pardes.Surface, builder: *OverlayBuilder) void { const kind: pet.Kind = @fromBackingInt(@backingInt(which)); if (kind == .off or surface.rows == 0 or surface.cols == 0) { g.pet_state = .{}; diff --git a/dev/jump_trail.zig b/dev/jump_trail.zig index 25eba636..05664ec1 100644 --- a/dev/jump_trail.zig +++ b/dev/jump_trail.zig @@ -4,7 +4,7 @@ //! the cursor of the Surface it shows, frame after frame, and times the fade //! on its own clock; the tty tints those cells' ground toward the text, the //! window draws over them. Nothing of it reaches the core, which keeps the -//! setting alone (config.Runtime.jump_trail). +//! setting alone (config.Settings.jump_trail). const std = @import("std"); pub const life_ns: u64 = 120 * std.time.ns_per_ms; diff --git a/dev/lsp/lsp_client.zig b/dev/lsp/lsp_client.zig index 83aea44f..4ad8dace 100644 --- a/dev/lsp/lsp_client.zig +++ b/dev/lsp/lsp_client.zig @@ -783,8 +783,13 @@ fn answer(io: std.Io, arena: std.mem.Allocator, si: usize, req: lsp.Req, out: *s if (!try timedWait(c, io, startup_deadline)) break; } if (starting or c.loading or c.progress > 0) { - tr.note("{s} is still loading: waiting for it, then asking again", .{specs[si].name}); - post(si, .always, "{s} is still loading the workspace; the answer comes when it is done\u{2026}", .{specs[si].name}); + // Said only when the server says it: a startup window that ran + // out with no word of loading is asked again quietly, and the + // message row keeps what it had (an empty answer is an answer). + if (c.loading or c.progress > 0) { + tr.note("{s} is still loading: waiting for it, then asking again", .{specs[si].name}); + post(si, .always, "{s} is still loading the workspace; the answer comes when it is done\u{2026}", .{specs[si].name}); + } while ((c.loading or c.progress > 0) and c.gen == g and c.alive()) _ = try timedWait(c, io, nowMs() + 500); out.end = before; try attempt(c, io, si, arena, req, out, tr, g); diff --git a/dev/macos/Sources/AppDelegate.swift b/dev/macos/Sources/AppDelegate.swift index 767d3766..4168999f 100644 --- a/dev/macos/Sources/AppDelegate.swift +++ b/dev/macos/Sources/AppDelegate.swift @@ -132,7 +132,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, PardesViewDelegate { // to change the day macos_min_version reaches 14. NSApp.activate(ignoringOtherApps: true) - var runtime = pardes_runtime_s( + var runtime = pardes_callbacks_s( userdata: Unmanaged.passUnretained(self).toOpaque(), wakeup: { ud in // A pty reader thread. Every other function in pardes.h is diff --git a/docs/ghostty-macos-notes.md b/docs/ghostty-macos-notes.md index 830d4b1f..3dc03265 100644 --- a/docs/ghostty-macos-notes.md +++ b/docs/ghostty-macos-notes.md @@ -56,10 +56,10 @@ comptime { The payoff is that adding a feature adds an enum case, not a struct field: hosts that do not implement it return `false` and the ABI never changed. Worth copying the day a fixed callback list starts growing. pardes has three callbacks today -— `wakeup`, `set_clipboard`, `read_clipboard` (`Runtime` in `runtime/macos.zig:153`) +— `wakeup`, `set_clipboard`, `read_clipboard` (`Callbacks` in `runtime/macos.zig:153`) — and does not need it yet. -Two userdata scopes, worth noting: the runtime struct's `userdata` is +Two userdata scopes, worth noting: the callbacks struct's `userdata` is app-scoped, and each surface carries its own. Swift round-trips both with `Unmanaged.passUnretained(self).toOpaque()` — libghostty never retains, so lifetime stays entirely on the Swift side. diff --git a/docs/macos.md b/docs/macos.md index 44b77d67..98cd5312 100644 --- a/docs/macos.md +++ b/docs/macos.md @@ -85,7 +85,7 @@ copies had in common is the argument for the shared file existing: none set the pty master, so a program in one pane could read and write another pane's terminal and closing a master did not reliably hang its shell up. -That is why the runtime struct is three callbacks rather than a second vtable — +That is why the callbacks struct is three callbacks rather than a second vtable — and why two of the three are the clipboard: the pasteboard is AppKit's, in both directions, and is the one piece of IO the Zig side cannot reach for itself. @@ -128,7 +128,7 @@ is made of and what opens a path from argv or the Dock (`Look <path>`). it. `pardes_resize` also carries one cell in *physical* pixels, which only the native PDF placement path reads — pass the backing-store size, not points. -**Runtime callbacks.** `pardes_runtime_s` is a `userdata` and three functions, +**Callbacks.** `pardes_callbacks_s` is a `userdata` and three functions, copied by value during init so the struct need not outlive the call. `wakeup` means "your state moved, please pump me". `set_clipboard` hands over text to put on the pasteboard, borrowed for the duration of the call; it fires inside a tick diff --git a/docs/next-daemon.md b/docs/next-daemon.md index d93cbbea..37ba0241 100644 --- a/docs/next-daemon.md +++ b/docs/next-daemon.md @@ -9,8 +9,9 @@ Designed 2026-10-29 in discussion (the user, the coordinator, a survey agent), and built since, phase by phase (phases 1 to 6, then the -architecture steps): each phase's notes below say what was built, and where -it went otherwise than the design that follows. Where the build differs, the +architecture steps, then the reorganisation of 2026-11-17 to 19): each +phase's notes below say what was built, and where it went otherwise than +the design that follows; the reorganisation's notes are the last but two. Where the build differs, the design's line is kept and marked *Built otherwise*. What runs today, in the words ruled on 2026-11-17 (session, client, far, frontend, detached, attach), is the manual's "How pardes runs" (`docs/typ/running.typ`); where @@ -338,7 +339,7 @@ the ponytail lens: one on a plain terminal differ. The 223 comptime platform branches stay comptime: a session is one build, which the semantics hash says. - Each pane's, each view's own (`PaneView`): `vweight`, `collapsed` and - `attached_to` (a layout's); `focus`; the body's mode, cursor, + `docked_to` (a layout's); `focus`; the body's mode, cursor, selections, sticky column, pending normal command and find; a document's scroll, `hscroll` and size; and what the step measured for that view (`tag_rows`, `tag_top`, `tag_scroll`, `view`, `notices`), so a view drawn @@ -3358,7 +3359,10 @@ either kind. Decisions at the forks, with the ponytail lens: - **The wheel in a client moves a row a turn.** The window's glide and a touchpad's fraction run on the core's clock, which in a client is the session's and moves only with its units. ponytail: whole rows, no glide; - the local window's is unchanged. + the local window's is unchanged. *Built since:* the notch glides in a + client as in the session's own window (measured 2026-11-17, 5 frames, 0 + to -22 px): whole rows go to the session, and the picture moves between + them on the client's own clock (`dev/gui/gui.zig` `glideFrame`). - **A client says its frontend first** (`Event.frontend`: windowed, native images and patches; wire 16, client tag 0x20): the view the session opens for a joiner copies the live view's, and a window's view of a terminal's @@ -3610,7 +3614,7 @@ Not done, and why: touchpad's fractions are the client window's own picture, and only its whole rows go to the session (`gui.zig`, the test "detached trackpad scrolling keeps fractions local and queues whole rows for replication"); - a wheel's notch is still whole rows with no glide. + a wheel's notch glides too (above). - **The notice a client gets is in its title and its log, not its frame** (the session's words: joined again, let go, refused). The tty's draws them on its notice band, which the window's frame has no slot for @@ -4615,6 +4619,103 @@ After it, the query pane's two: min and six clients (late windows and a late terminal among them): no rejoin, no differing check, no panic. All pass. +## The reorganisation notes (2026-11-17 to 2026-11-19) + +The reorganisation (`.scratch/sketch/PARDES.md`, its rulings P12 to P30) +kept the design above: speculation and rollback, the session the only +orderer. The user's rulings it built on: a far client keeps instant local +echo and the replicated core stays (P12, P13); on a far client typing, +motions, edits and layout are instant and what has a side effect on the +system may take the round trip (P14); a client's yank fills the client's +clipboard, and a layout change beside a shell is instant (P16). And the +rule every later choice is measured by (P30): "keep the wire protocol +simple and raw, and the local state process it" (`docs/typ/building.typ`, +"The principle"). What was built, as it stands: + +- **The tree.** `src/` became four directories, each a module that names + the others: `core/` (`core/root.zig`, the core's struct + `core/Core.zig`), `dev/` (the frontends `dev/tui`, `dev/gui`, `dev/macos`, + and `dev/host_io.zig` cut into `Host`, `Shell`, `Inbox`, `KindJob`, + `Lsp`), `runtime/` (main, the daemon, the upgrade, 9P's transport, the + loops) and `abi/` (the wire, `plain`, `term`, the headers). A test + program runs its root module's tests, so a suite runs one a module. +- **The frontends draw from the frame.** A frontend reads the `Surface` + and one record beside it, `Facts` (`core/surface.zig`, filled by + `draw.place`), to draw and to turn input into events, never the core; + so a client no longer makes its view live to read it (`OwnView`, + `Replica.within` deleted). Its frame statistics are its runner's + (`FrameStats`), and `present` says whether it showed the frame + (`present_skipped` gone). Left reading the core: the window's hit + test, its close, a session window's font. +- **One client loop** (`runtime/client.zig`, `Loop(Frontend)`), which the + terminal's client (`Tty`) and the window's (`Client`) run: the joins and + the reader thread, and a pass of the frontend's calls (`own`, `again`, + `deadline`, `wait`, `present`, `copy`, `paste`, `open`, ...), written + once where `runClient` and `clientSession` each had their own. A client's + input is sent before it is applied (`Replica.pend`), and its yank, paste + and link are done on the client's machine. +- **One session loop** (`runtime/session.zig`, `Loop(Frontend)`), which + the terminal's and the window's own frontend (`Own`) run: the + allocators, the workers, the core, the prompt files, the 9P listener, + `Peers`, the pump and the unit, an Upgrade or a Restore, and one order + for the parts' end. The devices are still each frontend's. +- **The soak runs both** (`test/replicas.zig`): each client is + `client.Loop`, the session `session.Loop` over a frontend whose host is + the soak's delayed network (`Peers.threads` off: the soak does the + reader's and the writer's work in memory). It judges every stop against + `may_wait`, runs a frame corpus through a client (22 scenes, its frame + and `Facts` against a session's own), and ends each run with the + session's allocators' leak check. `replica.Authority` remains the + session's stand-in in the core's unit tests and the soak's side cases. +- **What a far client does at once.** A Host entry that returns nothing no + longer stops a speculation, but for those on `keeps_stopping` + (`core/tape.zig`); closing a pane learns from its open whether Recent + keeps the file (`File.State.on_disk`), with no stat; `n`/`N` in a kind's + pane step the rows' own places, asking the disk nothing; a pane switch + beside a shell that asked for focus events tells the program a round + trip later. What may wait is one list, `may_wait` (`core/replica.zig`), + each row with why, pinned by a test that walks every word, key and + gesture on four kinds of pane. +- **The session's facts** (its home, default shell and directory) are the + core's state, read once through the tape; `DumpDir`'s check and + `Font`/`Fonts` read the session's machine through it too. A count of + what `core/` asks of the machine is a test (`core/root.zig`, + `machine_lines`). +- **Nothing of a core is a process global**: `config.tab_now`, + `Addon.distrusted` and `Kind.draw_tokens` went (the tab is the core's + `settings.tab`, handed down; the distrusted list is the client's, + `Options.distrusted`; a draw's token is its slot's); a test walks + `core/` for container-level `var`s (`allowed_vars`). With it, two + faults a rollback met: a terminal's image cache on the epoch's allocator, + a non-plain kind's slot freed by a speculation. +- **Nothing a frame writes is read by a step.** A step read a pane's + notice bands and a big markdown text's tables as the last frame left + them; both are made from the step's state now (the tables read whole at + once, the budgeted reading deleted). `kept_out` (`core/root.zig`) names + every field out of the digest with who writes it, and `core/draw.zig`'s + test steps a core that draws and one that never does, digests equal. +- **An entry written once.** Each of the core's taped entries is a private + body with its public name beside it, + `pub const update = pardes.tape.taped(updateInner);`; the tape's `Input` + variant and the replay come from the body's parameters. Six stay by + hand, each with why. +- **The tape as a handle.** A core holds its tape as it holds its + allocator (`p.tape`, never null; `tape: *Tape` where no core is handed), + and the kinds, the addons, a directory's listing, the file system, the + core's own files and the smaller ones ask it so. The effects, the + budgets, the terminals and the process's `tape.on` are not moved yet. +- **A slot is a type** where it crosses the core's edge: `Pane.Id` and + `View.Id`, each an `enum(u8)`, in the entries, events, effects, the Host + table, the wire's welcome and the device messages. +- **Found by the real loops**: an idle client's quiet check woke its + session every 0.3 s for ever (now a check answered covers the units that + came while it was asked); an addon load under way in another live process + was taken for a crash (the mark is the loader's, `addon-loading.<pid>`); + a kind's draw landing after its pane closed was kept; the command line's + serve thread freed its core under a request; mvzr read past a pattern cut + short (`a{`), patched as it is fetched (`build/patches.zig`, + `docs/mvzr-bounds.md`). + ## Architecture step 6 notes: the rollback and the digest through the journal The clean-room plan's step 6 (`.scratch/clean-room/architecture.md` 9.4) diff --git a/docs/next-drag.md b/docs/next-drag.md index cfaa6c69..47ccdb0b 100644 --- a/docs/next-drag.md +++ b/docs/next-drag.md @@ -56,15 +56,15 @@ window it goes to is found by asking every registry session. at the pointer where SDL can place windows), in its own session, so it outlives the source and leaves no zombie. It waits (up to 15 s) for the child's registry entry to answer `status`; the child reads the dump before - it listens (gui.localSession), so then the file is removed and `handed` - is posted into `host_io.Inbox`. + it listens (runtime/session.zig's `Loop.run`), so then the file is removed and `handed` + is posted into `host_io.Inbox` (dev/Inbox.zig). - `Handover.finish`: taken, each carried pane is closed with `Pardes.removePane` (Del's rows rule: its rows go to its neighbour; a carried column's empty column is dropped); a pane whose revision changed since the dump is kept, unattached ("copied to …; edited on the way, kept here too"). Refused or failed: everything stays, the reason on the message row. One handover flies at a time. -- New option `--geometry=WxH[+X+Y]` (main.zig, `Options.geometry`). +- New option `--geometry=WxH[+X+Y]` (runtime/main.zig, `Options.geometry`). ### 3. A grip let go over another pardes window: it goes there diff --git a/docs/next-run.md b/docs/next-run.md index dc189bc6..06941026 100644 --- a/docs/next-run.md +++ b/docs/next-run.md @@ -11,7 +11,7 @@ stays as built; the vocabulary and the manual's page first, no code moved yet. Nothing in this note is built. What runs today, with a figure for each way of starting pardes, is the manual's "How pardes runs" (`docs/typ/running.typ`); the daemon's history is `docs/next-daemon.md`. -Line numbers are this tree's, 2026-11-17. +Line numbers are this tree's, 2026-11-19. ## The ruling @@ -38,7 +38,7 @@ docs/next-run.svg`). Today `pardes attach` is four mechanisms, picked by the daemon's `find` (`runtime/daemon.zig:901-972`) and by `main.zig`'s `attachTo` -(`runtime/main.zig:1774-1810`): a terminal handed to a detached terminal's +(`runtime/main.zig:1806-1842`): a terminal handed to a detached terminal's session, which draws on it in its own process while the attach process waits as its stub; a window's detached session asked to open its own window again, while the attach process exits; a client here, when the @@ -51,19 +51,19 @@ The reorganisation plan's option b, checked against this tree: | What goes | Where today | Lines, about | |---|---|---| -| A terminal handed to a session: the daemon's `attach` request and answer, the session's `attachTerminal`, the `attach` note and message | `daemon.zig:400-403`, `:431-437`, `:504-533`, `:883-897`; `tui.zig:105-107`, `:1065-1068`, `:1162-1167`, `:1373-1406`, `:1723`; `main.zig:1789-1810` | 110 | -| A window opened again in place | `gui.zig:540-544` (what it reopens with), `:982-1000` (`reopenWindow`), `:2534-2547` (`openTheWindow`), `:2753`, `:3275-3281` | 50 | -| The daemon choosing which session takes a frontend: `find`, its `other` answer, the use of `daemon.Kind` to match | `daemon.zig:901-972`, `:506-509` | 75 | -| The stub's second use: an attach process waiting on a session that is not its child (`stubWait`'s `child = false`, its `r` refusals) | `daemon.zig:561-616` in part (`:593-597`, `:613-615`) | 10 | +| A terminal handed to a session: the daemon's `attach` request and answer, the session's `attachTerminal`, the `attach` note and message | `runtime/daemon.zig:400-403`, `:431-437`, `:504-533`, `:883-897`; `dev/tui/tui.zig:107-109`, `:1037-1040`, `:1135-1140`, `:1354-1387`, `:1711`; `runtime/main.zig:1821-1842` | 110 | +| A window opened again in place | `dev/gui/gui.zig:550-557` (what it reopens with), `:1004-1022` (`reopenWindow`), `:2588-2601` (`openTheWindow`), `:2823`, `:3388-3394` | 50 | +| The daemon choosing which session takes a frontend: `find`, its `other` answer, the use of `daemon.Kind` to match | `runtime/daemon.zig:901-972`, `:506-509` | 75 | +| The stub's second use: an attach process waiting on a session that is not its child (`stubWait`'s `child = false`, its `r` refusals) | `runtime/daemon.zig:561-616` in part (`:593-597`, `:613-615`) | 10 | What does not go, against the plan's list: the upgrade record's terminal and window fields. A session born with a terminal still takes it across an -Upgrade (`tui.zig:1455-1463`, `upgrade.zig:101-117`), and a window's still -says whether it had its window (`gui.zig:2600`). Only the record's other -terminals (`tui.zig:1504-1523`, a build's from before 2026-11-06, when a +Upgrade (`dev/tui/tui.zig:1438-1446`, `runtime/upgrade.zig:101-117`), and a window's still +says whether it had its window (`dev/gui/gui.zig:2656`). Only the record's other +terminals (`dev/tui/tui.zig:1487-1506`, a build's from before 2026-11-06, when a second local terminal stopped being the session's) are already dead weight. -Detach of the session's own frontend stays too (`tui.zig:1346-1371`, -`gui.zig:2476-2485`, `:2521-2532`): it is how a session becomes detached. +Detach of the session's own frontend stays too (`dev/tui/tui.zig:1327-1352`, +`dev/gui/gui.zig:2530-2539`, `:2575-2586`): it is how a session becomes detached. `daemon.Kind` stays in the hello and in `pardes ps` (`tty` or `gui`). The plan counted 87 + about 60 + 67 lines for the first three rows; the @@ -102,15 +102,16 @@ what is true, and whether it was measured. for the wheel, measured (`.scratch/sketch/reports/pardes-measure.md` sections C and E): a notch in a client glides as it does in the session's own window (5 frames, 0 to -22 px, in both). Only whole rows - go to the session (`gui.zig:2147-2161`; its comment and - `docs/next-daemon.md`'s GUI replica notes still say "no glide"); the + go to the session (`dev/gui/gui.zig:2200-2214`; its comment still says + "no glide", which `docs/next-daemon.md`'s GUI replica notes said too + until 2026-11-19); the picture moves between them on the client's own clock (`glideFrame`, - `gui.zig:3544`). A touchpad's fractions are the client window's own + `dev/gui/gui.zig:3673`). A touchpad's fractions are the client window's own picture too (the test "detached trackpad scrolling keeps fractions local - and queues whole rows for replication", `gui.zig:8042`). Fonts: a client follows the session's font request by + and queues whole rows for replication", `dev/gui/gui.zig:8190`). Fonts: a client follows the session's font request by the face's name when that face is installed on its machine - (`gui.zig:580-608`, `syncReplicaFont`); its opacity is its own (not in - the client's per-frame chores, `gui.zig:1311-1323`). The note said "keeps + (`dev/gui/gui.zig:595-623`, `syncReplicaFont`); its opacity is its own (not in + the client's per-frame chores, `dev/gui/gui.zig:1296-1322`). The note said "keeps its own font"; it is corrected there. Measured: a face the client lacks leaves it at its old face and its old size, and it diverged and joined again (2 runs of 2, cause not found). @@ -122,29 +123,32 @@ what is true, and whether it was measured. ## A session registering again -Today a session says hello once, at its start (`main.zig:1535-1563`), or -on its link after an Upgrade (`daemon.zig:392-398`). When the daemon dies -the session's reader sees the link end (`daemon.zig:419-425`) and nothing +Today a session says hello once, at its start (`runtime/main.zig:1567-1595`), or +on its link after an Upgrade (`runtime/daemon.zig:392-398`). When the daemon dies +the session's reader sees the link end (`runtime/daemon.zig:419-425`) and nothing dials again, so the session runs on unlisted: `pardes ps` and attach do not find it, Detach and Adopt refuse, and its frontend closing ends it -(`tui.zig:1711-1721`, `gui.zig:1784`). The next daemon knows only the +(`dev/tui/tui.zig:1699-1709`, `dev/gui/gui.zig:1839`). The next daemon knows only the sessions that start after it. The work: when `gone` is set, the session's loop (which calls -`daemon.watch` each iteration already, `tui.zig:1115`, `gui.zig:1154`) +`daemon.watch` each iteration already, `runtime/session.zig:115`, `:133-135`) dials again, starting a daemon if none answers (`daemon.connect(true)`), says its hello with its state, sends a dup of every pty master it holds -(at most 64 fds a message, `daemon.zig:37`), and its clients' pids. What +(at most 64 fds a message, `runtime/daemon.zig:37`), and its clients' pids. What cannot come back: the shells of sessions killed earlier, which only the dead daemon held. ## `--detach` forking -Today `--detach` is the launch process itself (`main.zig:1502-1537`): it -blocks the shell unless backgrounded by hand, it stays the job of the -terminal it was typed in, and a window's detached session ends on that -terminal's hangup (no handler of its own: `9p_io.zig:704-729`). The work: -fork as `daemon.forkSession` does (`daemon.zig:663-698`), `setsid` in the +Today `--detach` is the launch process itself (`runtime/main.zig:1517-1569`): it +blocks the shell unless backgrounded by hand, and it stays the job of the +terminal it was typed in. `pardes-gui --detach` runs the `pardes` beside +it in its place (`runtime/main.zig:1518-1534`), so a window's binary is a +detached session only where no `pardes` is beside it, and that one ends +on its terminal's hangup (no handler of its own: +`runtime/9p_io.zig:704-729`). The work: +fork as `daemon.forkSession` does (`runtime/daemon.zig:663-698`), `setsid` in the child, its stdin, stdout and stderr on `/dev/null`, and the parent printing the session's name and exiting 0, with no stub (nothing waits on it). For the window's build the fork comes before SDL starts. Then @@ -181,7 +185,7 @@ session takes back. - Re-registration: dial again at once and back off, or only when something needs the daemon (a Detach, an Adopt, the frontend closing)? - `--detach` with no daemon starts a session nothing can attach to - (`main.zig:1535-1537` ignores the failed registration). Refuse, or keep + (`runtime/main.zig:1567-1569` ignores the failed registration). Refuse, or keep it as a 9P-only session? - `pardes ps` says "has a frontend" for a session with a frontend of its own (the daemon's list, and so /sessions, still says `attached`, a wire diff --git a/docs/next-terminal.md b/docs/next-terminal.md index 26996897..2d033380 100644 --- a/docs/next-terminal.md +++ b/docs/next-terminal.md @@ -230,7 +230,7 @@ What differs from the plan above, and why: of them fail for want of a terminal (they open a shell or a command pane, read the emulator, or index the classic boot's three shells) and say so on their first line (`if (pardes.Term.ops == null) return - error.SkipZigTest; // a shell`), and ninep/testing.zig's `withTerm` + error.SkipZigTest; // a shell`), and ninep/harness.zig's `withTerm` once for its 29. The rest run. core-test: 810 of 949 run, 139 skip; `shell-test` runs all of them with the terminal. The 28 tests that read terminal.zig's own state through a core are in test/terminal.zig diff --git a/docs/next-tests.md b/docs/next-tests.md index 2266b06a..7da60470 100644 --- a/docs/next-tests.md +++ b/docs/next-tests.md @@ -13,7 +13,7 @@ agent's survey. The `e2e` line (kbdin, mousein) is its first step. `mousein`), the process (flags, daemon, attach, signals, terminal bytes), and files on disk and effects. A rewrite that keeps those keeps its tests. - **T1, in-process 9P, is the main tier.** The core is driven only through - `serveFs` (core/ninep/testing.zig's `call`, `rd`, `wr`): as behavioural + `serveFs` (core/ninep/harness.zig's `call`, `rd`, `wr`): as behavioural as a client on a socket, and milliseconds a case. - **One process runner, not Python (the user, 2026-11-04):** test/process.zig's `Process` starts `pardes` detached (over its socket), in a pty, or as the diff --git a/docs/next-winmode.md b/docs/next-winmode.md index c2a01da8..1f7c87c2 100644 --- a/docs/next-winmode.md +++ b/docs/next-winmode.md @@ -36,13 +36,13 @@ Typed in one go, the `j` after `SPC d` lands 100-250 ms after the `d` waiting to see something happen. 400 ms clears a relaxed typist with margin and is still quick enough to read as "it is asking", not "it is broken". Key-hint popups elsewhere (which-key) wait a few hundred ms for the same reason. It is a compile-time -constant beside `del_question` (keys are compiled in); a Runtime setting +constant beside `del_question` (keys are compiled in); a `Settings` field would be one line in config if the author wants to tune it live. ## Tests - `window mode d deletes the outlined pane and asks k or j, c collapses - it, and the mode stays` (pardes.zig): c twice restores the height; d asks, + it, and the mode stays` (core/layout.zig): c twice restores the height; d asks, Esc keeps it, d j gives the rows below and the outline follows; d with one neighbour closes at once onto it; labels hold none of h j k l d c. - `the Del question shows only once its delay is up: a quick SPC d j never diff --git a/docs/render-pipeline.md b/docs/render-pipeline.md index 05bc8cfa..4f3cc7a5 100644 --- a/docs/render-pipeline.md +++ b/docs/render-pipeline.md @@ -15,7 +15,8 @@ frontend keeps the little it draws on its own. deadline (`nextWake`: a message's linger, the look-hover preview, a question's hint, a paused Grep, work that resumes a frame at a time); `now`; `poll_frame`; `render` and `present` only when a frame is owed - (`needs_frame`); and `post_present`, whose `Pardes.presented` lets a + (`needs_frame`; `present` says whether it showed the frame, and one it + held is owed again); and `post_present`, whose `Pardes.presented` lets a drag's moving end and a look-hover follow what is under the pointer now. - `advance(now)` steps `.tick`s a `frame_ns` (16 ms) at a time, for the work that resumes a frame at a time; a wait is jumped in one step. @@ -24,7 +25,12 @@ frontend keeps the little it draws on its own. owner and focus; a body's first line and the text it shows, `Region.line` and `Region.doc`), the layers a pixel shell draws at the tagline's pitch and with compact context rows, the placements, the - cursor and the palette (`Chrome`). Nothing on it moves. + cursor and the palette (`Chrome`). Nothing on it moves. Beside it, + `draw.place` fills one record, `Facts` (surface.zig): the view's size, + each open pane's rectangle, tag rows and kind, and the settings a + frontend draws by. A frontend draws, and turns its input into events, + from the Surface and its Facts, not from the core, so a client draws + its own view as a session's own frontend does. - A placement (surface.zig's `Placement`) is a picture over the cells, a pane's at a time and lowest first: its pixels (`raster`: RGBA, straight alpha), the part shown (`src`), the cells it lies over and is clipped to @@ -41,9 +47,10 @@ frontend keeps the little it draws on its own. ## The frontends' own -Each draws these on its own clock, from the Surface alone, and draws their -frames itself while they move (the last frame again: the tty's -`poll_frame`, the window's loop), pacing its own waits: +Each draws these on its own clock, from the Surface and its Facts alone, and draws their +frames itself while they move (the last frame again: a session's own +frontend through its host's `poll_frame`, a client's through the client +loop's `again`, runtime/client.zig), pacing its own waits: | what | tty | window | from | |---|---|---|---| @@ -55,9 +62,9 @@ frames itself while they move (the last frame again: the tty's | `Pet` | (unsupported) | a sprite in the workspace tag's blank end (gui/pet.zig) | the grid's first row; SDL's ticks | | a placement | a kitty image placed over its cells, or glyph art in them (Art.zig) without kitty graphics or when its pane asks | a texture by key, scissored to its cells, or glyph art when its pane asks | the frame's placements | -The settings these read are plain bytes in the core's settings, dumped -and replicated as any other; nothing a frontend keeps goes back to the -core. +The settings these read are the core's settings, plain bytes dumped and +replicated as any other, copied into the frame's Facts; nothing a frontend +keeps goes back to the core. ## The window's composition diff --git a/docs/search-proto-converge.md b/docs/search-proto-converge.md index ddc41196..da336f7c 100644 --- a/docs/search-proto-converge.md +++ b/docs/search-proto-converge.md @@ -15,7 +15,7 @@ only the prompts that are not search. | piece | file | lifted from | |---|---|---| -| attached panes: a group under its owner, rows from the owner alone, moving/folding/closing with it, seam drag, Dump/Restore, `Unattach` | `core/layout.zig` "Attached panes", `Pane.attached_to` | attached | +| attached panes: a group under its owner, rows from the owner alone, moving/folding/closing with it, seam drag, Dump/Restore, `Undock` | `core/layout.zig` "Attached panes", `Pane.docked_to` | attached | | places: every match tinted, rail ticks (B1 on a tick goes there), current selected and in view, smart-case regex, view-first sliced scan, silent wrap | `core/Places.zig`, `Pane.places` | incsearch (MatchSet) | | the query pane: line 1, its first word the source, live rows, preview, Enter/Esc/Del, reuse, settings | `core/Query.zig`, `Pane.query` | queryline, pick, live, preview, everywhere | | fuzzy names (files, recent, panes, declarations) | `core/Names.zig` | pick (its scorer, whole) | @@ -115,7 +115,7 @@ erases it and B2 / B3 on it take the word clicked, as on any row. **Enter** puts the keyboard on the current hit in its pane (the +Preview promoted in place: same slot, serial, rect, an unattached file pane from then on), fills `/`, and freezes the rows into ordinary text (tag ` Save -Unattach Del`). A `/` freezes its whole list (every place found first, 2000 +Undock Del`). A `/` freezes its whole list (every place found first, 2000 rows at most), a Grep every line it has. **Esc** while typing puts every view back, clears the places it fed and closes the pane, its rows back to the owner; a reused pane's frozen rows and their places come back instead. @@ -145,7 +145,7 @@ cursor on line 15000. | keystroke 1, `p` | Every `p` in the view tinted at once, the rest found a 4 ms slice a frame (the tag `1/38479+` until done); rail ticks fill in; the first `p` at or after the cursor selected in layout.zig (scrolled only if off screen). Rows: the lines holding `p`, each ` 15003 code`, from two before the current one, the current marked as the visited row, a note row above saying how many places come before them. | | keystroke 2, `a` | `pa`: tints, ticks and rows narrow (`1/10189`); the current is again the first at or after where `/` was pressed, not after the last preview. The pane is the same size, line 1 where it was. | | Ctrl-n / Ctrl-p | The next / previous `pa` current, selected in layout.zig; `2/10189`. | -| Enter | The keyboard on that `pa`, `pa` in `/`, the rows frozen (the whole list, 2000 rows), tag `+Search 2/10189 Save Unattach Del`; tints and ticks stay while the pane lives. Ctrl-o goes back to where `/` was pressed. | +| Enter | The keyboard on that `pa`, `pa` in `/`, the rows frozen (the whole list, 2000 rows), tag `+Search 2/10189 Save Undock Del`; tints and ticks stay while the pane lives. Ctrl-o goes back to where `/` was pressed. | | `n` | The next `pa` in layout.zig, `3/10189`, its row marked in the +Search. | | `N` | Back to `2/10189`; from the first, round to the last with no message. | | Esc (typing) | layout.zig's selection and scroll exactly as at `/`, tints and ticks gone, the +Search closed, its rows back to layout.zig. | diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 5273298e..9350b484 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -1,7 +1,8 @@ -// Building pardes, for contributors: platforms, options, the library, tests, -// the release gates and sending patches, then how the pieces fit: the core -// and its shells, the threads, the daemon and its sessions, the 9P engine, the -// listeners and mounts. +// Building pardes, for contributors: platforms, options, the patches to +// dependencies, the library, tests, the release gates and sending patches, +// then how the pieces fit: the principle, the tree, the core and its +// frontends, the loops, the tape, the checks, the threads, the daemon and its +// sessions, the 9P engine, the listeners and mounts. #import "style.typ": key, keys, btn, chord, word, tag, addr, file, cmd, doc, pairs For contributors: how pardes is built, tested and released, and how its @@ -9,7 +10,7 @@ pieces fit. To install it, see #doc("setup", section: "install"). = Platforms -Zig *0.17.0* (`build.zig.zon` pins `minimum_zig_version`). Dependencies are +Zig *0.17.1* (`build.zig.zon` pins `minimum_zig_version`). Dependencies are fetched and pinned by the manifest; the terminal build needs no system package. The SDL shell builds SDL3 and FreeType from source. Pictures and PDFs are addons, each its own step: `zig build image`, `zig build pdf` @@ -73,6 +74,22 @@ must share with its session; `pardes --help` lists every flag. [`-Dhelix-harness`], [reference executable for live differential tests; `HX_HARNESS`, else `hx-harness` on `PATH`], ) +== Patches to dependencies <dep-patches> + +A fault in a dependency is fixed in the dependency, never guarded in the +core. pardes builds a few with edits of its own, made as each is fetched: +`build/patches.zig` holds, for each patched file, a table of exact edits +(and a file to append, in `build/patches/`), which `tools/patch.zig` +applies at make time, so a fresh fetch is patched the same and a bump that +moves an anchor fails that file's step. Each table says why, edit by edit. + +#pairs( + [vaxis], [its input parser (no reply, split read or malformed sequence reaches the editor as typed text), its event queue (every blocked writer woken) and its render (a blank whose ink alone changed is not sent)], + [zstbi], [stb_image and its writer cut out: its resize alone is left, for a terminal PNG's downscale], + [ghostty], [kitty graphics: a path opened only once it is a regular file, shared memory non-blocking, an image no larger than a screen's storage], + [mvzr], [a step budget, a group's backtracking, `$` before `|`, the `**` Zig 0.17 removed, a class's range to `\xff`, and its reads past a pattern cut short; `docs/mvzr-group-backtrack.md` and `docs/mvzr-bounds.md` are the reports for upstream], +) + == As a library <library> A Zig package that depends on pardes is given one module and nothing of @@ -174,6 +191,9 @@ zig build lib-test the library, from a package that depends on pardes (t zig build hxlib helix's cases on the library's editor (-- --parity: against the file pane) zig build behaviour-test behaviour through the 9P tree, in process (test/behaviour/), and the T1 runner's short run of random 9P requests +zig build replicas the soak: a session and clients in process, on the real + session and client loops, each client typing over a + delayed link (-- [--seeds N] [--clients C] [--rtt 30,80,207]) zig build process-test real sessions over their sockets: mounts, flags, shells (test/process/), and the tty's own cases, each a pardes in a pty against its golden (test/process/tty_*.zig, test/snapshots/); -Dplatform=gui runs the @@ -251,12 +271,60 @@ Mail patches to the list `~gbrls/[email protected]`; it is the preferred way to #link("https://git-send-email.io")[git-send-email.io] sets `git send-email` up. The mirrors (#doc("setup", section: "install")) are for cloning, as a GitHub one will be; pull requests are not the preferred route. -= The core and its shells += The principle <principle> + +The owner's rule, in their words: "keep the wire protocol simple and raw, +and the local state process it" (2026-11-19). Every design choice is +measured against it. + +What crosses between processes is raw and ordered: a client's keys and +gestures, and the session's steps, each with what the session's machine +answered inside it (a file's bytes, the clock, a directory's listing) as +the machine said it. Each process's own core turns them into state. Nothing +computed is shipped where the input that computes it can be, and bandwidth +is spent before correctness is. What follows from it in the tree today: + +- A client is a whole core, loaded once from the session's dump. It applies + its own input at once and replays the session's units over it, rolling + back where the session ordered otherwise; nothing it draws is sent to it. + A picture or a game is drawn by the process that shows it, from its own + addon's code. +- A step that asks the machine asks through the tape (#link(<tape>)[below]): + the session records the answer, a client's replay reads that answer and + not its own machine's. The session's home, shell and directory are state + of the core for the same reason. +- What may wait is what touches the session's machine; the lists that say + so are checked by a test (#link(<may-wait>)[below]). +- Nothing a frame writes is read by a step, and nothing of a core is a + process global, so a core that drew and one that did not, in this process + or another, step alike (#link(<core-checks>)[the checks]). +- The exceptions, each small and named: the dump a client joins from (it + cannot replay from the start); the digests and quiet checks (a check, not + state); and a terminal, which crosses as the session's screen state + (rows and their changes), not as the pty's bytes. + += The tree <tree> + +#pairs( + [`core/`], [the editor as a state machine: panes, layout, the frame, the 9P tree, the tape and the replica engine. Module `core`, rooted at `core/root.zig`; the core's struct is `core/Core.zig`, `pardes.Pardes`], + [`dev/`], [the devices: the frontends (`dev/tui`, `dev/gui`, the Mac app's Swift in `dev/macos`), the host's services (`dev/host_io.zig` and the files beside it: `Host`, `Shell`, `Inbox`, `KindJob`, `Lsp`), the file watcher, the fonts, the language servers' client. Module `dev`], + [`runtime/`], [what runs a session: a session's loop (`session.zig`) and a client's (`client.zig`), the daemon and the stub, the upgrade, the crash file, the 9P listener and client (`9p_io.zig`). Module `runtime`; beside it each product's root, a module of its own: `runtime/main.zig` (`pardes`, `pardes-gui`) and `runtime/macos.zig` (the Mac's library)], + [`abi/`], [what crosses a process or a language: the replica stream (`abi/wire.zig`, module `wire`), the records the core and the terminal share (`plain.zig`), the terminal's table (`term.zig`), the addon's header and module, `pardes.h`], +) + +The modules name each other. A Zig test program runs the tests of the +module it is rooted at, so `core-test` and `shell-test` run one program a +module (core, dev, runtime, wire, and for `shell-test` `runtime/main.zig`'s); +each module's `root.zig` lists the files whose tests it runs. Beside the +four: `addons/`, `build/` (the build script's parts, the patches), `test/`, +`tools/`, `shaders/`, `vendor/`, `assets/` and `docs/`. + += The core and its frontends -One core, three shells (tui, gui, macos). The core owns -editing, layout, rendering and the virtual filesystem it serves over 9P; a shell turns native -input into `pardes.Event`, presents `pardes.Surface`, and performs host -effects such as spawning processes. +One core, three frontends (tui, gui, macos). The core owns +editing, layout, rendering and the virtual filesystem it serves over 9P; a +frontend turns native input into `pardes.Event`, presents `pardes.Surface`, +and its host performs effects such as spawning processes. - The core is a state machine: input arrives as an `Event` through `update`; output leaves as a `Surface` from `render(arena)` and as a ring @@ -271,13 +339,21 @@ effects such as spawning processes. - `pump` runs: wait for input (the host owns the sleep), flush paused 9P write batches, drain queued events, drain effects, settle the turn, then render and present only when a frame is needed and someone is looking. -- `host_io.Host` is a context pointer and a vtable of optional callbacks; a - null method is not an error, and `Host{}` is a complete in-process pardes - that the tests use. Comptime decides what a build has (`pardes.platform`, - `can_attach`); the vtable - decides who serves it. -- The root module is chosen by platform: `main.zig` (tui, gui), - `macos.zig`. The macOS shell is a library whose host owns `main()`. +- `Host` (`dev/Host.zig`) is a context pointer and a table of optional + callbacks; a null method is not an error, and `Host{}` is a complete + in-process pardes that the tests use. Comptime decides what a build has + (`pardes.platform`, `can_attach`); the table decides who serves it. +- The terminal and the window draw from the frame alone: the `Surface` + (cells, regions, layers, placements, cursor, `Chrome`) and one record + beside it, `Facts` (`core/surface.zig`: the view's size, each open + pane's rectangle, tag rows and kind, the settings a frontend draws by), + which `draw.place` fills with the frame. Each reads these, not the core, + to draw and to turn its input into events, so a client draws its own + view with no view of the core made live. A few reads of the core remain, in the window: its + hit test, its close and a session window's font. +- The macOS build is a library whose Swift app owns `main()` and the run + loop (`runtime/macos.zig`); it reads the core beyond the frame (its + theme, a pane's document state) and runs neither loop below. - The terminal is a module of its own, `term` (`core/term/`): the emulator (ghostty-vt), kitty images (wuffs, zstbi), the pager's parse and the replicas' screen state. It never imports the core; the core @@ -292,14 +368,115 @@ effects such as spawning processes. safe, its checks in Debug builds only. Code map: `core/panes.zig` and the pane kinds it names (`core/File.zig`, -`src/Terminal.zig`, ...), `core/layout.zig`, `core/fs.zig` (host access, -mounts and resolution) and `core/root.zig` (input), with one file per -thing beside them (`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, -`mouse.zig`, ...). `core/ninep/` is the control tree, `runtime/daemon.zig` the -per-user daemon and a terminal's stub, `abi/wire.zig` the input -wire a remote client will speak, `core/lsp/` the -language-server client; `test/` holds harnesses, goldens and helix cases, -`build/` the process tests' build steps. +`core/Term.zig`, `core/Kind.zig`, ...), `core/layout.zig`, `core/fs.zig` +(host access, mounts and resolution), `core/Core.zig` (the core's state +and its entries) and `core/draw.zig` (the frame), with one file per thing +beside them (`edit.zig`, `normal.zig`, `look.zig`, `exec.zig`, +`mouse.zig`, ...). `core/ninep/` is the control tree, `core/tape.zig` the +tape, `core/replica.zig` the replica engine (a client's `Replica` and +`Link`, a session's `Peers`), `runtime/daemon.zig` the per-user daemon and +a terminal's stub, `abi/wire.zig` the replica stream's frames, `core/lsp/` +the language-server client; `test/` holds harnesses, goldens and helix +cases, `build/` the build script's parts. + +== The loops <loops> + +A session runs `runtime/session.zig`'s `Loop`, a client +`runtime/client.zig`'s, each over the frontend it is given (comptime: no +vtable). The terminal's and the window's own frontend (`Own` in each) and +their client frontends (`Tty`, the window's `Client`) give the calls; +what a loop holds and its order are written once. + +- The session's loop holds its allocators and workers, its core (new, + from a dump, or an Upgrade's), the prompt files its shells start with, + the 9P listener and its clients (`Peers`). A turn is a `pump`, the step's + unit to the clients (`Peers.boundary`), the frontend's `sent`, an + Upgrade or a Restore between steps, and the daemon's notes. Its parts end + in one order: the listener, the clients, the frontend's devices, the + prompt files, the core, the workers, the allocators. The devices (ptys, + their readers, watched files, the jobs, the queue they post to) are + still each frontend's (`open`, `start`, `close`). +- A client's loop holds what it keeps across joins (`client.Start`: its + allocators, the addons it distrusts, its frame timings, the blobs it + keeps when far) and runs its joins: the reader thread, a pass at a time, + and a join again after a divergence or an Upgrade. A pass: the + frontend's own work (`own`), the predicted echo's frame, a draw or the + frontend's own motion (`again`), the wait (`deadline`, `wait`), then the + session's units settled, and a yank, paste or link its view asked for + done on this machine (`copy`, `paste`, `open`). An input is sent to the + session before it is applied here. +- The soak, `zig build replicas` (`test/replicas.zig`), runs both: its + session is `session.Loop` over a frontend whose host is the soak's + delayed network, every client a `client.Loop`, so what it tests is what + a session and a client run. The core's own unit tests stand a session in + with `replica.Authority`. + +== The tape <tape> + +The tape (`core/tape.zig`) records what a step takes in: the entry a host +called and its arguments, and every answer of the machine inside the step. +A session records its steps; a client replays the session's and records +its own speculations, to compare. + +- An entry is written once: a private body and, directly under it, its + public name made by `tape.taped` + (`pub const update = pardes.tape.taped(updateInner);`); the tape's + `Input` variant and the replay come from the body's parameters. The few + written by hand (`init`, `deinit`, `pump`, `render`, ...) each say why. +- The tape is the handle a step is given, as an allocator is: a core + holds it (`p.tape`, never null), and a function handed no core takes + `tape: *Tape`. A step's question of the machine goes through it + (`p.tape.value`, `p.tape.site`, `p.tape.authorityOnly`): the session + records the answer, a replay reads it. So far the kinds and addons, a + directory's listing, the file system, the core's own files and the + smaller ones ask it so; beside the field, the process's `tape.on` still + says which core is being stepped. +- A pane's and a view's slot are types where they cross the core's edge + (an entry's argument or answer, an event, an effect, a host call, the + wire's welcome): `Pane.Id` and `View.Id`, each an `enum(u8)` of its own. + The core's own loops keep their integers. +- The session's facts, its home, default shell and directory, are the + core's state (`session_home`, `session_shell`, `session_dir`), read once + at its start through the tape and carried in its dump: a far client's + `~`, #word("Shell") and a word run in the session's directory are the + session's. + +== What may wait <may-wait> + +A client applies its own input at once; a step that needs the session's +machine stops its speculation, and the input waits a round trip for the +session's unit (`tape.hostCall`). The user's line: motions, edits and +layout are instant; what has a side effect on the system may wait. Two +lists say which, each row with why: + +- `keeps_stopping` (`core/tape.zig`): the Host entries that return nothing + and still stop a speculation (`pty_write`, `spawn`, `write_file`, ...). + A client records any other such call as made and goes on; an entry that + answers stops by nature, the answer being the session's. +- `may_wait` (`core/replica.zig`): each word, key or gesture that may wait, + on a kind of pane, and where it stops. A test walks every word of the + registry, every key (and every key after each prefix) and the gestures + between panes, on a file's, a kind's and a shell's pane: a stop not + listed fails it, and a row nothing stopped at is stale. The soak judges + its stops by name against the same list. + +== The checks <core-checks> + +At the end of `core/root.zig`, run by `core-test`, `shell-test` and +`unit-test`: + +- *No process globals:* every container-level `var` in `core/` is on + `allowed_vars`, with why it is not a core's. +- *What the core asks of the machine:* every line of `core/` naming libc, + `std.posix`, `getenv`, a `std.Io` file, directory or socket, `dev` or + `runtime` is counted, a file at a time, against `machine_lines`, with why. +- *What is kept out of the digest:* every field kept out of the digest and + the dump (`.local`, `.derived`) is on `kept_out`, with who writes it and + why a step's read of it is the step's. + +Beside them, `core/draw.zig`'s test "a frame changes nothing a step reads" +steps a core that draws after every input and one that never draws, and +their digests agree after every step. == Threads @@ -311,7 +488,7 @@ would change a pane parks (`Status.again`) and is retried when the editor rests. 9P requests are not events: they enter through `Pardes.serveFs`, and only one that changes a pane costs a frame. Language-server and selection-pipe workers post completions through a bounded mailbox; a -`host_io.Lsp.Job` owns copies of the source, path and arguments, never +`Lsp.Job` (`dev/Lsp.zig`) owns copies of the source, path and arguments, never reading the live core, and a request id, the pane's serial and (for an edit) the file's revision reject a stale reply. A process that never calls `turn.start` (the tests) has no second thread. diff --git a/docs/typ/builtins-gui.json b/docs/typ/builtins-gui.json index 8ed70b10..732e66a7 100644 --- a/docs/typ/builtins-gui.json +++ b/docs/typ/builtins-gui.json @@ -101,8 +101,8 @@ {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."}, - {"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."}, + {"name": "Undock", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Undock a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Unfollow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Take this pane out of its Follow chain: it stays, a Zerox twin with the scroll it has, and the chain closes up behind it."}, {"name": "Unmount", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Unmount the 9P tree mounted under /n/<name>."}, {"name": "Up", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane above, and from a column's top pane to its tag."}, diff --git a/docs/typ/builtins-tui.json b/docs/typ/builtins-tui.json index aa95d9a6..0a074c44 100644 --- a/docs/typ/builtins-tui.json +++ b/docs/typ/builtins-tui.json @@ -95,8 +95,8 @@ {"name": "Togglettymode", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Switch this terminal between raw program input and normal editor mode."}, {"name": "TreeContext", "leader": null, "also": [], "arg": true, "scope": "pane", "setting": false, "choices": null, "doc": "Show the declarations enclosing the top row at the pane's head, on or off."}, {"name": "Tutor", "leader": "SPC h t", "also": ["topbar"], "arg": false, "scope": "root", "setting": false, "choices": null, "doc": "Open the tutor, a document to work through."}, - {"name": "Unattach", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Unattach a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Undo", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "acme's Undo and Redo: step the pane's body back or forward through its edits, from a tag, a pane ctl or exec."}, + {"name": "Undock", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Undock a pane from the pane it answers for: it stays where it is, a pane of its own, and the next search from that pane opens another under it."}, {"name": "Unfollow", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Take this pane out of its Follow chain: it stays, a Zerox twin with the scroll it has, and the chain closes up behind it."}, {"name": "Unmount", "leader": null, "also": [], "arg": true, "scope": "root", "setting": false, "choices": null, "doc": "Unmount the 9P tree mounted under /n/<name>."}, {"name": "Up", "leader": null, "also": [], "arg": false, "scope": "pane", "setting": false, "choices": null, "doc": "Move the keyboard to the pane above, and from a column's top pane to its tag."}, diff --git a/docs/typ/reference.typ b/docs/typ/reference.typ index 2562c91b..4c193e0f 100644 --- a/docs/typ/reference.typ +++ b/docs/typ/reference.typ @@ -1179,8 +1179,12 @@ of it is laid out by `view` and drawn by `paint`. handed (the last allocation the answer); one asked before an #word("Addon") `reload` answers into nothing, and the old library stays until its last such job has answered. -- A client of the session runs no addon's code: a pane of a kind it lacks - shows the session's frames of it, and its keys go to the session. +- A client of the session runs a kind whose state is plain (`PA_PLAIN`: + the games, the picture, the PDF) from its own addons, as the session + does, and draws its pictures itself. A pane of a plain kind it lacks, or + one that broke its promise there, shows a line saying so; a kind whose + state is not plain runs in the session alone, and its pane in a client + shows a line saying that. The session sends no pictures to a client. - #word("Addon") `load <path>` (relative to the pane's directory) loads one; `unload <name>` lets one go, refused while a pane of its kind is @@ -1230,8 +1234,10 @@ of it is laid out by `view` and drawn by `paint`. pane whose file changes on disk opens again from it, its record kept for its `load` (a PDF stays on its page). - An addon runs in pardes's process. A load is marked on disk while it - runs; a start that finds the mark of one that never finished skips that - library, listed so, until #word("Addon") `load` asks for it again. A + runs, with the loading process's pid; a start that finds the mark of a + load whose process is gone (it never finished) skips that library, + listed so, until #word("Addon") `load` asks for it again. Another + pardes's load still under way is no crash. A crash inside one says `in addon <file>, <call>` in the crash record. - `pardes --addon-test <lib> <script>` runs a script of keys, clicks, words and ticks (its clock starts at 1 s), `focus` and `blur`, `size C diff --git a/docs/typ/running.typ b/docs/typ/running.typ index 7e0d16d4..1500845e 100644 --- a/docs/typ/running.typ +++ b/docs/typ/running.typ @@ -9,10 +9,11 @@ A running pardes is up to four kinds of process. Which of them there are, and what each holds, depends only on how it was started. -// daemon.zig:8-16 (nobody's parent; dups; hands terminals, windows, -// replicas); replica.zig:1-19, :730-769 (a client's core from the dump); -// host_io.zig:2176-2179 (the shells are the session's children); -// 9p_io.zig:57 (the socket); daemon.zig:546-698 (the stub). +// runtime/daemon.zig:8-16 (nobody's parent; dups; hands terminals, +// windows, replicas); core/replica.zig:1-19, :747-794 (a client's core +// from the dump); dev/host_io.zig:548-551 (the shells are the session's +// children); runtime/9p_io.zig:57 (the socket); runtime/daemon.zig:546-698 +// (the stub). #pairs( [*session*], [the process with the truth: the one core every other copy follows, the shells' pty masters (the shells are its children) and the 9P socket. There is one a session, always.], [*client*], [any further terminal or window on a session: a process of its own, with a copy of the session's core (a replica) loaded from the session's dump and kept in step with the session's tape. It has its own view (columns, focus, cursors, scroll) and draws it. It holds no shells and no 9P socket. A client on another machine is *far*.], @@ -20,9 +21,9 @@ and what each holds, depends only on how it was started. [*stub*], [the process your shell waits on when the session is not it. It holds nothing: it passes signals on, and ends when the session leaves its terminal.], ) -// tui.zig:588 (a session's terminal: one or none); gui.zig:2381-2384 (the -// window, or none while detached); daemon.zig:901-905 ("a session shows one -// frontend of its own"). +// dev/tui/tui.zig:590 (a session's terminal: one or none); +// dev/gui/gui.zig:2433-2436 (the window, or none while detached); +// runtime/daemon.zig:901-905 ("a session shows one frontend of its own"). A *frontend* is what draws: the terminal (`pardes`), the window (`pardes-gui`), or the Mac's own build. A session draws at most one frontend of its own: the one it was started with, or one attached to it @@ -40,10 +41,11 @@ travels on it. #run-terminal() -// main.zig:1538-1563, daemon.zig:663-698 (the fork, setsid, the stub); -// daemon.zig:550-559, :567-616 (what the stub forwards and how it ends); -// tui.zig:1697-1721 (the terminal's end: detached while kept, else the -// end); daemon.zig:305-314 (kept: the daemon answered and is still there). +// runtime/main.zig:1570-1595, runtime/daemon.zig:663-698 (the fork, +// setsid, the stub); runtime/daemon.zig:550-559, :567-616 (what the stub +// forwards and how it ends); dev/tui/tui.zig:1685-1709 (the terminal's +// end: detached while kept, else the end); runtime/daemon.zig:305-314 +// (kept: the daemon answered and is still there). `pardes` forks the session off and stays as its stub. The session runs in a POSIX session of its own, so it can outlive the job your shell waits on. It reads the keys from the terminal and draws on it itself; the stub only @@ -58,9 +60,9 @@ daemon, or after the daemon has died, it ends the session and its shells. #run-window() -// main.zig:1536-1537 (registered, no fork); gui.zig:1775-1788 (the -// window's close); next-daemon.md "Phase 3 notes", known gaps (a terminal's -// job). +// runtime/main.zig:1568-1569 (registered, no fork); +// dev/gui/gui.zig:1830-1843 (the window's close); next-daemon.md "Phase 3 +// notes", known gaps (a terminal's job). The process you started is the session; there is no stub. Closing the window ends the session and its shells, unless the session has clients and a daemon: then only the window closes, and the session runs on, detached. @@ -71,17 +73,18 @@ terminal hangs up. #run-detach() -// main.zig:1502-1520 (no fork; 160x50); main.zig:1535-1537 (registered -// detached, or with no daemon not at all); tui.zig:596-603 and :1700 -// (a hangup taken, nothing to leave); 9p_io.zig:704-729 (the hangup's -// default handler in a window's process). +// runtime/main.zig:1517-1552 (no fork; 160x50); runtime/main.zig:1567-1569 +// (registered detached, or with no daemon not at all); +// dev/tui/tui.zig:598-605 and :1688 (a hangup taken, nothing to leave); +// runtime/9p_io.zig:704-729 (the hangup's default handler in a window's +// process). The process you started is the session: nothing is forked, so the `&` that puts it in the background is yours to type (`pardes new --detach=work` is the same). It draws nothing and is 160×50 until an attach or the root #file("ctl")'s `size` sizes it. Until something attaches, 9P is the only way in (#doc("scripting")). -// main.zig, the --detach branch (the exec of the pardes beside it). +// runtime/main.zig, the --detach branch (the exec of the pardes beside it). `pardes-gui --detach` runs the `pardes` installed beside it in its place: a detached session draws nothing, and a window's binary would start a GPU device and its fonts for it. So every detached session is a terminal's @@ -96,9 +99,10 @@ reaches it. #run-attach-detached() -// main.zig:1780-1810 (attachTo); daemon.zig:883-897 (handed on); -// tui.zig:1373-1401 (the terminal entered as the first was); -// gui.zig:3271-3289, :2534-2547 (the window opened again). +// runtime/main.zig:1812-1842 (attachTo); runtime/daemon.zig:883-897 +// (handed on); dev/tui/tui.zig:1354-1382 (the terminal entered as the +// first was); dev/gui/gui.zig:3384-3402, :2588-2601 (the window opened +// again). For a terminal's session, `pardes attach work` hands its terminal and a pipe to the session through the daemon, and stays as the stub. For a window's, `pardes-gui attach work` asks, then exits, and the session opens @@ -106,7 +110,7 @@ its own window again. Either way the frontend is the session's own again, in the process that has been the session all along: what happens when it closes is what the first two sections say. -// daemon.zig:901-972 (find: the bare attach, and `other`). +// runtime/daemon.zig:901-972 (find: the bare attach, and `other`). The kind has to match. A terminal's session attached from `pardes-gui`, or a window's from `pardes`, is joined as a client (the next section). Bare, `pardes attach` takes the one detached session of its kind; with @@ -118,14 +122,15 @@ spelling of `attach work`. #run-attach-client() -// main.zig:1812-1818 (crossAttach); daemon.zig:974-1008 (the hello, the -// same build, handed on); replica.zig:1-19 (speculation and rollback); -// replica.zig:2013-2023, views.zig:31, Core.zig:1110-1153 (four views, the -// session's own among them); replica.zig:2111-2133 (a client leaving); -// replica.zig initDump, Addon.zig plainOps (a plain kind's code runs in -// the client that has it; another's in the session alone); gui.zig:2147-2161 -// (a client's notch: whole rows sent), :3544 (glideFrame: the picture on -// the client's clock); gui.zig:580-608 (a client's font: the session's +// runtime/main.zig:1844-1850 (crossAttach); runtime/daemon.zig:974-1008 +// (the hello, the same build, handed on); core/replica.zig:1-19 +// (speculation and rollback); core/replica.zig:2204-2214, core/views.zig:31, +// core/Core.zig:1163-1203 (four views, the session's own among them); +// core/replica.zig:2303-2325 (a client leaving); core/replica.zig initDump, +// core/Addon.zig plainOps (a plain kind's code runs in the client that has +// it; another's in the session alone); dev/gui/gui.zig:2200-2214 (a +// client's notch: whole rows sent), :3673 (glideFrame: the picture on the +// client's clock); dev/gui/gui.zig:595-623 (a client's font: the session's // request, by the face's name on this machine). Measured 2026-11-17 // (.scratch/sketch/reports/pardes-measure.md sections A, C and E): a // client's notch glides as the session's window does (5 frames, 0 to @@ -140,12 +145,28 @@ loads the session's dump into its own core, applies its own keys at once, and takes the session's tape (each step as the session took it) as the truth, rolling back when the session ordered things differently. +// core/replica.zig:5316-5395 (may_wait: what a client waits for, each +// row's why); core/tape.zig:1163-1193 (keeps_stopping); core/Core.zig:1763-1778 +// (readSessionFacts: the session's home, shell, directory); +// runtime/client.zig:245-261 (asks: a client's yank, paste and link, here). +What a client applies at once is what changes the editor alone: typing, +motions, edits, the layout (a pane dragged, collapsed or closed, a column +made), a yank. What touches the session's machine waits a round trip for +the session's step: a save, a shell's keys or its closing, a file read +from its disk, a program run, a kind whose state is the session's +(#doc("building", section: "may-wait") lists each, with why). The +session's machine is the one a client's words read: `~`, the default +shell and the directory a word runs in are the session's. The client's +machine is the one its view acts on: a yank to the system clipboard fills +the clipboard here, #word("ClipPaste") pastes it, and a link looked at +opens here. + A session takes three clients: four views at once, its own among them. A client's #word("Detach"), or its terminal or window closing, ends that client only; the last client of a detached session leaves its layout as the session's, for the next one to find. In a client, an addon whose state -is plain (`PA_PLAIN`: the games) runs in the client that shows it, from -that client's own addons, its keys applied at once; one the client lacks +is plain (`PA_PLAIN`: the games, the picture, the PDF) runs in the client +that shows it, from that client's own addons; one the client lacks shows a line saying so, and any other addon's panes show a line saying it runs in the session alone. A window client's wheel glides as the session's own window does: whole rows @@ -160,11 +181,11 @@ part. #run-far() -// main.zig:1498-1500, :1687-1772 (HOST:NAME, ssh -L, PARDES_SSH, -// PARDES_REMOTE_RUNTIME, a path with '/'); tui.zig:678-685 (far: blobs by -// hash, zstd); replica.zig:2516-2640 (Have: the disk cache); -// tui.zig:819-828, replica.zig:3012-3024 (no reconnect; a rejoin only -// after a divergence or an Upgrade). +// runtime/main.zig:1513-1515, :1719-1804 (HOST:NAME, ssh -L, PARDES_SSH, +// PARDES_REMOTE_RUNTIME, a path with '/'); runtime/client.zig:74-87 (far: +// blobs by hash, zstd); core/replica.zig:2709-2845 (Have: the disk cache); +// runtime/client.zig:168-177, core/replica.zig:3262-3274 (no reconnect; a +// rejoin only after a divergence or an Upgrade). `pardes attach box:work` runs `ssh -L` from a socket here to box's replica socket and is a client through it. `PARDES_SSH` replaces `ssh`; `PARDES_REMOTE_RUNTIME` names box's runtime directory when it is not the @@ -181,12 +202,12 @@ of the session or a divergence of its own. `pardes attach /run/x.sock:work` #run-no-daemon() -// daemon.zig:52-61 (PARDES_DAEMON, PARDES_TEST), :34 (Linux and FreeBSD -// only); main.zig:1544-1560 (no daemon reached: no fork); tui.zig:1352-1353, -// gui.zig:2483, host_io.zig:227 (Detach and Adopt refused); -// replica.zig:1900-1905 (a client only through the daemon); -// core/root.zig:117 (can_attach); runtime/main.zig:1498-1500 (a far attach needs no -// daemon here). +// runtime/daemon.zig:52-61 (PARDES_DAEMON, PARDES_TEST), :34 (Linux and +// FreeBSD only); runtime/main.zig:1576-1592 (no daemon reached: no fork); +// dev/tui/tui.zig:1333-1334, dev/gui/gui.zig:2537, dev/host_io.zig:85 +// (Detach and Adopt refused); core/replica.zig:2087-2092 (a client only +// through the daemon); core/root.zig:118 (can_attach); +// runtime/main.zig:1513-1515 (a far attach needs no daemon here). With `PARDES_DAEMON=off`, in a window under test (`PARDES_TEST`), where none could start, and in the Mac's own build, the session is the process you started, with no stub. #word("Detach") and #word("Adopt") refuse, no @@ -198,9 +219,10 @@ client. = At a glance <run-glance> -// The rows' sources are the sections above; `ps`: daemon.zig:241-245 -// (the daemon is whichever binary started it), main.zig:1727 (ssh's -// arguments), upgrade.zig:5-8 (an upgraded session's command line). +// The rows' sources are the sections above; `ps`: +// runtime/daemon.zig:241-245 (the daemon is whichever binary started it), +// runtime/main.zig:1759 (ssh's arguments), runtime/upgrade.zig:5-8 (an +// upgraded session's command line). #{ set text(size: 0.85em) set par(justify: false) @@ -225,13 +247,14 @@ started it. After an #word("Upgrade"), a session's command line starts with = What survives what <run-survives> -// replica.zig:2111-2133 (a client leaving); daemon.zig:485-502, -// 9p_io.zig:704-729, tui.zig:949-961 (TERM, HUP, INT: the shells go); -// daemon.zig:755-765, :770-789 (killed outright: kept for Adopt; `kill`: -// not); tui.zig:596-598 (a HUP kept by a daemon is a terminal's end, not -// the session's); daemon.zig:397, main.zig:1534-1561 (registered at the start and at -// an Upgrade only); upgrade.zig:1-15, replica.zig:2178-2201, :2787-2807 -// (Upgrade); Db.zig:1-17, :385-410 (the state file: Recent, the dumps). +// core/replica.zig:2303-2325 (a client leaving); runtime/daemon.zig:485-502, +// runtime/9p_io.zig:704-729, dev/tui/tui.zig:928-940 (TERM, HUP, INT: the +// shells go); runtime/daemon.zig:755-765, :770-789 (killed outright: kept +// for Adopt; `kill`: not); dev/tui/tui.zig:598-600 (a HUP kept by a daemon +// is a terminal's end, not the session's); runtime/daemon.zig:397, +// runtime/main.zig:1566-1593 (registered at the start and at an Upgrade +// only); runtime/upgrade.zig:1-15, core/replica.zig:2370-2393, :2988-3008 +// (Upgrade); core/Db.zig:1-17, :385-410 (the state file: Recent, the dumps). #{ set text(size: 0.85em) set par(justify: false) @@ -269,15 +292,18 @@ The code says these words too, each for one thing of its own (the older notes, `docs/next-daemon.md` among them, still say `remote` for a client and `headless` for detached): -// replica.zig:1-19 (authority); replica.zig:1832-1876, :2812 (Peers, Link, -// Joining); tui.zig:1189, gui.zig:2379 (Shell); Core.zig:269-271, -// replica.zig:1850-1852 (unattended against detached); daemon.zig:283, -// :363, :799 (the daemon's attached and detached), main.zig:1616 (`ps` -// says "has a frontend"). +// core/replica.zig:1-19 (authority); core/replica.zig:2006-2062, :3013 +// (Peers, Link, Joining); dev/tui/tui.zig:1162, dev/gui/gui.zig:2431 +// (Shell); core/Core.zig:313-315, core/replica.zig:2028-2030 (unattended +// against detached); runtime/daemon.zig:283, :363, :799 (the daemon's +// attached and detached), runtime/main.zig:1647 (`ps` says "has a +// frontend"); runtime/session.zig:1-30, runtime/client.zig:1-35 (the +// loops and what a frontend gives each). #pairs( [`authority`], [the session's core, inside the replica engine; `replica`, a client's core], [`Peers`, `Peer`; `Link`, `Joining`, `Joined`], [a session's clients, seen from the session; a client's connection, seen from the client], - [`Shell`], [a frontend's host object (`tui.zig`, `gui.zig`); elsewhere the user's shell], + [`Shell`], [a frontend's host object (`dev/tui/tui.zig`, `dev/gui/gui.zig`); elsewhere the user's shell], + [`session.Loop`, `client.Loop`], [the one loop a terminal's or a window's session runs and the one a client runs (`runtime/session.zig`, `runtime/client.zig`), each over the frontend that draws it: `Own` for a session's own terminal or window, `Tty` and `Client` for a client's; the Mac's own build keeps its own], [`unattended`], [a detached session with no client either: nobody looks, so a message goes on the clock], [`attached` in #file("/sessions")], [the daemon's word for a session with a frontend of its own; `pardes ps` says "has a frontend"], ) diff --git a/runtime/macos.zig b/runtime/macos.zig index 408915da..a5869753 100644 --- a/runtime/macos.zig +++ b/runtime/macos.zig @@ -103,7 +103,7 @@ pub const Image = extern struct { paper_bg: u32, }; -pub const Runtime = extern struct { +pub const Callbacks = extern struct { userdata: ?*anyopaque = null, wakeup: ?*const fn (?*anyopaque) callconv(.c) void = null, set_clipboard: ?*const fn (?*anyopaque, [*]const u8, usize) callconv(.c) void = null, @@ -250,7 +250,7 @@ const State = struct { io: std.Io, core: *pardes.Pardes, started: bool = false, - runtime: Runtime, + runtime: Callbacks, tag_cells: [pardes.MAX_TAG_LAYERS][]Cell = @splat(&.{}), layer_cells: [pardes.MAX_PANES][]Cell = @splat(&.{}), cells: []Cell = &.{}, @@ -290,7 +290,7 @@ const State = struct { var state: ?State = null; -export fn pardes_init(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) c_int { +export fn pardes_init(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) c_int { if (state != null) return 1; // already up; deinit first initCore(runtime, cols_arg, rows_arg) catch |err| { log.err("init failed: {t}", .{err}); @@ -302,7 +302,7 @@ export fn pardes_init(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) c_ /// The shell's gpa in a Debug build, as std.start's is for the others. var debug_gpa: std.heap.DebugAllocator(.{}) = .init; -fn initCore(runtime: ?*const Runtime, cols_arg: u16, rows_arg: u16) !void { +fn initCore(runtime: ?*const Callbacks, cols_arg: u16, rows_arg: u16) !void { // The allocator every other shell gets from std.start: a DebugAllocator // in Debug, libc's malloc otherwise. libc's measured at least as fast as // std.heap.smp_allocator everywhere and faster on MuPDF's page-sized @@ -2461,7 +2461,7 @@ test "pardes.h matches the Zig boundary" { try expectEqual(@sizeOf(c.pardes_image_s), @sizeOf(Image)); inline for (@typeInfo(Image).@"struct".field_names) |name| try expectEqual(@offsetOf(c.pardes_image_s, name), @offsetOf(Image, name)); - try expectEqual(@sizeOf(c.pardes_runtime_s), @sizeOf(Runtime)); + try expectEqual(@sizeOf(c.pardes_callbacks_s), @sizeOf(Callbacks)); try expectEqual(@as(u32, c.PARDES_COLOR_DEFAULT), color_default); try expectEqual(@as(u32, c.PARDES_COLOR_INDEXED), color_indexed); diff --git a/runtime/main.zig b/runtime/main.zig index 2b600d63..448dfa57 100644 --- a/runtime/main.zig +++ b/runtime/main.zig @@ -753,7 +753,7 @@ const Word = struct { /// Its group: the first key after the leader, else what it is. fn group(w: Word) []const u8 { if (std.mem.indexOf(u8, w.doc, " (addon ") != null and std.mem.endsWith(u8, w.doc, ")")) return "addon"; - if (pardes.config.Runtime.find(w.name) != null) return "setting"; + if (pardes.config.Settings.find(w.name) != null) return "setting"; if (std.meta.stringToEnum(pardes.builtins.registry.Builtin(), w.name)) |b| if (pardes.config.leader_path.get(b)) |p| switch (p[0]) { 'f' => return "file", 'c' => return "column", diff --git a/test/macos_e2e.swift b/test/macos_e2e.swift index 74a03200..38d27808 100644 --- a/test/macos_e2e.swift +++ b/test/macos_e2e.swift @@ -51,7 +51,7 @@ private struct ScriptError: Error { } /// What the three C callbacks reach through `userdata`. A class, because a C -/// function pointer cannot capture: a pointer the runtime struct carries is the +/// function pointer cannot capture: a pointer the callbacks struct carries is the /// only way back into Swift state. private final class Host { /// Set by `wakeup`, which runs on a pty reader thread. Nothing else in the @@ -168,7 +168,7 @@ private final class Driver: PardesViewDelegate { message: "the view measured \(got.cols)x\(got.rows) cells, not the \(cols)x\(rows) the script asked for") } - var runtime = pardes_runtime_s( + var runtime = pardes_callbacks_s( userdata: Unmanaged.passUnretained(host).toOpaque(), wakeup: { ud in // A pty reader thread. One flag and out — see Host.woke. diff --git a/test/output.zig b/test/output.zig index 38e8ba0d..4b9e7678 100644 --- a/test/output.zig +++ b/test/output.zig @@ -549,7 +549,7 @@ test "a window's setting builtins (TaglineSize, Font) reach the report DumpConfi defer font_arena.deinit(); var chosen_font: ?[]const u8 = null; var buf: [512]u8 = undefined; - for (config.Runtime.settings) |setting| { + for (config.Settings.settings) |setting| { // The view's own (a terminal's takes no window's words). if (!setting.enabled(builtins.viewCapabilities(p))) continue; const command: []const u8 = switch (setting.action) { diff --git a/test/process/tty_boot.zig b/test/process/tty_boot.zig index a5f42074..741f6260 100644 --- a/test/process/tty_boot.zig +++ b/test/process/tty_boot.zig @@ -300,6 +300,9 @@ fn restore(gpa: std.mem.Allocator, exe: [:0]const u8) !void { // when it comes up. Both headers used to run the word under the PRESS, on // the press, so a sweep of `echo SWEPT-COL` ran a bare `echo`. A right sweep // looks for what it swept the same way, and the other button cancels. +// What a sweep ran is waited for in its pane's tag, `(echo SW''EPT-COL) exit +// 0`, which stays: the echo's line shows in the pane's one body row only +// until `exit 0` follows it, and a loaded machine draws both in one frame. fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { var t = try Tty.init(gpa, exe, "headersweep"); defer t.deinit(); @@ -321,7 +324,7 @@ fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("col-sweeping"); try t.drag("middle", "@echo+16", 2); try t.release("middle", "@echo+16", 2); - try t.wait(8000, "SWEPT-COL"); + try t.wait(8000, "EPT-COL) exit 0"); try t.stable(700, 15000); try t.snap("col-swept"); // the workspace tag, the same @@ -335,7 +338,7 @@ fn headersweep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.press("middle", "@echo", 1); try t.drag("middle", "@echo+15", 1); try t.release("middle", "@echo+15", 1); - try t.wait(8000, "SWEPT-WS"); + try t.wait(8000, "EPT-WS) exit 0"); try t.stable(700, 15000); try t.snap("ws-swept"); // a right sweep over part of a word looks for the part: `hay.txt` opens, @@ -399,7 +402,7 @@ fn headersweep_restored(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("col-sweeping"); try t.drag("middle", "@echo+19", 2); try t.release("middle", "@echo+19", 2); - try t.wait(8000, "RESTORED-COL"); + try t.wait(8000, "-COL) exit 0"); try t.stable(700, 15000); try t.snap("col-swept"); try t.press("left", "118", 1); @@ -415,7 +418,7 @@ fn headersweep_restored(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.style("ws-sweeping"); try t.drag("middle", "@echo+18", 1); try t.release("middle", "@echo+18", 1); - try t.wait(8000, "RESTORED-WS"); + try t.wait(8000, "-WS) exit 0"); try t.stable(700, 15000); try t.snap("ws-swept"); try t.done(); @@ -869,6 +872,10 @@ fn winch(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.start(31, 100, &.{ "-n", "3" }); try t.stable(700, 20000); try t.key("c-b"); + // Its shell at its prompt after its `ls` (a row of the 50-column pane + // holding `$` alone): typed into earlier, a loaded machine's bash echoed + // the line before its readline was up, or ran it before the `ls`. + try t.wait(20000, "\n $" ++ @as([47]u8, @splat(' '))); try t.stable(600, 8000); try t.send("for i in $(seq 600); do kill -WINCH $PPID; done; echo SUR''VIVED"); try t.key("enter"); diff --git a/test/process/tty_editing.zig b/test/process/tty_editing.zig index b5f0495c..63c75512 100644 --- a/test/process/tty_editing.zig +++ b/test/process/tty_editing.zig @@ -783,6 +783,12 @@ fn grep(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try t.key("g"); try t.stable(400, 5000); try t.send("zzqq"); + // Its count once the search is over (`0`): `0+` is while it still + // counts (its pause on the clock, then the worker), which a quiet + // machine's frame shows and a loaded one's not. The query typed in + // first: the pane's empty query counts `0` too. + try t.wait(10000, "Grep zzqq"); + try t.wait(10000, "+Search 0 "); try t.stable(700, 10000); try t.snap("nomatch"); try t.key("esc"); diff --git a/test/process/window.zig b/test/process/window.zig index 687b9000..00450a9b 100644 --- a/test/process/window.zig +++ b/test/process/window.zig @@ -426,8 +426,11 @@ fn corpus(gpa: std.mem.Allocator, exe: [:0]const u8) !void { try d.mouse("wheel", -3, cell_w * 40, cell_h * 12); try k.keep(&d, from, "11 a wheel's glide, every frame", true); from = try k.mark(&d); - try d.mouse("down", 1, cell_w * 20, cell_h * 10); - try d.mouse("up", 1, cell_w * 20, cell_h * 10); + // The press and its release in one write (Detached.mouse's events), + // so the window reads them in one pass: written apart, a loaded + // machine let it read the press alone and draw a frame between, one + // more kept frame than the base's (78) and every one after shifted. + try d.typeKeys(f.at("\x1b]777;mouse;down;1;{d};{d}\x07\x1b]777;mouse;up;1;{d};{d}\x07", .{ cell_w * 20, cell_h * 10, cell_w * 20, cell_h * 10 })); try k.keep(&d, from, "11 a click moves the caret, every frame", true); from = try k.mark(&d); try d.typeKeys("gg"); diff --git a/test/snapshots/find.golden b/test/snapshots/find.golden index 6c3bc950..4825d1dc 100644 --- a/test/snapshots/find.golden +++ b/test/snapshots/find.golden @@ -30,7 +30,7 @@ |32: /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Del |33: 1 beta body == snap promoted grid=120x41 cursor=7,33 -|22: +Search 2/3 Save Unattach Del +|22: +Search 2/3 Save Undock Del |32: /tmp/pardes-snap/find/cwd/sub/ZQMARK-beta.txt Save Term Collapse Follow Del == snap nomatch grid=120x41 cursor=11,14 |13: ^ +Search 0 Del @@ -43,7 +43,7 @@ == snap cancel grid=120x41 cursor=7,3 |13: |14: -|22: +Search 2/3 Save Unattach Del +|22: +Search 2/3 Save Undock Del |23: Find zqm |24: zqmark-alpha.txt |25: sub/ZQMARK-beta.txt diff --git a/test/snapshots/fsearch.golden b/test/snapshots/fsearch.golden index e923cb58..71a9900a 100644 --- a/test/snapshots/fsearch.golden +++ b/test/snapshots/fsearch.golden @@ -71,7 +71,7 @@ |8: 6 MARK b |9: ^ +Search 2/3 Del == snap landed grid=180x31 cursor=10,8 -|9: +Search 2/3 Save Unattach Del +|9: +Search 2/3 Save Undock Del == snap n grid=180x31 cursor=10,8 |7: 9 l9 |8: 10 MARK c diff --git a/test/snapshots/grep.golden b/test/snapshots/grep.golden index 30c8612c..52633372 100644 --- a/test/snapshots/grep.golden +++ b/test/snapshots/grep.golden @@ -36,10 +36,10 @@ |14: 1 deep |15: 2 TARGET inside sub == snap opened-hit grid=180x31 cursor=12,15 -|9: +Search 3/3 Save Unattach Del +|9: +Search 3/3 Save Undock Del |13: /tmp/pardes-snap/grep/cwd/sub/b.txt Save Term Collapse Follow Del == snap nomatch grid=180x31 cursor=11,15 -|14: ^ +Search 0+ Del +|14: ^ +Search 0 Del |15: Grep zzqq == snap esc grid=180x31 cursor=12,15 |14: 1 deep diff --git a/test/snapshots/lookrange.golden b/test/snapshots/lookrange.golden index 92b619e4..c677fb8f 100644 --- a/test/snapshots/lookrange.golden +++ b/test/snapshots/lookrange.golden @@ -69,7 +69,7 @@ |15: 0-0 d,#608269, 1-4 d,#0d1410, 5-6 #59675c,#0d1410, 7-11 #e5eee5,#0d1410, 12-149 #f5f7ee,#3c614a, |16: 0-0 d,#608269, 1-1 d,#0d1410, 2-4 d,#0d1410,b 5-6 #616f64,#0d1410,b 7-10 #f5f7ee,#3c614a, 11-149 #f5f7ee,#0d1410, == snap hit1 grid=150x31 cursor=17,15 -|21: +Search 2/2 Save Unattach Del +|21: +Search 2/2 Save Undock Del |22: /NEEDLE |23: r.txt:7:4 gg NEEDLE gg |24: r.txt:8:6 hhhh NEEDLE diff --git a/test/snapshots/lsp-client.golden b/test/snapshots/lsp-client.golden index 44b16309..42c378d1 100644 --- a/test/snapshots/lsp-client.golden +++ b/test/snapshots/lsp-client.golden @@ -26,5 +26,5 @@ |19: /tmp/pardes-snap/lsp-client/cwd/+Preview Del |20: 1 == snap gr-opened grid=100x25 cursor=21,6 -|13: +Search 2/3 Save Unattach Del +|13: +Search 2/3 Save Undock Del == snap gr-back grid=100x25 cursor=21,7 diff --git a/test/snapshots/lsprelpath.golden b/test/snapshots/lsprelpath.golden index 36f411ef..964f0286 100644 --- a/test/snapshots/lsprelpath.golden +++ b/test/snapshots/lsprelpath.golden @@ -29,7 +29,7 @@ | 1 == snap abslook grid=100x35 cursor=21,27 |3: 1 const shade = @import("../shade.zig"); -|16: +Search 1/2 Save Unattach Del +|16: +Search 1/2 Save Undock Del |26: /tmp/pardes-snap/lsprelpath/cwd/shade.zig Save Term Collapse Follow TreeContext Def Refs Del |27: 1 pub const Shade = enum { |28: 2 verdigris, @@ -103,7 +103,7 @@ | 1 == snap sublook grid=100x35 cursor=20,28 |3: 1 const tint = @import("inner/tint.zig"); -|16: +Search 1/2 Save Unattach Del +|16: +Search 1/2 Save Undock Del |26: /tmp/pardes-snap/lsprelpath/cwd/sub/inner/tint.zig Save Term Collapse Follow TreeContext Def Refs |27: Del |28: 1 pub const Tint = enum { diff --git a/test/snapshots/stepgrain.golden b/test/snapshots/stepgrain.golden index 1b7d3245..9af17689 100644 --- a/test/snapshots/stepgrain.golden +++ b/test/snapshots/stepgrain.golden @@ -84,5 +84,5 @@ |18: 0-0 d,#608269, 1-149 d,#0d1410, |22: 0-1 d,#496656, 2-32 #b2c3b8,#1d2824, 33-46 #d3b0d9,#1d2824, 47-149 #b2c3b8,#1d2824, == snap blank-opened grid=150x31 cursor=7,23 -|12: +Search 1/1 Save Unattach Del +|12: +Search 1/1 Save Undock Del |22: /tmp/pardes-snap/stepgrain/cwd/two words.txt Save Term Collapse Follow Del |
