diff options
Diffstat (limited to 'src/draw.zig')
| -rw-r--r-- | src/draw.zig | 97 |
1 files changed, 45 insertions, 52 deletions
diff --git a/src/draw.zig b/src/draw.zig index ac13fc7d..ce5f86c1 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -1040,27 +1040,24 @@ test "a tag of three rows has its grip on the first, and band under it that stil pane.tag.own = try std.testing.allocator.dupe(u8, "Second\nthird\nfourth"); var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - p.sync(); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - const r = p.rects[0]; - const top = p.tagTop(pane, r); - try std.testing.expect(pane.tag_rows >= 3); - const chrome = p.chromeTheme(); - const band = if (p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; - for (0..config.GUTTER) |dx| { - const x = r.x + @as(u16, @intCast(dx)); - try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg); - for (1..pane.tag_rows) |line| { - const cell = s.at(x, top + @as(u16, @intCast(line))); - try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg); - try std.testing.expectEqualStrings(" ", cell.grapheme()); - } + p.sync(); + _ = arena.reset(.retain_capacity); + const s = try p.render(arena.allocator()); + const r = p.rects[0]; + const top = p.tagTop(pane, r); + try std.testing.expect(pane.tag_rows >= 3); + const chrome = p.chromeTheme(); + const band = if (p.settings.focus_tint) chrome.tag_active_bg else chrome.tag_bg; + for (0..config.GUTTER) |dx| { + const x = r.x + @as(u16, @intCast(dx)); + try std.testing.expectEqual(Color{ .rgb = chrome.box }, s.at(x, top).style.bg); + for (1..pane.tag_rows) |line| { + const cell = s.at(x, top + @as(u16, @intCast(line))); + try std.testing.expectEqual(Color{ .rgb = band }, cell.style.bg); + try std.testing.expectEqualStrings(" ", cell.grapheme()); } - try std.testing.expectEqual(pane.tag_rows, s.region(.grip, 0).?.rect.h); } + try std.testing.expectEqual(pane.tag_rows, s.region(.grip, 0).?.rect.h); } test "place puts every part where the painters and layers put it, in every layout" { @@ -1074,7 +1071,6 @@ test "place puts every part where the painters and layers put it, in every layou var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); for (0..16) |step| { - p.settings.tag_bottom = step & 1 != 0; if (step & 4 != 0) try std.testing.expect(p.executeBuiltinLine(p.active, "Msg a placed notice")); if (step == 8) try std.testing.expect(p.executeBuiltinLine(1, "Collapse")); if (step == 12) try std.testing.expect(p.executeBuiltinLine(1, "Collapse")); @@ -1214,7 +1210,7 @@ test "a monkey over notices, prompts, tags and tiny panes at a gui's metrics nev var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); const words = [_][]const u8{ "error:", "\u{754c}", "x", "Shader /tmp/a.glsl:", "e\u{301}", "\t", std.mem.asBytes(&@as([20][5]u8, @splat("long-".*))), " " }; - const commands = [_][]const u8{ "New", "Newcol", "Collapse", "Tagbottom", "TreeContext", "Wrap", "Find", "Del", "FocusTint", "Debug" }; + const commands = [_][]const u8{ "New", "Newcol", "Collapse", "TreeContext", "Wrap", "Find", "Del", "Debug" }; var text: std.ArrayListUnmanaged(u8) = .empty; defer text.deinit(std.testing.allocator); for (0..steps) |_| { @@ -1318,38 +1314,35 @@ test "a body with context rows is painted once, and the grid's rows are what a p pane.file.?.scroll = 8; var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); defer arena.deinit(); - for ([_]bool{ false, true }) |bottom| { - p.settings.tag_bottom = bottom; - // A selection and the cursor on body rows, painted in the one pass. - pane.body.cur_row = 12; - pane.body.cur_col = 3; - pane.body.vsel = .{ .active = true, .row = 10, .col = 2 }; - pane.body.mode = .normal; - p.sync(); - _ = arena.reset(.retain_capacity); - const s = try p.render(arena.allocator()); - const layer = &s.body_layers[0]; - try std.testing.expect(layer.context_rows > 0); - const body = s.region(.body, 0).?; - // The plain paint the grid used to take, of the same frame. - const cells = try arena.allocator().alloc(Cell, s.cells.len); - @memset(cells, .{}); - var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells }; - pane.view.layered = false; - try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null); - pane.view.layered = true; - for (0..body.rect.h) |row| { - const y = body.rect.y + row; - for (0..body.rect.w) |col| { - const x = body.rect.x + col; - const got = s.cells[y * s.cols + x]; - const want = plain.cells[y * s.cols + x]; - try std.testing.expect(got.visuallyEqual(&want)); - } + // A selection and the cursor on body rows, painted in the one pass. + pane.body.cur_row = 12; + pane.body.cur_col = 3; + pane.body.vsel = .{ .active = true, .row = 10, .col = 2 }; + pane.body.mode = .normal; + p.sync(); + _ = arena.reset(.retain_capacity); + const s = try p.render(arena.allocator()); + const layer = &s.body_layers[0]; + try std.testing.expect(layer.context_rows > 0); + const body = s.region(.body, 0).?; + // The plain paint the grid used to take, of the same frame. + const cells = try arena.allocator().alloc(Cell, s.cells.len); + @memset(cells, .{}); + var plain: Surface = .{ .cols = s.cols, .rows = s.rows, .cells = cells }; + pane.view.layered = false; + try body_layer.renderBody(p, &plain, arena.allocator(), pane, p.rects[0], 0, true, null); + pane.view.layered = true; + for (0..body.rect.h) |row| { + const y = body.rect.y + row; + for (0..body.rect.w) |col| { + const x = body.rect.x + col; + const got = s.cells[y * s.cols + x]; + const want = plain.cells[y * s.cols + x]; + try std.testing.expect(got.visuallyEqual(&want)); } - try std.testing.expectEqual(plain.cursor, s.cursor); - // The layer's own rows run past the grid's. - try std.testing.expect(layer.rows > body.rect.h); } + try std.testing.expectEqual(plain.cursor, s.cursor); + // The layer's own rows run past the grid's. + try std.testing.expect(layer.rows > body.rect.h); } |
