1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//! The identity palette: which colour a service is drawn in.
//!
//! Colour here is identity, never status. Red, green and yellow are reserved for
//! state everywhere in podup, so no identity colour may sit near one.
/// Identity colours, as xterm-256 indices.
///
/// Chosen so each clears 3:1 contrast against both white and black, sits at
/// least deltaE 40 from the semantic red/green/yellow, and is at least deltaE 22
/// from every other entry. `palette_tests.rs` recomputes all three from the sRGB
/// values, so an edit that adds a pretty but unreadable colour fails the build
/// rather than shipping.
///
/// Twenty is what survives those three filters, not a round number: of the 256
/// colours only 80 clear 3:1 against both backgrounds at all, and 61 of those
/// are far enough from the status colours. At the stricter 4.5:1 text bar only
/// six qualify anywhere in the 256-colour space, which is why the wide palette
/// targets the 3:1 interface bar instead.
pub const WIDE_PALETTE: = ;
/// The palette entry at `index`, wrapping when a project has more services than
/// the palette has colours. Repeating past the twentieth is better than running
/// out of colour.
pub
/// Whether the terminal can render the wide palette, from the values that
/// describe it.
///
/// Pure so all four tiers are tested without a terminal. First match wins:
/// - `COLORTERM` announcing truecolor or 24bit
/// - `TERM` carrying the conventional `256color` marker
/// - on Windows, unconditionally: the console there takes 256 colours in every
/// modern host, and Windows commonly sets neither variable, so without this
/// tier every Windows user would fall back
/// - anything else falls back to the six ANSI basics
///
/// Guessing wider paints escape codes into the output of a terminal that cannot
/// decode them.
pub
/// [`supports_wide_palette`] against this process's environment.
///
/// Read once and cached: the environment does not change under a running
/// command, and every styled cell would otherwise pay two `var_os` calls.
///
/// The Windows argument is `cfg!(windows)` — the target, not a runtime probe of
/// virtual-terminal processing. That is sufficient because this is only ever
/// consulted after the colour gate has decided to emit colour at all, which
/// already required a terminal and a permitting `--ansi`/`NO_COLOR`; and on a
/// console that genuinely lacks VT, anstream's wincon path converts the escapes
/// rather than printing them raw.
///
/// Cached for the process, so tests must exercise [`supports_wide_palette`]
/// rather than this: two tests varying the environment around this function
/// would see whichever answer was cached first and pass or fail on test
/// scheduling.
pub
use HashMap;
/// Give each name its own palette slot, walking them in sorted order.
///
/// Sequential rather than hashed: a hash does not know how many services exist,
/// so it collides well before the palette is full — measured on a four-service
/// project, two came out the same colour, and over twenty colours five services
/// still collide about 42% of the time.
///
/// Sorting is what keeps it deterministic. Assigning in order of appearance
/// would repaint everything when a service moved in the compose file; sorted,
/// the same file always renders the same and adding a service only shifts those
/// that sort after it. Nothing is written to disk.
pub
/// The palette slot for `label`, falling back to a hash for a label that was
/// never registered.
///
/// The fallback matters for anything podup renders but did not resolve from the
/// compose file — an orphan container, a project listed by `ls`. A stable wrong
/// colour reads better than no colour at all, and the hash is what guarantees
/// the same label always lands on the same slot.
pub