Skip to main content

ishou_render/
ghostty.rs

1//! Ghostty renderer — emits a Ghostty `config` block binding palette indices
2//! and cursor / selection / background colors.
3
4use ishou_tokens::TokenSet;
5
6pub fn render(t: &TokenSet) -> String {
7    let c = &t.color;
8    let hex = |rgb: ishou_tokens::Rgb| rgb.hex();
9    let mut out = String::from("# ishou — pleme-io Ghostty config (generated)\n\n");
10
11    // Nord palette as Ghostty 16-color ANSI mapping.
12    out.push_str(&format!("background = {}\n", hex(c.polar_night_0)));
13    out.push_str(&format!("foreground = {}\n", hex(c.snow_storm_2)));
14    out.push_str(&format!("cursor-color = {}\n", hex(c.frost_1)));
15    out.push_str(&format!("selection-background = {}\n", hex(c.polar_night_2)));
16    out.push_str(&format!("selection-foreground = {}\n", hex(c.snow_storm_2)));
17
18    // 0-15 ANSI
19    let palette = [
20        c.polar_night_0,  c.aurora_red,     c.aurora_green,   c.aurora_yellow,
21        c.frost_3,        c.aurora_purple,  c.frost_0,        c.snow_storm_0,
22        c.polar_night_3,  c.aurora_red,     c.aurora_green,   c.aurora_yellow,
23        c.frost_2,        c.aurora_purple,  c.frost_1,        c.snow_storm_2,
24    ];
25    for (i, p) in palette.iter().enumerate() {
26        out.push_str(&format!("palette = {i}={}\n", hex(*p)));
27    }
28
29    // Shader stack — reference the 13 blackmatter-ghostty shaders.
30    let shaders = [
31        "stardust", "sonic-boom", "prompt-saber", "cursor-glow",
32        "cursor-trail", "bloom", "frost-haze", "spotlight",
33        "background-pulse", "chromatic-aberration", "film-grain", "screen-curvature",
34    ];
35    for s in shaders {
36        out.push_str(&format!("custom-shader = ${{blackmatter-ghostty}}/shaders/{s}.glsl\n"));
37    }
38    out
39}