summaryrefslogtreecommitdiff
path: root/src/gui/gui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/gui.zig')
-rw-r--r--src/gui/gui.zig39
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 });