The first P3 (a84abf3) ran on the wrong model and its palette never reached the TUI: MESH_THEME_16 was written in 256-colour cube indices instead of the 16 VT slots, and the platform theme pick was wired into the scripted-CLI console while the real rasterizer stayed hardcoded to truecolor. Replace it end to end: - theme._VT_SLOTS: the canonical slot->RGB design (conventional hue families kept; slots 5/6 become the track/faint slates), MESH_THEME_16 rewritten against color(0..15) with the VT's bold-as-brightness and dim-bank-background rules pinned by tests. /etc/vtrgb + a boot oneshot install it (console-font script), OSC fallback when kbd is absent. - platforms.on_platform: set_platform now re-runs registered bindings, so theme, rasterizer and widgets swap implementations once per switch and hot paths read module globals - no per-call get_platform(). - The render-boundary fold (theme.fold_text): one str.translate pass (NFKD accent folds - the Terminus base has no accented Latin - plus symbol stand-ins and the width-padded emoji map), an embedded-SGR quantizer for canvas truecolor, and a ?-at-own-width catch-all that makes the no-wide-glyph short-circuit true by construction. Applied at the only two places every visible byte passes: render_to_ansi and MapCanvas.to_ansi_lines. - ui/fontset.py freezes the installed font's inventory (dumped live); the gallery now asserts rendered picocalc ANSI carries no truecolor/ 256-colour SGR and no character outside it - the parity gate the first attempt faked by asserting a dataclass field. - Font build: nine new 6x12 marks (ellipsis, warn, backspace, shift, gear, refresh, clock, crosshair, padlock) drawn into donor slots, with donor misses now fatal and a keeper canary (donating pi once erased Cyrillic pe - shared slot). Table re-dumped on-device: identical to fontset.py, 519 = 519. - Type-based name colouring: registry moved to core/nodetypes (services no longer import ui), fed from monitor observations, heard_nodes and merge_contacts. Heat gradient quantizes to heat.* steps on picocalc. - ui/marks.py: the P2-deferred constant relocation - widgets no longer drags map_render/mapcanvas/pathgraph for tuples and aliases. - meshterm specimen: the visual language on one card through the real funnels - the on-device acceptance screen (JP's request). - tools/chat: delivered/no-ack state uses the standard check/query marks, not the banned emoji pair. Verified on the Lyra: font+palette installed, specimen framebuffer captures in .claude/plans/. 1259 tests green, 13 xfailed (P6 list). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
50 lines
2.2 KiB
Python
50 lines
2.2 KiB
Python
"""The shared mark constants: node-type glyphs, their colours, and path sentinels.
|
||
|
||
The app's spatial surfaces — the map, the path graph, the braille rasters, the node
|
||
rows — all pin nodes with the same marks in the same hues, and several of them need the
|
||
constants *without* the machinery around them. Before this module, ``ui.widgets`` pulled
|
||
``map_render``, ``mapcanvas`` and ``pathgraph`` onto the boot path for a handful of
|
||
tuples and type aliases (~60 ms of import on the PicoCalc); now the constants live here,
|
||
dependency-free, and the heavy modules import *from* the constants instead of hosting
|
||
them. ``map_render``/``mapcanvas``/``pathgraph`` re-export their old names, so existing
|
||
importers of those modules are untouched.
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Callable, Optional
|
||
|
||
#: An ``(r, g, b)`` colour triple, 0–255 per channel (the raster/canvas colour type).
|
||
RGB = tuple[int, int, int]
|
||
|
||
|
||
def parse_hex(color: str) -> RGB:
|
||
"""Convert ``"#rrggbb"`` (or ``"rrggbb"``) to an ``(r, g, b)`` tuple."""
|
||
c = color.lstrip("#")
|
||
return (int(c[0:2], 16), int(c[2:4], 16), int(c[4:6], 16))
|
||
|
||
|
||
# Marker palette, shared across the whole app. The basemap is blue (water), green (parks)
|
||
# and warm amber (roads), so markers use the hues a map never contains — pink/violet — to
|
||
# stand out against it. Ordinary nodes are the loudest (bright pink); repeaters recede a
|
||
# step (a calmer violet); our own node stays the fixed yellow star; a node heard of but
|
||
# never identified is a muted grey ring. Every glyph is in the PicoCalc console font.
|
||
SELF_MARK = ("★", "#facc15")
|
||
REPEATER_MARK = ("▲", "#a78bfa")
|
||
NODE_MARK = ("●", "#f472b6")
|
||
UNKNOWN_MARK = ("○", "#94a3b8")
|
||
|
||
#: Sentinels naming a path's endpoints on the route graph. ``\x00`` never appears in a
|
||
#: node hash, so they can share the node-id namespace without colliding with one.
|
||
SRC_NODE = "\x00src"
|
||
DST_NODE = "\x00dst"
|
||
|
||
#: Maps a node id to its graph marker: a ``(glyph, colour)`` pair.
|
||
GlyphOf = Callable[[str], tuple[str, str]]
|
||
|
||
#: A node's graph label, or ``None``/``""`` to leave the marker bare.
|
||
LabelOf = Callable[[str], Optional[str]]
|
||
|
||
#: The colour a node's label is drawn in (usually the node's name hue).
|
||
LabelRgbOf = Callable[[str], RGB]
|