The harness now has the interface it was missing: a chat pane on three quarters of the screen, a sidebar on one quarter, a status bar underneath. - vendor/netbsd-curses: NetBSD's curses and terminfo, ported edition, vendored with PROVENANCE.md. The build of that one directory needs GNU make; splinter's own Makefile stays POSIX make. - tools/genpalettes.py turns CDE's *.dp palette files into a C table. 42 palettes, generated, checked in with the generator, so the source of every colour is a file in the CDE tree and not a guess. - themes: roles are derived, not invented - background is the darkest of the eight colour sets, foreground the lightest, border the second darkest, accent the most saturated of the rest, status the accent darkened by a third. Delphinium is the default. Unknown palette is an error. - colours map to the terminal through xterm's 256-colour cube when available, the 16 basic colours otherwise, so a palette looks the same everywhere within what the terminal can show. - ui.c redraws only on change; the sidebar shows session, transport, theme and last-turn numbers. Widgets are a labelled empty area - the registry lands next. Six test binaries green, including test_theme (42 palettes, ordering invariants, unknown name rejected, colour indices in range).
82 lines
2.3 KiB
Python
82 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Turn CDE palette files (*.dp) into a C table for splinter.
|
|
|
|
A CDE palette file holds eight colours, one per line, in the order the desktop
|
|
numbers its colour sets. Two encodings occur in the CDE tree:
|
|
|
|
#RRRRGGGGBBBB 16 bits per channel, 48 bits total
|
|
Black / White a colour name (only four files use this)
|
|
|
|
Both are handled. Anything that is neither is a hard error: a palette that
|
|
silently turns grey hides a broken file, and the palette is what the user sees
|
|
first.
|
|
|
|
Usage: genpalettes.py <palette-dir> > palettes.c
|
|
"""
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
NAMED = {
|
|
"black": (0, 0, 0),
|
|
"white": (255, 255, 255),
|
|
}
|
|
|
|
HEX48 = re.compile(r"^#([0-9a-fA-F]{12})$")
|
|
|
|
|
|
def parse_line(text: str, path: str, lineno: int):
|
|
tok = text.strip()
|
|
if not tok:
|
|
return None
|
|
m = HEX48.match(tok)
|
|
if m:
|
|
v = m.group(1)
|
|
return tuple(int(v[i:i + 4], 16) >> 8 for i in (0, 4, 8))
|
|
low = tok.lower()
|
|
if low in NAMED:
|
|
return NAMED[low]
|
|
raise SystemExit("%s:%d: neither #RRRRGGGGBBBB nor a known name: %r"
|
|
% (path, lineno, tok))
|
|
|
|
|
|
def load(path: str):
|
|
out = []
|
|
with open(path, "r", encoding="utf-8") as fh:
|
|
for lineno, line in enumerate(fh, 1):
|
|
rgb = parse_line(line, path, lineno)
|
|
if rgb is not None:
|
|
out.append(rgb)
|
|
if len(out) != 8:
|
|
raise SystemExit("%s: %d colours, expected 8" % (path, len(out)))
|
|
return out
|
|
|
|
|
|
def main() -> int:
|
|
if len(sys.argv) != 2:
|
|
raise SystemExit(__doc__)
|
|
src = sys.argv[1]
|
|
names = sorted(f[:-3] for f in os.listdir(src) if f.endswith(".dp"))
|
|
if not names:
|
|
raise SystemExit("%s: no .dp files" % src)
|
|
|
|
w = sys.stdout.write
|
|
w("/*\n"
|
|
" * Generated by tools/genpalettes.py from the CDE palette files.\n"
|
|
" * Do not edit by hand: change the .dp source or the generator.\n"
|
|
" */\n"
|
|
"#include \"palettes.h\"\n\n"
|
|
"const struct sp_palette sp_palettes[] = {\n")
|
|
for name in names:
|
|
cols = load(os.path.join(src, name + ".dp"))
|
|
body = ", ".join("{0x%02x,0x%02x,0x%02x}" % c for c in cols)
|
|
w("\t{ \"%s\", { %s } },\n" % (name, body))
|
|
w("};\n\n"
|
|
"const size_t sp_palette_count = "
|
|
"sizeof(sp_palettes) / sizeof(sp_palettes[0]);\n")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|