diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 20:49:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:17 -0300 |
| commit | 9554cc4c544632b01f740f895fd6db9f9952c02e (patch) | |
| tree | 2ebaa76540793610027e80968c30df9ecb2d9159 /src/draw.zig | |
| parent | bed515689a5e09ed704de9206877ec7c0a32ab3a (diff) | |
| parent | c63b7915530c327571ebfc55389a31ed54153198 (diff) | |
| download | pardes-9554cc4c544632b01f740f895fd6db9f9952c02e.tar.gz pardes-9554cc4c544632b01f740f895fd6db9f9952c02e.zip | |
Merge: renames/folds + tagline accents for every theme
Diffstat (limited to 'src/draw.zig')
| -rw-r--r-- | src/draw.zig | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/draw.zig b/src/draw.zig index 9c9e11dd..10303117 100644 --- a/src/draw.zig +++ b/src/draw.zig @@ -1477,6 +1477,60 @@ test "a grip's four states, focused or not and clean or dirty, are each its own pane.file.?.revision = pane.file.?.saved_revision; } +test "every theme draws a file's name, a +Errors and a Tty word in a tint, never the tag's plain ink" { + const gpa = std.testing.allocator; + const p = try Pardes.init(gpa, .{ .cols = 120, .rows = 40, .tty_only = true }); + defer p.deinit(); + _ = try p.setTestFile("text\n"); + try std.testing.expect(p.executeBuiltinLine(0, "Tty+sh")); + const terminal = p.active; + p.acknowledgeShell(terminal, "/bin/sh", false); + try @import("Output.zig").openErrors(p, 0, try gpa.dupe(u8, "oops\n")); + while (p.nextEffect()) |_| {} + p.animate_theme_changes = false; + const errors = for (p.panes, 0..) |slot, id| { + const pane = slot orelse continue; + if (pane.file) |f| if (std.mem.endsWith(u8, f.path, "+Errors")) break id; + } else return error.NoErrorsPane; + const Probe = struct { id: usize, word: []const u8 }; + const probes = [_]Probe{ .{ .id = 0, .word = "test.txt" }, .{ .id = terminal, .word = "Tty+sh" }, .{ .id = errors, .word = "+Errors" } }; + var arena: std.heap.ArenaAllocator = .init(gpa); + defer arena.deinit(); + for (pardes.themes, 0..) |theme, index| { + colors.setThemeIndex(p, index); + // Each pane focused in turn: every word on both grounds. + for (probes) |focused| { + p.active = focused.id; + _ = arena.reset(.retain_capacity); + const s = try p.render(arena.allocator()); + for (probes) |probe| { + const r = p.rects[probe.id]; + const y = p.tagTop(p.panes[probe.id].?, r); + // The row's text, and the column each byte of it is drawn at. + var row: [512]u8 = undefined; + var cols: [512]u16 = undefined; + var len: usize = 0; + for (r.x..r.x + r.w) |x| { + const g = s.at(@intCast(x), y).grapheme(); + for (if (g.len == 0) " " else g) |byte| if (len < row.len) { + row[len] = byte; + cols[len] = @intCast(x); + len += 1; + }; + } + const name = std.mem.indexOf(u8, row[0..len], probe.word) orelse return error.WordNotDrawn; + const plain = std.mem.indexOf(u8, row[0..len], " Del") orelse return error.WordNotDrawn; + const tint = s.at(cols[name], y).style.fg; + const ink = s.at(cols[plain + 1], y).style.fg; + if (std.meta.eql(tint, ink)) std.debug.print("{s}: {s} drawn in the tag's ink\n", .{ theme.name, probe.word }); + try std.testing.expect(!std.meta.eql(tint, ink)); + // The whole word, in the one tint. + try std.testing.expect(std.meta.eql(s.at(cols[name + probe.word.len - 1], y).style.fg, tint)); + } + } + } +} + test "a tag of three rows has its grip on the first, and band under it that still grabs the pane" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 100, .rows = 30 }); defer p.deinit(); |
