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
//! Low-level text paint helper + `ComputedStyle` → paint `Style`
//! conversion.
//!
//! All inline / IFC / ::before / ::after paint paths ultimately
//! funnel through `paint_text` so Unicode-width handling, clipping,
//! and wide-glyph placement stay in one place.
use UnicodeWidthStr;
use crate;
use crate;
/// Paint `text` starting at `(x, base_y)`, clipped to
/// `[x..budget_right)` on that row. Returns the x-cursor after the
/// last painted cell so callers can chain multiple paints
/// (`::before` → own text → `::after`).
pub
/// Build a paint-layer `Style` from a `ComputedStyle`, including
/// `bg`. Filters `Color::Reset` (means "no color set, use terminal
/// default") and keeps only the modifier bits we actually support.
///
/// **Use this only when the caller is the one painting the bg
/// for the cells it writes** — i.e. the cells don't already have
/// their bg set by an upstream `fill_bg`. Cases:
/// - `::before` / `::after` static pseudo content (the pseudo's
/// bg, if any, paints in the pseudo's cells without a separate
/// `fill_bg`).
/// - `positioned_pseudos` content (the positioning pass does its
/// own bg fill, but this helper is also used for the glyph
/// style — bg in style is redundant at `opacity = 1.0` and
/// currently produces a small double-blend at `opacity < 1.0`,
/// which is documented as deferred polish).
/// - IFC fragments whose owner is an inline-level element with
/// its own `background-color` (the inline child has no
/// `fill_bg` of its own; its bg paints via the fragment glyph
/// style).
///
/// For all other glyph paints (the element's own text, gauge /
/// select chrome, password mask, IFC fragments owned by the IFC
/// block itself) use `glyph_style_from_computed` below — the
/// cell's `bg` is already owned by the upstream `fill_bg`, and
/// including `bg` in the glyph style would cause a second blend
/// pass at `opacity < 1.0`, brightening text cells relative to
/// non-text cells (the "text cells have a different bg from the
/// surrounding bg" symptom).
///
/// This split is the project's paint-layer invariant in practice:
/// `fill_bg` owns `cell.bg`; glyph painters write
/// `symbol + fg + modifiers`.
pub
/// Same as `style_from_computed` but **omits `bg`** — for glyph
/// paints where the cell's `bg` is already owned by an upstream
/// `fill_bg`. See `style_from_computed`'s doc for the call-site
/// split.
pub