L
ling-miao
↓ 0 downloadsmiao: a Ling-native version control system — temples, souls, rites and talismans instead of repos, branches, commits and tags; adaptive whole/delta/chunk storage; SSH temple fairs for sharing; a LingStationX-themed GUI; ROYGBIV everywhere
Keywords vcs, version-control, git, miao, ling
lingfu install ling-miaoCode / Files (268)
ling/colors.ling
# ━━━ colors.ling — ROYGBIV terminal engine for miao ━━━
# Truecolor ANSI, matching the LingStationX key palette exactly.
# cx_init() must run once at program start. MIAO_PLAIN=1 or --plain disables color.
fn cx_init(plain) {
bind e = ""
if plain < 0.5 {
bind er = hex_text("1b")
if ut_is_bad(er) == false { bind e = er.unwrap() }
}
st_set("cx_esc", e)
return 0.0
}
fn cx_on() { return st_get("cx_esc", "") != "" }
fn cx_fg(r, g, b) {
bind e = st_get("cx_esc", "")
if e == "" { return "" }
return e + "[38;2;" + r + ";" + g + ";" + b + "m"
}
fn cx_bold() {
bind e = st_get("cx_esc", "")
if e == "" { return "" }
return e + "[1m"
}
fn cx_r() {
bind e = st_get("cx_esc", "")
if e == "" { return "" }
return e + "[0m"
}
# ── the seven colors (LSX palette) ────────────────────────────────────
# 0 red 237,74,55 | 1 orange 247,148,30 | 2 yellow 247,216,70 | 3 green 69,200,112
# 4 blue 59,170,235 | 5 indigo 74,100,216 | 6 violet 154,83,214
fn cx_roy(i) {
bind k = floor(i) % 7.0
if k < 0.0 { bind k = k + 7.0 }
if k < 0.5 { return cx_fg(237.0, 74.0, 55.0) }
if k < 1.5 { return cx_fg(247.0, 148.0, 30.0) }
if k < 2.5 { return cx_fg(247.0, 216.0, 70.0) }
if k < 3.5 { return cx_fg(69.0, 200.0, 112.0) }
if k < 4.5 { return cx_fg(59.0, 170.0, 235.0) }
if k < 5.5 { return cx_fg(74.0, 100.0, 216.0) }
return cx_fg(154.0, 83.0, 214.0)
}
fn cx_paint(i, t) { return cx_roy(i) + t + cx_r() }
# semantic wrappers — the ROYGBIV meaning map:
# red=errors/deletions orange=warnings/restless yellow=altar/staged
# green=additions/success blue=info/souls indigo=rite ids/metadata
# violet=talismans/wandering spirits
fn cx_err(t) { return cx_paint(0.0, t) }
fn cx_warn(t) { return cx_paint(1.0, t) }
fn cx_stage(t) { return cx_paint(2.0, t) }
fn cx_good(t) { return cx_paint(3.0, t) }
fn cx_info(t) { return cx_paint(4.0, t) }
fn cx_meta(t) { return cx_paint(5.0, t) }
fn cx_tal(t) { return cx_paint(6.0, t) }
fn cx_dim(t) { return cx_fg(140.0, 144.0, 152.0) + t + cx_r() }
# ── rainbow text: cycle ROYGBIV per character ─────────────────────────
fn cx_rainbow(t) {
if cx_on() == false { return t }
bind out = ""
bind i = 0.0
bind c = 0.0
bind n = len(t)
while i < n {
bind ch = str_slice(t, i, 1.0)
if ch == " " {
bind out = out + ch
} else {
bind out = out + cx_roy(c) + ch
bind c = c + 1.0
}
bind i = i + 1.0
}
return out + cx_r()
}
# a horizontal rule of 7 colored segments
fn cx_rule(w) {
if w < 7.0 { bind w = 42.0 }
bind seg = floor(w / 7.0)
bind out = ""
bind k = 0.0
while k < 7.0 {
bind out = out + cx_roy(k) + str_repeat("─", seg)
bind k = k + 1.0
}
return out + cx_r()
}
# the aura of a rite: its 7-char short id, each hex char in its rainbow color
fn cx_aura(id) {
bind s = ut_short(id)
if cx_on() == false { return s }
bind out = ""
bind i = 0.0
while i < len(s) {
bind out = out + cx_roy(i) + str_slice(s, i, 1.0)
bind i = i + 1.0
}
return out + cx_r()
}
fn cx_banner() {
print(cx_rainbow("miao") + cx_dim(" 灵庙 · the temple of versions"))
print(cx_rule(42.0))
return 0.0
}