summaryrefslogtreecommitdiff
path: root/src/colors.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-16 23:14:39 -0300
committerGabriel Schneider <[email protected]>2026-11-17 12:15:01 -0300
commita7a446e0f32cb9daaa06689c91ef7de01bfc968c (patch)
treec51501cb55862f0b527606292e61d04e0e78edaf /src/colors.zig
parentb2163c0a53a6276bc8e1211e9a7c9584bb1ccb2e (diff)
downloadpardes-a7a446e0f32cb9daaa06689c91ef7de01bfc968c.tar.gz
pardes-a7a446e0f32cb9daaa06689c91ef7de01bfc968c.zip
colors: the 256-colour palette is pardes's own, colors.xterm (the sixteen named colours Art.zig kept, xterm's 6x6x6 cube and 24-grey ramp, at comptime), so Art.zig and gui.zig stop importing ghostty-vt: Art's Petscii takes its first sixteen and drops its comptime check against the emulator, gui.zig's palColor goes and its two .index cells read the table; terminal.zig's test holds all 256 entries to ghostty-vt's color.default; the changelog says so
Diffstat (limited to 'src/colors.zig')
-rw-r--r--src/colors.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/colors.zig b/src/colors.zig
index e679f4a5..1713ba24 100644
--- a/src/colors.zig
+++ b/src/colors.zig
@@ -12,6 +12,36 @@ const MAX_PANES = pardes.MAX_PANES;
const BOX_H = pardes.BOX_H;
const Pardes = pardes.Pardes;
+/// The 256-colour palette a terminal starts from (ghostty-vt's default):
+/// sixteen named colours, a 6x6x6 cube at xterm's levels (0, then 95 to
+/// 255 by 40) and a ramp of 24 greys from 8 by 10.
+pub const xterm: [256][3]u8 = blk: {
+ var p: [256][3]u8 = undefined;
+ p[0..16].* = .{
+ .{ 0x1D, 0x1F, 0x21 }, // black
+ .{ 0xCC, 0x66, 0x66 }, // red
+ .{ 0xB5, 0xBD, 0x68 }, // green
+ .{ 0xF0, 0xC6, 0x74 }, // yellow
+ .{ 0x81, 0xA2, 0xBE }, // blue
+ .{ 0xB2, 0x94, 0xBB }, // magenta
+ .{ 0x8A, 0xBE, 0xB7 }, // cyan
+ .{ 0xC5, 0xC8, 0xC6 }, // white
+ .{ 0x66, 0x66, 0x66 }, // bright black
+ .{ 0xD5, 0x4E, 0x53 }, // bright red
+ .{ 0xB9, 0xCA, 0x4A }, // bright green
+ .{ 0xE7, 0xC5, 0x47 }, // bright yellow
+ .{ 0x7A, 0xA6, 0xDA }, // bright blue
+ .{ 0xC3, 0x97, 0xD8 }, // bright magenta
+ .{ 0x70, 0xC0, 0xB1 }, // bright cyan
+ .{ 0xEA, 0xEA, 0xEA }, // bright white
+ };
+ for (0..216) |i| {
+ for (0..3, [3]usize{ i / 36, i / 6 % 6, i % 6 }) |c, v| p[16 + i][c] = if (v == 0) 0 else 55 + 40 * v;
+ }
+ for (0..24) |i| p[232 + i] = @splat(8 + 10 * i);
+ break :blk p;
+};
+
/// sRGB channel to linear light.
pub const to_linear: [256]f32 = blk: {
@setEvalBranchQuota(100_000);