diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 151 |
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" }); |
