diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 10:28:16 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 10:42:43 -0300 |
| commit | 52bfa3f2aa8f8158d4d7ca720d81ea0c654f94bf (patch) | |
| tree | baa2c90f77caac09fe27fb5c6d07997d78628fb2 /src | |
| parent | f697bb13c3599db3ce30fac059932242597acdf6 (diff) | |
| download | pardes-52bfa3f2aa8f8158d4d7ca720d81ea0c654f94bf.tar.gz pardes-52bfa3f2aa8f8158d4d7ca720d81ea0c654f94bf.zip | |
test: three of src/pardes.zig's tests through the 9P tree alone: in test/behaviour/columns_and_tags.zig a column tag lighting the word under the mouse, taking the caret where pressed, sweeping three cells in the selection's colour, typed at its caret (Home, Help) and scrolling its text from the column's edge, never its caret (each column); in test/behaviour/mouse.zig a click on either half of a wide character landing before it in the text (dot) and on a tag's path (a name drafted, Right stepping a grapheme, two cells then one), a two-byte λ typed in a tag and taken out by one backspace, and a sweep pressed on the line numbers taking only the text (unlit numbers, a Look in it finding its next place, a chord cutting it); Session's bg (a cell's background from /screen's styles); each checked to fail against a break (no tag hover, the header scrolled one cell too far, byteAtDisplay rounding a wide glyph's second half past it, Right stepping a byte in insert, the three clamps that keep a sweep's first row off the line numbers dropped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src')
| -rw-r--r-- | src/pardes.zig | 112 |
1 files changed, 0 insertions, 112 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index b47119c4..70bcf7c9 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -2918,48 +2918,6 @@ test "every line of the board's boot buffer renders whole" { // ---- the boundary types ---- -test "Unicode display cells map back to body and tag byte cursors" { - const gpa = std.testing.allocator; - const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 }); - defer p.deinit(); - const pane = try p.setTestFile("a界e\u{301}z\n"); - const f = &pane.file.?; - p.gpa.free(f.path); - f.path = try p.gpa.dupe(u8, "界e\u{301}.txt"); - - var frame = std.heap.ArenaAllocator.init(gpa); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - const rect = p.rects[0]; - const text_x = rect.x + config.GUTTER + config.PREFIX_W; - const body_y = rect.y + BOX_H; - // The second screen cell is the trailing half of the wide CJK grapheme. - // Both halves map to its one byte boundary. - p.update(.{ .mouse = .{ .button = config.select_button, .kind = .press, .col = text_x + 2, .row = body_y } }); - p.update(.{ .mouse = .{ .button = config.select_button, .kind = .release, .col = text_x + 2, .row = body_y } }); - try std.testing.expectEqual(@as(i32, 1), pane.body.cur_col); - - // A click in the wide path glyph drafts a name with its caret at the - // grapheme start; arrow motion then advances by the full UTF-8 cluster. - tagline.draftName(p, pane, 1); - try std.testing.expectEqual(@as(i32, 0), pane.input.cur_col); - edit.insertKey(p, &pane.input, .{ .cp = Key.right }); - try std.testing.expectEqual(@as(i32, 3), pane.input.cur_col); - edit.insertKey(p, &pane.input, .{ .cp = Key.right }); - try std.testing.expectEqual(@as(i32, 6), pane.input.cur_col); - pane.closePrompt(); - - const before = try gpa.dupe(u8, tagline.curTail(pane)); - defer gpa.free(before); - tagline.enterTag(p, pane); - const insertion = pane.tag.cur_col; - edit.insertKey(p, &pane.tag, .{ .cp = 'λ', .text = "λ" }); - try std.testing.expectEqual(insertion + 2, pane.tag.cur_col); - edit.insertKey(p, &pane.tag, .{ .cp = Key.backspace }); - try std.testing.expectEqual(insertion, pane.tag.cur_col); - try std.testing.expectEqualStrings(before, tagline.curTail(pane)); -} - test "Tab N draws every pane's tab N cells wide and clicks count past it; bare Tab says the width; the ctl read and a Dump keep it" { const gpa = std.testing.allocator; const p = try Pardes.init(gpa, .{ .cols = 60, .rows = 12 }); @@ -3106,63 +3064,6 @@ test "editable workspace and column tags are typed into and persist" { try std.testing.expectEqualStrings("", tagline.columnTag(empty, 0)); } -test "column tags render edit hover and scroll from the column edge" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20, .tty_only = true }); - defer p.deinit(); - _ = try p.setTestFile("untouched\n"); - p.newColumn(0); - p.newScratchIn(0, p.activeColumn().?); - p.sync(); - p.acknowledgePanelPresentation(&.{}); - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - for (0..p.ncol) |column| { - const x = p.col_x[column] + TAG_TEXT_INSET; - const width = p.col_w[column] - TAG_TEXT_INSET; - const initial = try p.render(frame.allocator()); - for ("New", 0..) |byte, offset| - try std.testing.expectEqual(byte, initial.at(x + @as(u16, @intCast(offset)), TOPBAR_H).text[0]); - p.update(.{ .mouse = .{ .button = .none, .kind = .motion, .col = x, .row = TOPBAR_H } }); - const hovered = try p.render(frame.allocator()); - try std.testing.expectEqual(Color{ .rgb = p.theme().sel_bg }, hovered.at(x, TOPBAR_H).style.bg); - p.update(.{ .mouse = .{ .button = .left, .kind = .press, .col = x, .row = TOPBAR_H } }); - try std.testing.expectEqual(column, p.header_column.?); - try std.testing.expectEqual(@as(i32, 0), tagline.focusedHeader(p).?.cur_col); - const at_start = try p.render(frame.allocator()); - try std.testing.expectEqual(x, at_start.cursor.?.x); - p.update(.{ .mouse = .{ .button = .left, .kind = .drag, .col = x + 3, .row = TOPBAR_H } }); - p.update(.{ .mouse = .{ .button = .left, .kind = .release, .col = x + 3, .row = TOPBAR_H } }); - const selected = try p.render(frame.allocator()); - for (0..3) |offset| - try std.testing.expectEqual(Color{ .rgb = p.theme().sel_bg }, selected.at(x + @as(u16, @intCast(offset)), TOPBAR_H).style.bg); - p.update(.{ .key = .{ .cp = Key.home } }); - p.update(.{ .key = .{ .cp = 'H', .text = "Help " } }); - try std.testing.expect(std.mem.startsWith(u8, tagline.columnTag(p, column), "Help New Tty")); - const edited = try p.render(frame.allocator()); - try std.testing.expectEqual(x + 5, edited.cursor.?.x); - // Only the text viewport participates in caret reveal. - const long: [80]u8 = @splat('a'); - if (p.col_tags[column].own) |own| p.gpa.free(own); - p.col_tags[column].own = try p.gpa.dupe(u8, long[0 .. width - 1]); - p.update(.{ .key = .{ .cp = Key.end } }); - const at_end = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), p.header_scroll); - try std.testing.expectEqual(x + width - 1, at_end.cursor.?.x); - p.update(.{ .key = .{ .cp = 'b', .text = "b" } }); - const revealed = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 1), p.header_scroll); - try std.testing.expectEqual(x + width - 1, revealed.cursor.?.x); - p.update(.{ .key = .{ .cp = Key.home } }); - const home = try p.render(frame.allocator()); - try std.testing.expectEqual(@as(usize, 0), p.header_scroll); - try std.testing.expectEqual(x, home.cursor.?.x); - p.update(.{ .key = .{ .cp = Key.escape } }); - p.update(.pointer_leave); - _ = frame.reset(.retain_capacity); - } - try std.testing.expectEqualStrings("untouched\n", p.panes[0].?.file.?.content); -} - test "column tag first-cell execution keeps New local to the clicked column" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 80, .rows = 20, .tty_only = true }); defer p.deinit(); @@ -9180,19 +9081,6 @@ test "board heap: every allocation failure during boot is a clean OutOfMemory" { ); } -test "a sweep pressed on the line numbers copies only the text" { - const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); - defer p.deinit(); - const pane = try p.setTestFile("alpha beta\ngamma delta\n"); - const numbers: i32 = panes.File.gutterWidth(pane); - const top: i32 = pane.tag_rows; - pane.sel[0] = .{ .state = .done, .c0 = 1, .c1 = numbers + 4, .r0 = top, .r1 = top + 1 }; - // Live, while the drag is held, and captured, once it is released. - try std.testing.expectEqualStrings("alpha beta\ngamma", try edit.selectionText(p, pane, pane.sel[0])); - try edit.capturePointerSelection(p, pane, 0); - try std.testing.expectEqualStrings("alpha beta\ngamma", try edit.selectionText(p, pane, pane.sel[0])); -} - test "jump history clears selections and lands at the recorded cursor" { const p = try Pardes.init(std.testing.allocator, .{ .cols = 60, .rows = 12 }); defer p.deinit(); |
