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!(
16        "selection-background = {}\n",
17        hex(c.polar_night_2)
18    ));
19    out.push_str(&format!("selection-foreground = {}\n", hex(c.snow_storm_2)));
20
21    // 0-15 ANSI
22    let palette = [
23        c.polar_night_0,
24        c.aurora_red,
25        c.aurora_green,
26        c.aurora_yellow,
27        c.frost_3,
28        c.aurora_purple,
29        c.frost_0,
30        c.snow_storm_0,
31        c.polar_night_3,
32        c.aurora_red,
33        c.aurora_green,
34        c.aurora_yellow,
35        c.frost_2,
36        c.aurora_purple,
37        c.frost_1,
38        c.snow_storm_2,
39    ];
40    for (i, p) in palette.iter().enumerate() {
41        out.push_str(&format!("palette = {i}={}\n", hex(*p)));
42    }
43
44    // Shader stack — reference the 13 blackmatter-ghostty shaders.
45    let shaders = [
46        "stardust",
47        "sonic-boom",
48        "prompt-saber",
49        "cursor-glow",
50        "cursor-trail",
51        "bloom",
52        "frost-haze",
53        "spotlight",
54        "background-pulse",
55        "chromatic-aberration",
56        "film-grain",
57        "screen-curvature",
58    ];
59    for s in shaders {
60        out.push_str(&format!(
61            "custom-shader = ${{blackmatter-ghostty}}/shaders/{s}.glsl\n"
62        ));
63    }
64    out
65}