catppuccin-nim/examples/term.nim

33 lines
571 B
Nim
Raw Permalink Normal View History

2023-04-26 20:03:36 -05:00
import std/[strformat]
import catppuccin
const ansiReset = "\e[0m"
2023-04-27 09:24:14 -05:00
proc ansi(s: string, c: Color): string =
let
cRgb = c.rgb()
(r, g, b) = (cRgb.r, cRgb.g, cRgb.b)
code = &"\e[48;2;{r};{g};{b}m"
2023-04-26 20:03:36 -05:00
result.add(code)
result.add(s)
result.add(ansiReset)
when isMainModule:
let flavors = @[
("latte", latte),
("frappe", frappe),
("macchiato", macchiato),
("mocha", mocha)
]
for (name, flavor) in flavors:
echo name
for name, color in flavor.fieldPairs():
write(stdout, " ".ansi(color))
write(stdout, "\n\n")