summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 10:45:49 -0300
committerGabriel Schneider <[email protected]>2026-11-04 10:48:35 -0300
commita0ec419725ebb4094d811f5206eb0d95bbc5add0 (patch)
treefddf0fd9e4bd3e6861348133bbb71c315ad4206c /src/pardes.zig
parent52bfa3f2aa8f8158d4d7ca720d81ea0c654f94bf (diff)
downloadpardes-a0ec419725ebb4094d811f5206eb0d95bbc5add0.tar.gz
pardes-a0ec419725ebb4094d811f5206eb0d95bbc5add0.zip
test: src/pardes.zig's three window-mode tests through the 9P tree alone, in test/behaviour/modes.zig (guide.typ's Modes): Ctrl-w outlining the pane with the keyboard (its tag in the outline's colour, each box its letter), h j k l moving only the outline, Enter, Esc (after SPC w), : (its tag the keyboard's) and a letter giving a pane the keyboard, other keys changing nothing; d deleting the outlined pane (between two it waits for k or j, Esc taking it back; the rows and the outline going to the pane that took them, one neighbour closing at once), c collapsing and restoring it (the ctl read's collapsed), the mode staying on until Enter; window keys walking from the top pane up to its column's tag (normal mode, w moving its caret), across columns and back to the caret it had, up to the workspace tag, down again, and : back to the body; each checked to fail against a break (h j k l moving the keyboard too, a letter choosing nothing, the outline's tint not painted, the outline dropped after d, c not collapsing, k past a column's top pane doing nothing)
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.zig151
1 files changed, 0 insertions, 151 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 70bcf7c9..ba09b3b6 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -3133,45 +3133,6 @@ test "s in a header selects in the header's own text" {
try std.testing.expectEqual(@as(u16, 0), pane.body.nsel);
}
-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();
- _ = try p.setTestFile("body\n");
- p.newColumn(0);
- p.newScratchIn(0, p.activeColumn().?);
- p.sync();
- p.active = p.col_panes[0][0];
- const window = struct {
- fn key(core: *Pardes, letter: u21) void {
- core.update(.{ .key = .{ .cp = 'w', .ctrl = true } });
- core.update(.{ .key = .{ .cp = letter } });
- }
- };
- // Up from the top pane: its column's tag, in normal mode; `:` there is
- // the way back to the body.
- window.key(p, 'k');
- try std.testing.expect(p.header_focus and p.header_column.? == 0);
- try std.testing.expectEqual(Text.Mode.normal, p.col_tags[0].mode);
- p.update(.{ .key = .{ .cp = 'w' } });
- try std.testing.expect(p.col_tags[0].cur_col > 0);
- const remembered = p.col_tags[0].cur_col;
- window.key(p, 'l');
- try std.testing.expect(p.header_focus and p.header_column.? == 1);
- window.key(p, 'h');
- try std.testing.expectEqual(remembered, p.col_tags[0].cur_col);
- window.key(p, 'k');
- try std.testing.expect(p.header_focus and p.header_column == null);
- window.key(p, 'j');
- try std.testing.expect(p.header_focus and p.header_column.? == 0);
- window.key(p, 'j');
- try std.testing.expect(!p.header_focus);
- try std.testing.expectEqual(p.col_panes[0][0], p.active);
- window.key(p, 'k');
- p.update(.{ .key = .{ .cp = ':' } });
- try std.testing.expect(!p.header_focus and p.panes[p.active].?.focus == .body);
- try std.testing.expectEqualStrings("body\n", p.panes[0].?.file.?.content);
-}
-
pub const Mouse = struct {
/// The host has inverted a compact body layer. Physical col/row still
/// route pane chrome; these coordinates address the pane's logical text.
@@ -8409,63 +8370,6 @@ test "with ProgramEsc raw tty Escape only leaves at a shell prompt" {
try std.testing.expectEqual(Text.Mode.tty, pane.body.mode);
}
-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();
- _ = try p.setTestFile("left\n");
- _ = try p.newShell(1, "");
- try std.testing.expect(layout.splitColumn(p, 0, 1, false));
- p.newScratchBelow(1);
- p.sync();
- const lower = for (p.panes, 0..) |slot, id| {
- if (slot != null and id > 1) break id;
- } else return error.TestExpectedScratch;
- p.active = 0;
- // Ctrl-w enters it; h/j/k/l move only the outline.
- p.update(.{ .key = .{ .cp = 'w', .ctrl = true } });
- try std.testing.expectEqual(@as(?usize, 0), p.window_pick);
- p.update(.{ .key = .{ .cp = 'l', .text = "l" } });
- try std.testing.expect(p.window_pick != null and p.window_pick.? != 0);
- p.update(.{ .key = .{ .cp = 'j', .text = "j" } });
- try std.testing.expectEqual(@as(?usize, lower), p.window_pick);
- try std.testing.expectEqual(@as(usize, 0), p.active);
- p.update(.{ .key = .{ .cp = Key.enter } });
- try std.testing.expectEqual(lower, p.active);
- try std.testing.expect(p.window_pick == null);
- // SPC w enters it too, and Esc also leaves it on the outlined pane.
- p.update(.{ .key = .{ .cp = ' ', .text = " " } });
- p.update(.{ .key = .{ .cp = 'w', .text = "w" } });
- p.update(.{ .key = .{ .cp = 'h', .text = "h" } });
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
- try std.testing.expect(p.window_pick == null);
- // Other keys change nothing.
- p.update(.{ .key = .{ .cp = 'w', .ctrl = true } });
- p.update(.{ .key = .{ .cp = '!', .text = "!" } });
- try std.testing.expectEqual(@as(?usize, 0), p.window_pick);
- p.update(.{ .key = .{ .cp = Key.escape } });
- // `:` focuses the outlined pane's tag.
- p.update(.{ .key = .{ .cp = 'w', .ctrl = true } });
- p.update(.{ .key = .{ .cp = 'l', .text = "l" } });
- p.update(.{ .key = .{ .cp = ':', .text = ":" } });
- try std.testing.expect(p.active != 0 and p.panes[p.active].?.focus == .tag);
- p.update(.{ .key = .{ .cp = Key.escape } });
- // A label goes straight there: the left column's pane is "a".
- try std.testing.expectEqual(@as(?u8, 'a'), layout.windowLabel(p, 0));
- try std.testing.expect(p.executeBuiltinLine(p.active, "Window"));
- p.update(.{ .key = .{ .cp = 'a', .text = "a" } });
- try std.testing.expectEqual(@as(usize, 0), p.active);
- // Painted: the outlined tag's band in the selection colour, each pane's
- // letter in its tag's box.
- try std.testing.expect(p.executeBuiltinLine(p.active, "Window"));
- var arena: std.heap.ArenaAllocator = .init(std.testing.allocator);
- defer arena.deinit();
- const shown = try p.render(arena.allocator());
- try std.testing.expectEqual(p.theme().sel_bg, shown.tag_layers[0].bg);
- const box = shown.at(p.rects[0].x, p.tagTop(p.panes[0].?, p.rects[0]));
- try std.testing.expectEqualStrings("a", box.text[0..box.len]);
-}
-
test "the Del question shows only once its delay is up: a quick SPC d j never sees it" {
if (platform == .web) return;
const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 80, .rows = 40 });
@@ -8516,61 +8420,6 @@ test "the Del question shows only once its delay is up: a quick SPC d j never se
try std.testing.expect(p.panes[mid] == null);
}
-test "window mode d deletes the outlined pane and asks k or j, c collapses it, and the mode stays" {
- 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
- const top = p.active;
- p.newScratchBelow(top);
- const mid = p.active;
- p.newScratchBelow(mid);
- const low = p.active;
- p.sync();
- const h = [_]u16{ p.rects[top].h, p.rects[mid].h, p.rects[low].h };
- // Neither key is a pane's label.
- try std.testing.expect(std.mem.indexOfAny(u8, layout.window_labels, "hjkldc") == null);
-
- // Ctrl-w from the bottom pane, the outline up to the middle one.
- p.update(.{ .key = .{ .cp = 'w', .ctrl = true } });
- p.update(.{ .key = .{ .cp = 'k', .text = "k" } });
- try std.testing.expectEqual(@as(?usize, mid), p.window_pick);
- // c folds the outlined pane to its tag and back, the mode staying.
- p.update(.{ .key = .{ .cp = 'c', .text = "c" } });
- try std.testing.expect(p.panes[mid].?.collapsed);
- try std.testing.expectEqual(@as(?usize, mid), p.window_pick);
- p.update(.{ .key = .{ .cp = 'c', .text = "c" } });
- try std.testing.expect(!p.panes[mid].?.collapsed);
- p.sync();
- try std.testing.expectEqual(h[1], p.rects[mid].h);
-
- // d with panes above and below asks, as SPC d does; Esc takes it back
- // and the outline stays where it was.
- p.update(.{ .key = .{ .cp = 'd', .text = "d" } });
- try std.testing.expectEqual(Pane.Prompt.del_side, p.panes[mid].?.prompt);
- p.update(.{ .key = .{ .cp = Key.escape } });
- try std.testing.expect(p.panes[mid] != null and p.panes[mid].?.prompt == .none);
- try std.testing.expectEqual(@as(?usize, mid), p.window_pick);
- // j: the pane below takes the rows, and the outline goes with them.
- p.update(.{ .key = .{ .cp = 'd', .text = "d" } });
- p.update(.{ .key = .{ .cp = 'j', .text = "j" } });
- p.sync();
- try std.testing.expect(p.panes[mid] == null);
- try std.testing.expectEqual(h[0], p.rects[top].h);
- try std.testing.expectEqual(h[1] + h[2], p.rects[low].h);
- try std.testing.expectEqual(@as(?usize, low), p.window_pick);
- // With one neighbour there is nothing to ask: d closes it at once,
- // the outline on the pane that grew.
- p.update(.{ .key = .{ .cp = 'd', .text = "d" } });
- p.sync();
- try std.testing.expect(p.panes[low] == null);
- try std.testing.expectEqual(@as(?usize, top), p.window_pick);
- // Enter leaves the mode on it.
- p.update(.{ .key = .{ .cp = Key.enter } });
- try std.testing.expect(p.window_pick == null);
- try std.testing.expectEqual(top, p.active);
-}
-
test "raw tty Ctrl-B switches to editor mode without sending child input" {
if (platform == .web) return;
const p = try Pardes.init(std.testing.allocator, .{ .file = "mise.toml" });