summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-03 17:09:53 -0300
committerGabriel Schneider <[email protected]>2026-11-03 17:17:31 -0300
commit5cc02232d522d5cd5a453caedd1e592ca20471ea (patch)
tree034d370ad6eed53abb27f2c7ff607f8e656b17c8 /src/pardes.zig
parent37408da299e21b8807ccd10545482a709bac88c7 (diff)
downloadpardes-5cc02232d522d5cd5a453caedd1e592ca20471ea.tar.gz
pardes-5cc02232d522d5cd5a453caedd1e592ca20471ea.zip
test: eleven more of src/pardes.zig's tests through the 9P tree alone (test/behaviour/columns_and_tags, modes, tags, panes): a click past a column tag's text typing after it, a newline there a space and a long tag scrolled to its caret, Enter and Tab in a tag running the word under the cursor, Esc alternating two panes of a kind, Esc out of a column or the workspace tag, Shift-Esc out of every mode, a name typed into the tag's path pending past Esc, an unsaved file's tag its name alone, a question ended in the log when its pane closes, focus on a closed pane to the one taking its place; Session's cursor (/screen's); each checked to fail against a break (flatten keeping newlines, the header drawn unscrolled, Enter in a header a Look, Esc in normal mode not running Last, Esc in a header not leaving it, Shift-Esc leaving insert on, the first Esc on a drafted name dropping it, a dirty tag marked ' *', del_side left out of noteRetire's answer, removeColumn's focus to any pane)
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.zig231
1 files changed, 0 insertions, 231 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index ea8b52df..3d29dfcd 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -1462,21 +1462,6 @@ test "dragging a column's only pane to another leaves that column in place, empt
try std.testing.expectEqual(@as(usize, 1), p.col_n[0]);
}
-test "an unsaved file's tag is its name alone: the grip, not a mark, says it is unsaved" {
- const gpa = std.testing.allocator;
- const p = try Pardes.init(gpa, .{ .tty_only = true, .cols = 100, .rows = 30 });
- defer p.deinit();
- while (p.nextEffect()) |_| {}
- const pane = try p.setTestFile("before\n");
- const clean = try tagline.tagText(p, p.scratch.allocator(), pane);
- panes.File.setContent(p, &pane.file.?, try gpa.dupe(u8, "after\n"));
- const dirty = try tagline.tagText(p, p.scratch.allocator(), pane);
- try std.testing.expectEqualStrings(clean, dirty);
- try std.testing.expect(std.mem.indexOf(u8, dirty, " *") == null);
- // The dirty file and index's flag still say it.
- try std.testing.expect(ctlfs.pane.dirtyOf(pane));
-}
-
test "unknown Exec from a document runs as a command pane in its directory, typed into no terminal" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{});
@@ -3180,33 +3165,6 @@ fn pardes_ctlfs_ctlText(p: *Pardes, pane: *Pane) []const u8 {
return th.rd(p, ctlfs.Node.of(pane.serial, .ctl), 0, 4096).bytes;
}
-test "a name typed into the tag's path survives Esc, pending, and the next Enter renames; a second Esc drops it" {
- const gpa = std.testing.allocator;
- const p = try Pardes.init(gpa, .{ .tty_only = true });
- defer p.deinit();
- const pane = try p.setTestFile("x\n");
- for ([_]bool{ true, false }) |enter| {
- tagline.enterTag(p, pane);
- pane.tag.mode = .insert;
- pane.tag.cur_row = 0;
- pane.tag.cur_col = 1;
- p.update(.{ .key = .{ .cp = 'z', .text = "z" } });
- try std.testing.expect(pane.prompt == .name);
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expect(pane.prompt == .name);
- // A stray key changes nothing while it waits.
- p.update(.{ .key = .{ .cp = 'q', .text = "q" } });
- if (enter) {
- p.update(.{ .key = .{ .cp = Key.enter } });
- try std.testing.expectEqualStrings("/ztest.txt", pane.file.?.path);
- } else {
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expect(pane.prompt != .name);
- try std.testing.expectEqualStrings("/ztest.txt", pane.file.?.path);
- }
- }
-}
-
test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 });
@@ -3389,43 +3347,6 @@ test "column tag first-cell execution keeps New local to the clicked column" {
try std.testing.expectEqualStrings("untouched\n", p.panes[0].?.file.?.content);
}
-test "header clicks beyond text append and long UTF-8 tags reveal their caret" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 12, .tty_only = true });
- defer p.deinit();
- _ = try p.setTestFile("body\n");
- p.col_tags[0].own = try p.gpa.dupe(u8, "New");
- p.acknowledgePanelPresentation(&.{});
- p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = 40, .row = TOPBAR_H } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = 40, .row = TOPBAR_H } });
- p.update(.{ .key = .{ .cp = 'x', .text = " extended" } });
- try std.testing.expectEqualStrings("New extended", tagline.columnTag(p, 0));
- p.update(.{ .paste = " 界界界界界界界界界界界界界界界界界界界界界界界界界界界界界界" });
- const frame = try p.render(p.scratch.allocator());
- try std.testing.expect(p.header_scroll > 0);
- try std.testing.expect(frame.cursor != null);
- try std.testing.expectEqual(TOPBAR_H, frame.cursor.?.y);
- try std.testing.expect(frame.cursor.?.x < p.screen_w);
- p.update(.{ .key = .{ .cp = Key.home } });
- _ = try p.render(p.scratch.allocator());
- try std.testing.expectEqual(@as(usize, 0), p.header_scroll);
-}
-
-test "a newline typed into a column tag is a space: the tag stays one row" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 50, .rows = 12, .tty_only = true });
- defer p.deinit();
- _ = try p.setTestFile("body\n");
- p.col_tags[0].own = try p.gpa.dupe(u8, "New");
- p.acknowledgePanelPresentation(&.{});
- p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = 40, .row = TOPBAR_H } });
- p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = 40, .row = TOPBAR_H } });
- p.update(.{ .key = .{ .cp = Key.enter } });
- p.update(.{ .key = .{ .cp = 'S', .text = "Snarf" } });
- _ = try p.render(p.scratch.allocator());
- try std.testing.expectEqualStrings("New Snarf", tagline.columnTag(p, 0));
- try std.testing.expectEqual(COLBAR_H, p.columnBarHeight());
- try std.testing.expectEqual(TOPBAR_H + COLBAR_H, p.rects[0].y);
-}
-
test "tiny screens keep pane space before adding a column tag" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 8, .rows = 2, .tty_only = true });
defer p.deinit();
@@ -3456,18 +3377,6 @@ test "a screen too short for the column row releases a column tag's focus withou
try std.testing.expectEqualStrings("unchanged body\n", pane.file.?.content);
}
-test "a header's execute key runs the word under its cursor and lets go of the keyboard first" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 12, .tty_only = true });
- defer p.deinit();
- _ = try p.setTestFile("body\n");
- tagline.enterHeader(p, null);
- p.global_tag.cur_col = @intCast(std.mem.indexOf(u8, config.topbar_str, "Dump").?);
- p.update(.{ .key = .{ .cp = Key.tab } });
- try std.testing.expect(!p.header_focus);
- try std.testing.expect(p.dump_out != null);
- try std.testing.expectEqual(@as(usize, 1), p.col_n[0]);
-}
-
test "s in a header selects in the header's own text" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 12, .tty_only = true });
defer p.deinit();
@@ -3487,20 +3396,6 @@ test "s in a header selects in the header's own text" {
try std.testing.expectEqual(@as(u16, 0), pane.body.nsel);
}
-test "Enter in a header runs the word under its cursor, as the execute key does" {
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 12, .tty_only = true });
- defer p.deinit();
- _ = try p.setTestFile("body\n");
- try std.testing.expectEqual(@as(usize, 1), p.ncol);
- tagline.enterHeader(p, null);
- p.global_tag.cur_col = @intCast(std.mem.indexOf(u8, config.topbar_str, "Newcol").?);
- p.update(.{ .key = .{ .cp = Key.enter } });
- try std.testing.expectEqual(@as(usize, 2), p.ncol);
- // and the workspace tag lets go of the keyboard: the new, empty
- // column's tag has it
- try std.testing.expect(p.header_focus and p.header_column.? == 1);
-}
-
test "window keys walk from a pane up through the column and workspace tags and back" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 100, .rows = 20, .tty_only = true });
defer p.deinit();
@@ -8272,31 +8167,6 @@ pub const Pardes = struct {
}
};
-test "Esc alternates between two panes of the SAME kind" {
- if (platform == .web) return;
- const gpa = std.testing.allocator;
- var cwdbuf: [4096]u8 = undefined;
- const cwd = std.mem.span(@as([*:0]u8, @ptrCast(std.c.getcwd(&cwdbuf, cwdbuf.len) orelse return)));
- var pathbuf: [4096]u8 = undefined;
- const boot = try std.fmt.bufPrint(&pathbuf, "{s}/mise.toml", .{cwd});
-
- const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 40, .file = boot });
- defer p.deinit();
- p.update(.{ .resize = .{ .cols = 80, .rows = 40 } });
- const a = p.active;
- exec.runBuiltin(p, .Look, a, "", "build.zig");
- p.sync();
- const b = p.active;
- try std.testing.expect(b != a);
- try std.testing.expect(!p.panes[a].?.isTerminal() and !p.panes[b].?.isTerminal());
-
- for (0..6) |_| {
- const was = p.active;
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expectEqual(if (was == a) b else a, p.active);
- }
-}
-
test "a boot file that will not open boots an errors pane rather than failing the launch" {
if (platform == .web) return;
const gpa = std.testing.allocator;
@@ -8676,49 +8546,6 @@ test "Del from a key asks which neighbour takes the rows; nothing else asks" {
try std.testing.expect(p.panes[low] == null);
}
-test "focus on a closed pane goes to the pane that takes its place, not the one focused before" {
- if (platform == .web) return;
- const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 40 });
- defer p.deinit();
- const shell = p.active;
- p.newColumn(shell);
- p.newScratchIn(shell, p.activeColumn().?);
- const right = p.active;
- p.sync();
- p.newScratchBelow(shell);
- const low = p.active;
- p.sync();
- // The dogfood case: `right` was focused just before `low`, but `shell`
- // grows into `low`'s rows, so `shell` gets the focus.
- try std.testing.expect(p.executeBuiltinLine(low, "Del"));
- p.sync();
- try std.testing.expect(p.panes[low] == null);
- try std.testing.expectEqual(shell, p.active);
-
- // Closing a pane that has no focus leaves the focus where it is.
- p.newScratchBelow(shell);
- const other = p.active;
- p.sync();
- p.active = right;
- p.sync();
- try std.testing.expect(p.executeBuiltinLine(other, "Del"));
- try std.testing.expectEqual(right, p.active);
-
- // Delcol: the column that takes the width holds, level with the closed
- // pane, the pane that takes its place; `right` was focused just before.
- p.newScratchBelow(right);
- const right_low = p.active;
- p.newScratchBelow(shell);
- const left_low = p.active;
- p.active = right;
- p.sync();
- p.active = left_low;
- p.sync();
- try p.removeColumn(layout.findPane(p, left_low).?.col);
- p.sync();
- try std.testing.expectEqual(right_low, p.active);
-}
-
test "the bare tty startup opens a text pane under the shell, unfocused" {
if (platform == .web) return;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .boot = .tty });
@@ -8892,43 +8719,6 @@ test "with ProgramEsc raw tty Escape only leaves at a shell prompt" {
try std.testing.expectEqual(Text.Mode.tty, pane.body.mode);
}
-test "Shift-Esc backs out to the previous pane in every mode, never into raw" {
- if (platform == .web) return;
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" });
- defer p.deinit();
- p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a shell under the doc
- const shell = p.active;
- const sp = p.panes[shell].?;
- // A terminal in normal mode: out, still normal, never raw.
- if (sp.body.mode == .tty) p.update(.{ .key = .{ .cp = 'b', .ctrl = true } });
- try std.testing.expectEqual(Text.Mode.normal, sp.body.mode);
- p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expectEqual(Text.Mode.normal, sp.body.mode);
- // A text pane in insert mode: out of insert, and out of the pane.
- const doc = p.panes[0].?;
- p.update(.{ .key = .{ .cp = 'i', .text = "i" } });
- try std.testing.expectEqual(Text.Mode.insert, doc.body.mode);
- p.update(.{ .key = .{ .cp = Key.escape, .shift = true } });
- try std.testing.expectEqual(Text.Mode.normal, doc.body.mode);
- try std.testing.expect(p.active != 0);
-}
-
-test "Esc in a column or the workspace tag gives the keyboard back to a pane, as Shift-Esc does" {
- if (platform == .web) return;
- const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 24, .file = "mise.toml" });
- defer p.deinit();
- p.update(.{ .key = .{ .cp = 'n', .alt = true } }); // a pane to go back to
- for ([_]?usize{ 0, null }) |column| {
- tagline.enterHeader(p, column);
- try std.testing.expect(tagline.focusedHeader(p) != null);
- const was = p.active;
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expect(tagline.focusedHeader(p) == null);
- try std.testing.expect(p.active != was);
- }
-}
-
test "window mode moves an outline and focuses it on Enter, Esc or a label" {
const p = try Pardes.init(std.testing.allocator, .{ .cols = 120, .rows = 30 });
defer p.deinit();
@@ -9870,27 +9660,6 @@ test "core animation keeps wall time at 60, 120 and 144 Hz and across a stall" {
try std.testing.expectEqual(@as(?u64, null), p.nextWake());
}
-test "a pane closed while its question stands ends the question in the log" {
- const th = @import("ninep/testing.zig");
- const p = try th.withFile(std.testing.allocator, "x\n");
- defer p.deinit();
- p.settings.placement = .pardes;
- p.newScratchBelow(0);
- const closing = p.active;
- p.newScratchBelow(closing);
- p.sync();
- p.active = closing; // a middle pane: Del from a key asks which side
- const serial = p.panes[closing].?.serial;
- p.update(.{ .key = .{ .cp = ' ' } });
- p.update(.{ .key = .{ .cp = 'd' } });
- try std.testing.expectEqual(Pane.Prompt.del_side, p.panes[closing].?.prompt);
- // A bare answer says what this question takes.
- try std.testing.expectEqualStrings("answer takes k j or -", th.wr(p, ctlfs.Node.of(serial, .ctl), "answer\n").reply.ename);
- try p.removePane(closing, null);
- var want: [64]u8 = undefined;
- try std.testing.expect(th.logHas(p, try std.fmt.bufPrint(&want, "answer {d} -\ndel {d}", .{ serial, serial })));
-}
-
test "a Save the host could not do logs no save record" {
const th = @import("ninep/testing.zig");
const p = try th.withFile(std.testing.allocator, "x\n");