status.rs

 1use gpui::Hsla;
 2
 3use crate::{blue, grass, neutral, red, yellow, StatusColors};
 4
 5impl Default for StatusColors {
 6    /// Don't use this!
 7    /// We have to have a default for StatusColors to be `[refineable::Refinable]`.
 8    fn default() -> Self {
 9        Self::dark()
10    }
11}
12
13pub struct DiagnosticColors {
14    pub error: Hsla,
15    pub warning: Hsla,
16    pub info: Hsla,
17}
18
19pub struct GitStatusColors {
20    pub created: Hsla,
21    pub deleted: Hsla,
22    pub modified: Hsla,
23    pub renamed: Hsla,
24    pub conflict: Hsla,
25    pub ignored: Hsla,
26}
27
28impl StatusColors {
29    pub fn dark() -> Self {
30        Self {
31            conflict: red().dark().step_9(),
32            created: grass().dark().step_9(),
33            deleted: red().dark().step_9(),
34            error: red().dark().step_9(),
35            hidden: neutral().dark().step_9(),
36            hint: blue().dark().step_9(),
37            ignored: neutral().dark().step_9(),
38            info: blue().dark().step_9(),
39            modified: yellow().dark().step_9(),
40            predictive: neutral().dark_alpha().step_9(),
41            renamed: blue().dark().step_9(),
42            success: grass().dark().step_9(),
43            unreachable: neutral().dark().step_10(),
44            warning: yellow().dark().step_9(),
45        }
46    }
47
48    pub fn light() -> Self {
49        Self {
50            conflict: red().light().step_9(),
51            created: grass().light().step_9(),
52            deleted: red().light().step_9(),
53            error: red().light().step_9(),
54            hidden: neutral().light().step_9(),
55            hint: blue().light().step_9(),
56            ignored: neutral().light().step_9(),
57            info: blue().light().step_9(),
58            modified: yellow().light().step_9(),
59            predictive: neutral().light_alpha().step_9(),
60            renamed: blue().light().step_9(),
61            success: grass().light().step_9(),
62            unreachable: neutral().light().step_10(),
63            warning: yellow().light().step_9(),
64        }
65    }
66
67    pub fn diagnostic(&self) -> DiagnosticColors {
68        DiagnosticColors {
69            error: self.error,
70            warning: self.warning,
71            info: self.info,
72        }
73    }
74
75    pub fn git(&self) -> GitStatusColors {
76        GitStatusColors {
77            created: self.created,
78            deleted: self.deleted,
79            modified: self.modified,
80            renamed: self.renamed,
81            conflict: self.conflict,
82            ignored: self.ignored,
83        }
84    }
85}