diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-09 00:37:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-09 01:28:28 -0300 |
| commit | 4c4b9bf54d77dbc0f9f4e2619746908e501c6001 (patch) | |
| tree | 457f82861e13ae95ab8d46ab04db93bcc0ca0e0b /src/gui | |
| parent | 174e031985db910b4907ba324d6fd12c67898a5a (diff) | |
| download | pardes-4c4b9bf54d77dbc0f9f4e2619746908e501c6001.tar.gz pardes-4c4b9bf54d77dbc0f9f4e2619746908e501c6001.zip | |
tests: the gui goldens go (test/gui-goldens.txt, the gui-golden step, window.zig's scenes case): their 15 frame hashes were this machine's; what they caught the kept set catches, checked break by break: the core's primary selection drawn as a secondary one (6 frames) fails 12 tty cases, the grip's focus fill and its button a pixel narrow (all 15) fail "every pixel of a grip column is band, button or ring", the theme's rules a pixel wider (all 15) fail "an empty column is ruled on both sides" and "decor is read from the regions"; two caught by the frames alone get unit tests of their own in gui.zig, the scrollbar thumb a pixel narrower (all 15) and the block cursor not reversed (9 frames); breaks the frames never saw (the body's clip and its context border, InactiveDim's fade, an image's scissor, fit and placed rect, the palette, the glyph art) stay the unit tests' and the image harness's or nobody's, as before
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/gui')
| -rw-r--r-- | src/gui/gui.zig | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gui/gui.zig b/src/gui/gui.zig index f4424520..b7ba1fb7 100644 --- a/src/gui/gui.zig +++ b/src/gui/gui.zig @@ -5795,6 +5795,22 @@ test "concealed terminal text emits no ink on its ground" { try std.testing.expectEqual(bg_default, resolved.bg); } +test "a block cursor's cell is drawn reversed: the cell's ink its ground, its ground its ink" { + var g = testGui(10, 20, 6, 12); + // A blank, so no glyph is looked up in this atlas-less Gui. + const cell: pardes.Cell = .{ + .text = .{ ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, + .len = 1, + .default = false, + .style = .{ .fg = .{ .rgb = .{ 10, 20, 30 } }, .bg = .{ .rgb = .{ 200, 210, 220 } } }, + }; + const plain = resolveCell(&g, (&cell)[0..1], 0, null, .body, false, bg_default); + const cursor = resolveCell(&g, (&cell)[0..1], 0, 0, .body, true, bg_default); + try std.testing.expectEqual([3]u8{ 10, 20, 30 }, plain.fg); + try std.testing.expectEqual(plain.fg, cursor.bg); + try std.testing.expectEqual(plain.bg, cursor.fg); +} + fn cellInstanceCount(cell: *const pardes.Cell) u32 { return if (cellFontRole(cell) == .tagline) 2 else 1; } @@ -7942,6 +7958,29 @@ test "the scrollbar thumb moves by the pixel and follows a glide" { try std.testing.expectApproxEqAbs(at10, try thumb.top(&g, core), 1e-3); } +test "the scrollbar thumb lies in its scroll column, a pixel short of the column's right edge, so the track edges it" { + const gpa = std.testing.allocator; + const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); + defer core.deinit(); + _ = try core.setTestFile(std.mem.asBytes(&@as([1000][5]u8, @splat("line\n".*)))); + var g = testGui(10, 20, 6, 12); + defer g.decor.deinit(gpa); + core.sync(); + const s = try core.render(core.scratch.allocator()); + var groups: Groups = .{}; + try buildDecor(&g, gpa, s, &groups, fixedCellLayout(&g), 800, 480, true); + const ink = s.chrome.scroll_thumb; + const thumb = for (g.decor.items) |item| { + if (@abs(item.br - @as(f32, @floatFromInt(ink[0])) / 255) < 1e-3 and + @abs(item.bg - @as(f32, @floatFromInt(ink[1])) / 255) < 1e-3 and + @abs(item.bb - @as(f32, @floatFromInt(ink[2])) / 255) < 1e-3) break item; + } else return error.TestExpectedThumb; + // The pane is the window's first: its scroll column is at cell 0. + const column = scrollColumn(&g, &s.chrome, 0, fixedCellLayout(&g)); + try std.testing.expectApproxEqAbs(column[0], (thumb.x0 + 1) / 2 * 800, 1e-3); + try std.testing.expectApproxEqAbs(column[1] - 1, (thumb.x1 + 1) / 2 * 800, 1e-3); +} + test "the rule between stacked panes stays in the tag band's slack, at any tagline size" { const gpa = std.testing.allocator; const core = try pardes.Pardes.init(gpa, .{ .cols = 80, .rows = 24 }); |
