markdown/paint/
comment.rs1use gpui::{App, Global, Hsla};
4use theme::Theme;
5
6#[derive(Debug, Clone, Copy, PartialEq)]
8pub struct CommentWashes {
9 pub color: Hsla,
11 pub open: Hsla,
13 pub active: Hsla,
15 pub resolved: Hsla,
17}
18
19impl CommentWashes {
20 pub fn of(color: Hsla) -> Self {
22 Self {
23 color,
24 open: color.opacity(0.20),
25 active: color.opacity(0.38),
26 resolved: color.opacity(0.08),
27 }
28 }
29}
30
31pub type CommentPaint = fn(theme: &Theme) -> CommentWashes;
34
35struct Installed(CommentPaint);
36
37impl Global for Installed {}
38
39pub(crate) fn set_comment_paint(cx: &mut App, paint: CommentPaint) {
43 cx.set_global(Installed(paint));
44}
45
46pub fn default_comment(theme: &Theme) -> CommentWashes {
48 CommentWashes::of(theme.warning)
49}
50
51pub(crate) fn comment_paint_of(cx: &App) -> CommentPaint {
52 cx.try_global::<Installed>()
53 .map_or(default_comment, |installed| installed.0)
54}