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
//! The orange→green corner gradient shared by the welcome "Recent Activity"
//! box and, under the Black theme, the focused-pane border. Defined once here
//! so both surfaces sweep through identical colours.
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::{Color, Style};
pub const GRAD_TL: (u8, u8, u8) = (0x5c, 0xd6, 0xc8);
pub const GRAD_TR: (u8, u8, u8) = (0xec, 0x8c, 0x5a);
pub const GRAD_BR: (u8, u8, u8) = (0x4f, 0xb1, 0xa6);
pub const GRAD_BL: (u8, u8, u8) = (0x35, 0x80, 0x78);
/// Muted dark-teal fill for the selected row of popups/menus under the Black
/// theme, replacing the legacy bright-blue (`#4e9aff`) highlight inherited from
/// the pre-brand VS Code accent. Quiet enough that the gradient border carries
/// the brand identity; white text reads cleanly on top.
pub const POPUP_SEL_BG: (u8, u8, u8) = (0x26, 0x4f, 0x4a);
/// Bright teal/cyan card accent (borders, line-art illustrations, links) on
/// the empty-state cards under the Black theme — the same value the Remote
/// Explorer card has always used locally as `CARD_BORDER`/`LINK_FG`.
pub const CARD_ACCENT: (u8, u8, u8) = (0x3e, 0xd8, 0xc4);
/// Brand-teal fill for primary action buttons (`Initialize Repository`,
/// `Run and Debug`, the Remote Explorer `Connect`) under the Black theme,
/// replacing the legacy VS Code button blue (#0967b8). Same value the remote
/// empty-state card has always used, promoted here as the single source.
pub const PRIMARY_BTN_BG: (u8, u8, u8) = (0x0e, 0x7e, 0x76);
/// VS Code's `panelTitle.activeForeground` (#E7E7E7): the chipless panel
/// header text under the Black theme (e.g. the TERMINAL title), replacing the
/// legacy white-on-navy chip so the gradient border alone carries the brand.
pub const PANEL_TITLE_FG: (u8, u8, u8) = (0xe7, 0xe7, 0xe7);
/// Muted brand teal (the gradient's bottom-right corner) used as the inner
/// stroke accent under the Black theme — input-box focus rings, text cursors,
/// chevrons, and magnifier glyphs — replacing the legacy bright-blue
/// (`#4e9aff`). Quieter than the top-left teal so inner chrome doesn't shout
/// over the gradient border that carries the brand.
pub const INNER_ACCENT: (u8, u8, u8) = (0x4f, 0xb1, 0xa6);
pub fn lerp_rgb(a: (u8, u8, u8), b: (u8, u8, u8), t: f32) -> (u8, u8, u8) {
let t = t.clamp(0.0, 1.0);
let mix = |x: u8, y: u8| ((1.0 - t) * x as f32 + t * y as f32).round() as u8;
(mix(a.0, b.0), mix(a.1, b.1), mix(a.2, b.2))
}
pub fn rgb_color((r, g, b): (u8, u8, u8)) -> Color {
Color::Rgb(r, g, b)
}
/// Paint a rounded-rectangle border whose stroke colour interpolates
/// linearly between the four corner colours along each edge. The interior
/// is left untouched so the caller can fill it with content.
///
/// The rect is clipped against the buffer's area, so callers don't have to
/// do the bounds math themselves — passing a rect that runs off the edge
/// (e.g., a 80x25 default startup buffer with a tall recents list) draws
/// nothing instead of panicking inside `set_string`.
pub fn paint_gradient_box(buf: &mut Buffer, rect: Rect) {
paint_gradient_box_weighted(buf, rect, false)
}
/// The gradient box in either weight (#470).
///
/// `heavy` swaps the light line-drawing glyphs for their heavy siblings so
/// a focused terminal pane reads as focused on the Black theme too, where
/// this overlay REPLACES the block border the rest of the app draws -- a
/// `BorderType::Thick` underneath would be painted straight over. The
/// corners stay rounded in both weights: there is no heavy rounded corner
/// in the box-drawing block, and the arc glyphs are the house look every
/// other caller of this function shares.
pub fn paint_gradient_box_heavy(buf: &mut Buffer, rect: Rect) {
paint_gradient_box_weighted(buf, rect, true)
}
fn paint_gradient_box_weighted(buf: &mut Buffer, rect: Rect, heavy: bool) {
// The one guard for both entry points. It lived in `paint_gradient_box`
// and a weaker copy landed here when the weight parameter was added,
// which left the heavy path able to panic on a rect the light path
// safely declined -- the offsets and the lower bounds matter whenever
// the buffer does not start at (0,0).
if rect.width < 2 || rect.height < 2 {
return;
}
let buf_area = buf.area;
if rect.x < buf_area.x
|| rect.y < buf_area.y
|| rect.x + rect.width > buf_area.x + buf_area.width
|| rect.y + rect.height > buf_area.y + buf_area.height
{
return;
}
let horiz = if heavy { "\u{2501}" } else { "\u{2500}" };
let vert = if heavy { "\u{2503}" } else { "\u{2502}" };
let max_x = rect.width - 1;
let max_y = rect.height - 1;
for x in 0..rect.width {
let u = if max_x > 0 {
x as f32 / max_x as f32
} else {
0.0
};
let top = lerp_rgb(GRAD_TL, GRAD_TR, u);
let bot = lerp_rgb(GRAD_BL, GRAD_BR, u);
let top_ch = if x == 0 {
"\u{256d}"
} else if x == max_x {
"\u{256e}"
} else {
horiz
};
let bot_ch = if x == 0 {
"\u{2570}"
} else if x == max_x {
"\u{256f}"
} else {
horiz
};
buf.set_string(
rect.x + x,
rect.y,
top_ch,
Style::default().fg(rgb_color(top)),
);
buf.set_string(
rect.x + x,
rect.y + max_y,
bot_ch,
Style::default().fg(rgb_color(bot)),
);
}
for y in 1..max_y {
let v = if max_y > 0 {
y as f32 / max_y as f32
} else {
0.0
};
let left = lerp_rgb(GRAD_TL, GRAD_BL, v);
let right = lerp_rgb(GRAD_TR, GRAD_BR, v);
buf.set_string(
rect.x,
rect.y + y,
vert,
Style::default().fg(rgb_color(left)),
);
buf.set_string(
rect.x + max_x,
rect.y + y,
vert,
Style::default().fg(rgb_color(right)),
);
}
}