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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
//! Every colour and weight `bdi` draws, named for what it means rather than
//! for what it is, and the only place in the view either is spelled.
//!
//! A slot is a `Style` and not a `Color`, which is what lets one be the
//! terminal's own foreground plus a weight rather than a colour of its own.
//! Two slots holding one value stay apart where they are two claims: a change
//! to what a grey means then reaches the claim it was made about and no other.
//!
//! `src/view/sgr.rs` is the one module outside this one that names a colour.
//! It replays a pane's own escapes rather than choosing anything, so the
//! colours it names are the pane's and no palette can hold them.
use FromStr;
use ;
use crate;
// ---- `bd`'s own, quoted ------------------------------------------------
/// `bd list`'s colours for a status, read off `bd` 1.2.2's output. They are
/// literal rather than named because `bd`'s are: it sends 24-bit values that
/// do not move with the terminal's theme, so a named colour here would track
/// the theme away from the tool this is matching.
pub const STATUS_IN_PROGRESS: Style = new.fg;
pub const STATUS_BLOCKED: Style = new.fg;
pub const STATUS_CLOSED: Style = new.fg;
pub const STATUS_DEFERRED: Style = new.fg;
/// `bd` sends no escape at all for an open bead, and a glyph that inherits is
/// what lets the brightness of the row it sits on reach it.
pub const STATUS_OPEN: Style = new;
/// `bd show`'s colour for the id at the head of the page, literal for the
/// reason the statuses are.
pub const IDENTITY: Style = new.fg;
// ---- the two axes `bd` cannot draw -------------------------------------
/// A live agent is here.
pub const AGENT: Style = new.fg;
/// This wants looking at.
pub const ATTENTION: Style = new.fg;
// ---- how live a row is -------------------------------------------------
/// A row an agent is on: the ground and a weight.
///
/// A theme's own foreground is routinely the same value as its colour 7 or
/// its colour 15, so there is no colour above the ground to reach for. A
/// weight is what is left, and it is the one treatment here whose size is the
/// reader's font rather than the reader's theme: the brightening a terminal
/// does on bold is a remap of palette slots 0-7, and the default foreground
/// has no slot to remap.
pub const TIER_STAFFED: Style = new.fg.add_modifier;
/// Nobody on it and still going, which is most of the forest most of the
/// time: the terminal's own foreground, untreated. It is the ground the other
/// two are measured from rather than a rung between them, so the commonest
/// row on the page is the one the scale spends nothing on.
pub const TIER_OPEN: Style = new.fg;
/// Finished, nobody on it: one rung under the ground, at the theme's colour
/// 8, which every theme sets and few rows on the page otherwise use. Named
/// rather than literal because a rung pinned to a number keeps no distance
/// from a ground it never sees — only the theme knows what its foreground is,
/// so only a value the theme also chooses can stay a fixed way from it.
pub const TIER_FINISHED: Style = new.fg;
// ---- chrome, and content that is not a row -----------------------------
/// Box-drawing and fold arrows: how the tree is shaped rather than how a bead
/// is going, so it is held on the ground while the row around it steps off
/// it. Naming the colour is not enough to stay there — a tone is patched
/// under the whole row and a weight in one composes with a weight in the
/// other, where a colour replaces it — so this says the weight it does not
/// take as well as the colour it does.
pub const STRUCTURE: Style = new
.fg
.remove_modifier;
/// Metadata, chrome, an affordance, a rule.
pub const QUIET: Style = new.fg;
/// In the tail band only: these are `bdi`'s words and not the pane's.
/// `design.md`'s account of the band makes this the whole of what tells the
/// two apart, so it is the one tone on the screen with nothing beside it.
///
/// The one slot here the reader's background selects, and the reason there
/// is a `[theme]` key at all. Every other slot is a value the reader's own
/// theme resolves — its foreground, or one of its sixteen — or one of
/// `bd`'s, which are absolute so that a status is the colour in `bdi` that
/// it is in `bd`. Neither kind has a light form to choose. This one is a
/// treatment `bdi` composes itself, and the terminal resolves it against
/// the background rather than against the palette.
///
/// **Dim over the default foreground is the composition that inverts.** It
/// is git's `GIT_COLOR_FAINT_DEFAULT`, SGR `2;39`, and the terminals that
/// implement dim by scaling the foreground toward black — xterm, VTE,
/// Alacritty, Windows Terminal — leave a light theme's near-black
/// foreground darker than plain text rather than fainter. Windows
/// Terminal's issue #16493 measured it: faint is "the darkest of the three
/// in each line", which against white is bold by another name. A band whose
/// whole distinction is that `bdi` speaks under the pane becomes one where
/// it shouts over it.
///
/// So a dark background is answered with the attribute, which a reader with
/// `NO_COLOR` set still has, and a light one at colour 8, where the theme's
/// own choice of a tone between its foreground and its background carries
/// the distinction and no arithmetic of the terminal's is involved. Not a
/// slant and not an underline: italic and `CODE`'s cyan are prose's
/// namespace, an underline says a link wherever it is drawn, and the band is
/// `bdi` scanning its own words at the reader rather than prose to read or
/// somewhere to go.
///
/// **A light background and `NO_COLOR` together leave the band no tone**,
/// because the one channel that survives colour being off is the one a
/// light background inverts. Such a reader has the rule and which of the
/// two states the band is in, and nothing else says whose words a row is.
pub
/// Every row of the bead window: the head the reader came for, and under it
/// the facts, the prose and the related rows. The terminal's own foreground,
/// which is to say the window spends no brightness on its own structure —
/// what stands out on the page takes a weight, and *dim* is left to mean one
/// thing on every surface. It is a claim about a page of text rather than
/// about a row, so the forest's scale can move without the window following
/// it.
pub const PAGE: Style = new.fg;
/// `bdi`'s own sentence about the forest where nothing went wrong in it: the
/// hidden trees the filter is holding back, and a forest that was read and
/// held no work. Said at the terminal's own foreground because the thing it
/// contrasts with is `ATTENTION`.
pub const PLAIN: Style = new.fg;
/// A code span or a code block: prose's own namespace.
pub const CODE: Style = new.fg;
// ---- weights -----------------------------------------------------------
// A weight says *this is the thing to go to*, and on both surfaces that is
// one meaning rather than two: a row with an agent on it is where the reader
// is heading, and so is the name of the section they are looking for on a
// page of text. What a reader learns on one surface holds on the next, which
// is the whole of why a channel may be spent twice.
//
// On the forest it is also the whole of the top rung of the liveness scale.
// A staffed row and an unworked one are both at the terminal's own
// foreground, so nothing else separates them: the scale spends the channel
// because it has run out of brightness at the ground.
//
// Inside the window it makes no further distinction, and the slots below say
// so by holding one value. What tells a section name from a heading from a
// strong word is position — the first two own their row and the third sits
// inside a sentence — rather than the treatment. They stay apart because
// they quote different sources: prose's markup can take a tone without
// `bd show`'s section names following it.
/// The row under the cursor, drawn so the eye finds it without reading it.
pub const SELECTED: Style = new.add_modifier;
/// A window's own name, on its border.
pub const TITLE: Style = new.add_modifier;
/// `bd show`'s section names, which stand out from a page of text: a weight
/// and no tone, so the page reaches them as it reaches everything else on it.
pub const SECTION: Style = new.add_modifier;
/// A heading in prose. A weight and no colour, so it composes onto the tone
/// of the page it is drawn on.
pub const HEADING: Style = new.add_modifier;
/// Prose's own emphasis, each a weight alone for the reason a heading is.
pub const EMPHASIS: Style = new.add_modifier;
pub const STRONG: Style = new.add_modifier;
/// Somewhere to go: a reference in prose, and a badge whose config gave it a
/// `link`.
pub const LINK: Style = new.add_modifier;
// ---- what a config may name --------------------------------------------
/// The slot a config named, for a badge a reader asked to be drawn in one.
pub
/// The colour a config named, for a badge a reader asked to be drawn in one.
///
/// The one colour this module hands out that `bdi` did not choose. It is named
/// here rather than where it is drawn so that this stays the only place in the
/// view a colour is spelled, whoever spelled it.
pub
/// A colour as a config wrote it, in any form `Color` names one by: one of the
/// sixteen by name, `#rrggbb`, or an index into the terminal's palette.
///
/// Reading a colour is what this module is for, so the reading is here even
/// though what asks for it is `config` refusing a name as it reads the file.
/// `colours-come-from-the-palette` holds the whole of `Color`'s vocabulary to
/// this module, and `from_str` is part of it.
pub