diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/consumer/lib.zig | 10 | ||||
| -rw-r--r-- | test/output.zig | 6 | ||||
| -rw-r--r-- | test/panes.zig | 23 | ||||
| -rw-r--r-- | test/terminal.zig | 26 |
4 files changed, 31 insertions, 34 deletions
diff --git a/test/consumer/lib.zig b/test/consumer/lib.zig index 2832bdf1..949afd5c 100644 --- a/test/consumer/lib.zig +++ b/test/consumer/lib.zig @@ -140,12 +140,10 @@ test "a diff is a language: its hunks coloured as their file's, its added and re // a row's hue in a theme: a ground between the page and the theme's green, a stronger and a fainter one const th = pardes.theme("Orchard").?; - const g = pardes.Grounds.of(th); - const ground = g.forStyle(styles[added]).?; - try std.testing.expectEqual(g.add, ground); - try std.testing.expectEqual(g.del, g.forStyle(styles[removed]).?); - try std.testing.expectEqual(null, g.forStyle(@backingInt(pardes.Syn.keyword))); - try std.testing.expect(!std.mem.eql(u8, &ground.row, &pardes.page(th)) and !std.mem.eql(u8, &ground.row, &ground.emph) and !std.mem.eql(u8, &ground.row, &ground.line)); + const c = pardes.Chrome.of(th); + for ([2]pardes.Chrome.Diff{ c.add, c.del }) |ground| + try std.testing.expect(!std.mem.eql(u8, &ground.row, &pardes.page(th)) and !std.mem.eql(u8, &ground.row, &ground.emph) and !std.mem.eql(u8, &ground.row, &ground.line)); + try std.testing.expect(!std.mem.eql(u8, &c.add.row, &c.del.row)); // what a row points at: the new line a `+` row is var lines: std.ArrayList([]const u8) = .empty; diff --git a/test/output.zig b/test/output.zig index f2a35c01..8f4048f0 100644 --- a/test/output.zig +++ b/test/output.zig @@ -103,7 +103,7 @@ test "output callers opt into location highlighting instead of matching prose co const surface = try p.render(frame.allocator()); const line = modal.lineSlice(file.content, 0); const before_colon = std.mem.indexOfScalar(u8, line, ':').?; - const normal: pardes.Color = if (p.theme().fg) |fg| .{ .rgb = fg } else .default; + const normal: pardes.Color = if (p.theme().text) |fg| .{ .rgb = fg } else .default; for (0..before_colon + 2) |byte| { const cell = outputCell(p, surface, id, byte); try std.testing.expectEqual(normal, cell.style.fg); @@ -140,7 +140,7 @@ test "location producers retain rendered location match and diagnostic styles" { } if (!diagnostic) { const number = start + std.mem.indexOf(u8, code, "42").?; - try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().num }, outputCell(p, surface, id, number).style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().number }, outputCell(p, surface, id, number).style.fg); } } } @@ -454,7 +454,7 @@ test "Mini syntax colors survive themes and rendering without source access" { const rect = p.view().rects[id]; const x = rect.x + config.GUTTER + panes.File.gutterWidth(mini) + @as(u16, @intCast(column)); const y = p.bodyTop(mini, rect) + @as(u16, @intCast(position.row)); - try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().kw }, surface.at(x, y).style.fg); + try std.testing.expectEqualDeep(pardes.Color{ .rgb = p.theme().keyword }, surface.at(x, y).style.fg); try std.testing.expectEqual(colors, mini.file.?.mini.?.colors.ptr); try std.testing.expectEqual(@as(usize, 0), mini.file.?.highlights.len); _ = frame.reset(.retain_capacity); diff --git a/test/panes.zig b/test/panes.zig index 497fe884..063832f3 100644 --- a/test/panes.zig +++ b/test/panes.zig @@ -787,13 +787,12 @@ const TagNameTintTests = struct { fn configure(p: *Pardes) void { var theme = p.theme().*; - theme.tag_name_fg = name_fg; - theme.tag_active_name_fg = null; - theme.tag_fg = tag_fg; + theme.tag_name = name_fg; + theme.tag_text = tag_fg; // The focused tag's ink is the plain one, as an unfocused tag's. - theme.tag_active_fg = null; + theme.tag_focus_text = null; p.custom_theme = theme; - p.theme_chrome = pardes.ChromeTheme.fromTheme(p.theme()); + p.theme_chrome = .of(p.theme()); } fn check(p: *Pardes, id: usize, name: []const u8) !usize { @@ -890,10 +889,10 @@ const TagNameTintTests = struct { pane.file.?.path = try p.gpa.dupe(u8, "/dir/file.zig"); configure(p); defer p.custom_theme = null; - p.custom_theme.?.tag_name_fg = null; + p.custom_theme.?.tag_name = null; const active_fg = [3]u8{ 175, 183, 194 }; - p.custom_theme.?.tag_active_fg = active_fg; - p.theme_chrome = pardes.ChromeTheme.fromTheme(p.theme()); + p.custom_theme.?.tag_focus_text = active_fg; + p.theme_chrome = .of(p.theme()); var arena = std.heap.ArenaAllocator.init(p.gpa); defer arena.deinit(); const surface = try p.render(arena.allocator()); @@ -987,7 +986,7 @@ test "terminal overlay recoloring never materializes unrelated history" { const body_y = bodyY(p, rect); const cell = surface.at(rect.x + config.GUTTER, body_y); try testing.expectEqualStrings("c", cell.grapheme()); - try testing.expectEqual(pardes.Color{ .rgb = p.theme().palette.?[2] }, cell.style.fg); + try testing.expectEqual(pardes.Color{ .rgb = p.theme().ansi.?[2] }, cell.style.fg); } test "terminal output keeps following new rows after scrollback eviction" { @@ -1035,7 +1034,7 @@ test "terminal output keeps following new rows after scrollback eviction" { for (last, 0..) |byte, col| { const cell = surface.at(x + @as(u16, @intCast(col)), y); try std.testing.expectEqualStrings(&.{byte}, cell.grapheme()); - try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().palette.?[2] }, cell.style.fg); + try std.testing.expectEqual(pardes.Color{ .rgb = p.theme().ansi.?[2] }, cell.style.fg); } while (p.nextEffect()) |_| {} p.update(.{ .key = .{ .cp = 'f', .text = "f" } }); @@ -3608,7 +3607,7 @@ test "Zig keywords keep every rendered byte colored across line-number widths" { try std.testing.expectEqual(@as(u16, @intCast(y)), surface.cursor.?.y); } else if_position = .{ .x = @intCast(x), .y = @intCast(y) }; for ([_]*pardes.Cell{ first, second }) |cell| { - const expected: pardes.Color = .{ .rgb = p.theme().kw }; + const expected: pardes.Color = .{ .rgb = p.theme().keyword }; if (!std.meta.eql(expected, cell.style.fg)) std.debug.print( "\nline={d} wrap={} horizontal={d} sample={s} cell={s}\n", .{ line, view.wrap, view.horizontal, sample, cell.grapheme() }, @@ -3644,7 +3643,7 @@ test "terminal overlays preserve trailing blank styles without coloring inserted const rect = p.view().rects[0]; const x = rect.x + config.GUTTER; const y = bodyY(p, rect); - const palette = p.theme().palette.?; + const palette = p.theme().ansi.?; const colors = [_]pardes.Color{ .{ .rgb = palette[1] }, .{ .rgb = palette[2] }, .{ .rgb = palette[4] } }; const original = try p.render(frame.allocator()); for (colors, 0..) |color, row| { diff --git a/test/terminal.zig b/test/terminal.zig index 1168fac7..3c74cd11 100644 --- a/test/terminal.zig +++ b/test/terminal.zig @@ -393,14 +393,14 @@ test "terminal Filter keys indexed truecolor OSC and background-only cells throu p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b]104;1\x1b\\" } }); var custom = p.theme().*; custom.name = try p.gpa.dupe(u8, "same-name"); - custom.palette = pardes.colors.xterm[0..16].*; - custom.palette.?[1] = .{ 1, 2, 3 }; + custom.ansi = pardes.colors.xterm[0..16].*; + custom.ansi.?[1] = .{ 1, 2, 3 }; p.custom_theme = custom; pardes.colors.finishThemeInitialization(p); _ = frame.reset(.retain_capacity); const custom_first = try p.render(frame.allocator()); try testing.expectEqual(plain.Color{ .rgb = .{ 1, 2, 3 } }, custom_first.at(tx, body_y).style.fg); - if (p.custom_theme) |*theme| theme.palette.?[1] = .{ 4, 5, 6 }; + if (p.custom_theme) |*theme| theme.ansi.?[1] = .{ 4, 5, 6 }; pardes.colors.finishThemeInitialization(p); _ = frame.reset(.retain_capacity); const custom_second = try p.render(frame.allocator()); @@ -465,9 +465,9 @@ test "terminal Filter preserves exact palette-null light theme default roles" { var light = p.theme().*; light.name = try p.gpa.dupe(u8, "filter-light-defaults"); - light.bg = .{ 0xf8, 0xf8, 0xf8 }; - light.fg = .{ 0x38, 0x38, 0x38 }; - light.palette = null; + light.page = .{ 0xf8, 0xf8, 0xf8 }; + light.text = .{ 0x38, 0x38, 0x38 }; + light.ansi = null; p.custom_theme = light; pardes.colors.finishThemeInitialization(p); @@ -482,14 +482,14 @@ test "terminal Filter preserves exact palette-null light theme default roles" { const tx = r.x + config.GUTTER; const body_y = p.bodyTop(pane, r); const ordinary = try p.render(frame.allocator()); - try testing.expectEqual(plain.Color{ .rgb = light.fg.? }, ordinary.at(tx, body_y).style.fg); - try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, ordinary.at(tx, body_y).style.bg); + try testing.expectEqual(plain.Color{ .rgb = light.text.? }, ordinary.at(tx, body_y).style.fg); + try testing.expectEqual(plain.Color{ .rgb = light.page.? }, ordinary.at(tx, body_y).style.bg); p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?5h" } }); _ = frame.reset(.retain_capacity); const reversed = try p.render(frame.allocator()); - try testing.expectEqual(plain.Color{ .rgb = light.bg.? }, reversed.at(tx, body_y).style.fg); - try testing.expectEqual(plain.Color{ .rgb = light.fg.? }, reversed.at(tx, body_y).style.bg); + try testing.expectEqual(plain.Color{ .rgb = light.page.? }, reversed.at(tx, body_y).style.fg); + try testing.expectEqual(plain.Color{ .rgb = light.text.? }, reversed.at(tx, body_y).style.bg); } test "terminal Filter maps the default roles before it maps anything else" { @@ -631,8 +631,8 @@ test "tty ansi colors follow the prompt hug into normal mode" { const r = p.view().rects[0]; const tx = r.x + config.GUTTER; const body_y = p.bodyTop(pane, r); - const red: plain.Color = .{ .rgb = p.theme().palette.?[1] }; - const blue: plain.Color = .{ .rgb = p.theme().palette.?[4] }; + const red: plain.Color = .{ .rgb = p.theme().ansi.?[1] }; + const blue: plain.Color = .{ .rgb = p.theme().ansi.?[4] }; // tty mode projects the emulator's ansi colours cell for cell. pane.body.mode = .tty; @@ -672,7 +672,7 @@ test "a prompt row hidden end to end paints nothing at all" { const s = try p.render(frame.allocator()); try testing.expectEqualStrings(" ", s.at(tx, body_y).grapheme()); - try testing.expect(!std.meta.eql(plain.Color{ .rgb = p.theme().palette.?[1] }, s.at(tx, body_y).style.bg)); + try testing.expect(!std.meta.eql(plain.Color{ .rgb = p.theme().ansi.?[1] }, s.at(tx, body_y).style.bg)); } test "a program that asked for focus reports hears CSI I and CSI O as its pane takes and gives up the keyboard, and as the window does" { |
