diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 00:08:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 00:32:56 -0300 |
| commit | 2367ed34beccf3f2f1b8bbf6b8a171f50933d7a1 (patch) | |
| tree | 8dcc7111d1e78806c6ac0e0bd1493c25d86bfc85 /src/pardes.zig | |
| parent | 43a4c24e607a456d7a23eb8a779bce5651f18222 (diff) | |
| download | pardes-2367ed34beccf3f2f1b8bbf6b8a171f50933d7a1.tar.gz pardes-2367ed34beccf3f2f1b8bbf6b8a171f50933d7a1.zip | |
config, exec, look: Placement, BootShell, LookWord, DirLook and DiffLook go, with what each kept of pardes before it took acme's ways (exec's pardesPlace, atFoot, belowParent, pardesDoc and evictLonePristineTty with mouse.zig's call, layout's splitParent and columnFitsHalves that only they called, look's ls in a terminal for a directory, the word and patch looks' other branches, the SPC c p key, their Help and builtins-JSON rows, their lines in docs/typ and a changelog line), and the tests of them: Dir.zig's "DirLook terminal: a look at a directory opens a terminal there, no pane listing it", pardes.zig's "first document fallback splits like Term from the originating pane", "first document keeps its originating shell and only opens a column when it fits", "BootShell keep leaves the untouched boot shell a dragged document joins; replace closes it" and "a Look on a directory does not type ls into an occupied terminal", keys.zig's "keys: SPC j n and SPC j p walk on from the place a Look's +Search listing chose, its keyboard left in the file", look_and_exec.zig's "look-and-exec: a second LookWord list look in a directory refills its +Search rather than stacking another", placement.zig's "placement: Placement pardes puts a new pane right under the asking one, and bare it steps back to acme", output.zig's "LookNext/LookPrev keeps the result output a Look chose through a no-match answer, and a stale serial once it is deleted", and the snapshot scripts that turned them on (cmdword, doccol, look-dir, lookpanes, rsearch, splitparent, ttylook); the Del question's test makes its middle panes the acme way, a New at the column's foot, and the others that turned one on for their layout run without it
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 164 |
1 files changed, 20 insertions, 144 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index aa458198..0dc0dc5f 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -965,47 +965,6 @@ test "a terminal respawned into a closed pane's slot hangs the old shell up firs try std.testing.expect(closed and spawned); } -test "first document fallback splits like Term from the originating pane" { - for ([_]u16{ 100, 198 }) |width| for (0..3) |from| { - for ([_]bool{ false, true }) |collapsed| { - const p = try Pardes.init(std.testing.allocator, .{ .cols = width, .rows = 62, .shells = 3 }); - defer p.deinit(); - const tty = try Pardes.init(std.testing.allocator, .{ .cols = width, .rows = 62, .shells = 3 }); - defer tty.deinit(); - p.settings.placement = .pardes; - tty.settings.placement = .pardes; - if (collapsed) { - layout.toggleCollapse(p, from); - layout.toggleCollapse(tty, from); - } - p.sync(); - tty.sync(); - const before = p.rects; - const parent = layout.splitParent(p, from); - const at = layout.findPane(p, parent).?; - // The Look origin need not be the currently active pane. - p.active = (from + 1) % 3; - const free = p.freeSlot().?; - _ = try p.openTutorView(free); - exec.placeNew(p, from, from, free, .doc); - _ = exec.spawnTty(tty, from); - p.sync(); - tty.sync(); - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(free, p.active); - try std.testing.expectEqual(free, p.col_panes[at.col][at.idx + 1]); - for (0..3) |id| { - try std.testing.expect(p.panes[id] != null); - if (id != parent) try std.testing.expectEqualDeep(before[id], p.rects[id]); - } - for (0..4) |id| try std.testing.expectEqualDeep(tty.rects[id], p.rects[id]); - for (0..p.ncol) |col| { - try std.testing.expectEqualSlices(usize, tty.col_panes[col][0..tty.col_n[col]], p.col_panes[col][0..p.col_n[col]]); - } - } - }; -} - test "a frame no one watches is not drawn, and is drawn once someone does" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true }); defer p.deinit(); @@ -1153,29 +1112,6 @@ test "the Tutor pane is named +Tutor in the session's directory, never a bare pa while (p.nextEffect()) |e| try std.testing.expect(e != .save_file); } -test "first document keeps its originating shell and only opens a column when it fits" { - for ([_]u16{ 199, 200 }) |width| { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = width, .rows = 32 }); - defer p.deinit(); - p.settings.placement = .pardes; - const shell = p.panes[0].?; - _ = try p.openTutorView(1); - exec.placeNew(p, 0, 0, 1, .doc); - p.sync(); - try std.testing.expectEqual(shell, p.panes[0].?); - try std.testing.expectEqual(@as(usize, 1), p.active); - if (width < 200) { - try std.testing.expectEqual(@as(usize, 1), p.ncol); - try std.testing.expectEqualSlices(usize, &.{ 0, 1 }, p.col_panes[0][0..p.col_n[0]]); - try std.testing.expectEqual(p.rects[0].y + p.rects[0].h, p.rects[1].y); - } else { - try std.testing.expectEqual(@as(usize, 2), p.ncol); - try std.testing.expectEqual(@as(usize, 1), p.col_panes[0][0]); - try std.testing.expectEqual(@as(usize, 0), p.col_panes[1][0]); - } - } -} - test "an empty column shows its theme's empty_col under its tag: acme's white, else the border" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 20 }); defer p.deinit(); @@ -1195,24 +1131,6 @@ test "an empty column shows its theme's empty_col under its tag: acme's white, e } } -test "BootShell keep leaves the untouched boot shell a dragged document joins; replace closes it" { - inline for (.{ "keep", "replace" }) |word| { - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); - defer p.deinit(); - const shell = p.active; - try std.testing.expect(p.panes[shell].?.isTerminal()); - try std.testing.expect(p.executeBuiltinLine(shell, "BootShell " ++ word)); - _ = try p.openTutorView(1); - layout.insert(p, 0, 1, 1); - p.sync(); - exec.evictLonePristineTty(p, 0, 1); - p.sync(); - const kept = std.mem.eql(u8, word, "keep"); - try std.testing.expectEqual(kept, p.panes[shell] != null); - try std.testing.expectEqual(@as(usize, if (kept) 2 else 1), p.col_n[0]); - } -} - test "dragging a column's only pane to another leaves that column in place, empty" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 32 }); defer p.deinit(); @@ -1798,49 +1716,6 @@ test "image dump restores source bytes renderer choices and exact custom tail" { try std.testing.expectEqualSlices(u8, source, again.panes[0].?.image.?.raw); } -test "a Look on a directory does not type ls into an occupied terminal" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .cols = 100, .rows = 30 }); - defer p.deinit(); - p.settings.dir_look = .terminal; // `ls` in a terminal, not a directory pane - while (p.nextEffect()) |_| {} - - var realbuf: [4096]u8 = undefined; - const tmp = look.resolve(null, "/tmp", "/", &realbuf).dir; - p.setCwd(0, tmp); - var host: FakeTtyQuery = .{}; - host.install(p); - host.taken[0] = true; - look.lookAt(p, 0, tmp); - - var spawned = false; - while (p.nextEffect()) |effect| switch (effect) { - .write => |w| if (w.pane == 0) return error.TypedLsIntoTheProgramOnTheTty, - .spawn => spawned = true, - else => {}, - }; - try std.testing.expect(spawned); - - // ...and the same look reuses that very pane once its program is gone: the - // core keeps no state of its own about it, so recovery needs nothing reset - host.taken[0] = false; - look.lookAt(p, 0, tmp); - var sent: [64]u8 = undefined; - var sent_len: usize = 0; - while (p.nextEffect()) |effect| switch (effect) { - .write => |w| { - try std.testing.expectEqual(@as(u8, 0), w.pane); - try std.testing.expect(w.bytes.slice().len <= sent.len - sent_len); - @memcpy(sent[sent_len..][0..w.bytes.slice().len], w.bytes.slice()); - sent_len += w.bytes.slice().len; - }, - .spawn => return error.SpawnedDespiteAFreeTerminalOnTheDirectory, - else => {}, - }; - try std.testing.expectEqualStrings("ls\r", sent[0..sent_len]); - try std.testing.expectEqual(@as(usize, 0), p.active); -} - test "a terminal its program gave back takes command lines again" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{}); @@ -4054,8 +3929,8 @@ pub const Pardes = struct { chord_hold: bool = false, /// The look just run found nothing (look.zig missed). look_missed: bool = false, - /// The look being run opens a .diff or .patch as text whatever DiffLook - /// says: Diff going back from a +Diff, Edit's B (it edits the file). + /// The look being run opens a .diff or .patch as text, not its +Diff: + /// Diff going back from a +Diff, Edit's B (it edits the file). look_text: bool = false, look_hover_wait: ?look.LookHoverWait = null, /// The place a look-hover last found nothing to open: the pointer @@ -8057,7 +7932,6 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); defer p.deinit(); - p.settings.placement = .pardes; // the neighbours below are what is under test var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const top = p.active; @@ -8086,14 +7960,14 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { try std.testing.expectEqual(low, p.active); // focus follows the rows // Esc takes the question back and the pane stays; so does any other key, - // and so does a click. (Top gets rows back first: split at its cursor, - // it kept its tag and two, too few to give a pane below its own.) - p.panes[top].?.vweight = p.panes[low].?.vweight; + // and so does a click. A New goes to the column's foot, under low, which + // is between two again. + p.newScratchBelow(low); + const foot = p.active; + const again = low; + p.active = again; p.sync(); - p.newScratchBelow(top); - const again = p.active; - p.sync(); - h = .{ p.rects[top].h, p.rects[again].h, p.rects[low].h }; + h = .{ p.rects[top].h, p.rects[again].h, p.rects[foot].h }; try std.testing.expect(p.executeBuiltinLine(again, "Msg keep")); for ([_]Key{ .{ .cp = Key.escape }, .{ .cp = 'x' } }) |answer| { p.update(.{ .key = .{ .cp = ' ' } }); @@ -8122,14 +7996,16 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { try std.testing.expect(p.panes[again] == null); try std.testing.expectEqual(h[0] + h[1], p.rects[top].h); try std.testing.expectEqual(top, p.active); - try std.testing.expectEqual(h[2], p.rects[low].h); + try std.testing.expectEqual(h[2], p.rects[foot].h); // A script answers the question on the pane's ctl, as the log's `ask` // names it: `answer -` takes it back, a side closes the pane toward it. + p.newScratchBelow(foot); + const tail = p.active; { const th = @import("ninep/testing.zig"); - p.newScratchBelow(top); - const asked = p.active; + const asked = foot; + p.active = asked; p.sync(); const serial = p.panes[asked].?.serial; const ctl = ctlfs.Node.of(serial, .ctl); @@ -8152,20 +8028,21 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" { // Bare Del from anything but a key closes at once and gives the rows up, // as it always has. - p.newScratchBelow(top); - const third = p.active; + p.newScratchBelow(tail); + const last = p.active; + const third = tail; p.sync(); - h = .{ p.rects[top].h, p.rects[third].h, p.rects[low].h }; + h = .{ p.rects[top].h, p.rects[third].h, p.rects[last].h }; try std.testing.expect(p.executeBuiltinLine(third, "Del")); p.sync(); try std.testing.expect(p.panes[third] == null); try std.testing.expectEqual(h[0] + h[1], p.rects[top].h); // With nothing open below, there is nothing to ask: SPC d closes at once. - p.active = low; + p.active = last; p.update(.{ .key = .{ .cp = ' ' } }); p.update(.{ .key = .{ .cp = 'd' } }); - try std.testing.expect(p.panes[low] == null); + try std.testing.expect(p.panes[last] == null); } test "the bare tty startup opens a text pane under the shell, unfocused" { @@ -8298,7 +8175,6 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se if (platform == .web) return; const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 }); defer p.deinit(); - p.settings.placement = .pardes; var frame = std.heap.ArenaAllocator.init(std.testing.allocator); defer frame.deinit(); const top = p.active; |
