1#![allow(missing_docs)]
2
3use gpui::Hsla;
4use refineable::Refineable;
5use strum::{AsRefStr, EnumIter};
6use util::FieldAccessByEnum;
7
8use crate::{blue, grass, neutral, red, yellow};
9
10#[derive(Refineable, FieldAccessByEnum, Clone, Debug, PartialEq)]
11#[refineable(Debug, serde::Deserialize)]
12#[field_access_by_enum(
13 enum_name = "StatusColorField",
14 enum_attrs = [
15 derive(Debug, Clone, Copy, EnumIter, AsRefStr),
16 strum(serialize_all = "snake_case")
17 ]
18)]
19pub struct StatusColors {
20 /// Indicates some kind of conflict, like a file changed on disk while it was open, or
21 /// merge conflicts in a Git repository.
22 pub conflict: Hsla,
23 pub conflict_background: Hsla,
24 pub conflict_border: Hsla,
25
26 /// Indicates something new, like a new file added to a Git repository.
27 pub created: Hsla,
28 pub created_background: Hsla,
29 pub created_border: Hsla,
30
31 /// Indicates that something no longer exists, like a deleted file.
32 pub deleted: Hsla,
33 pub deleted_background: Hsla,
34 pub deleted_border: Hsla,
35
36 /// Indicates a system error, a failed operation or a diagnostic error.
37 pub error: Hsla,
38 pub error_background: Hsla,
39 pub error_border: Hsla,
40
41 /// Represents a hidden status, such as a file being hidden in a file tree.
42 pub hidden: Hsla,
43 pub hidden_background: Hsla,
44 pub hidden_border: Hsla,
45
46 /// Indicates a hint or some kind of additional information.
47 pub hint: Hsla,
48 pub hint_background: Hsla,
49 pub hint_border: Hsla,
50
51 /// Indicates that something is deliberately ignored, such as a file or operation ignored by Git.
52 pub ignored: Hsla,
53 pub ignored_background: Hsla,
54 pub ignored_border: Hsla,
55
56 /// Represents informational status updates or messages.
57 pub info: Hsla,
58 pub info_background: Hsla,
59 pub info_border: Hsla,
60
61 /// Indicates a changed or altered status, like a file that has been edited.
62 pub modified: Hsla,
63 pub modified_background: Hsla,
64 pub modified_border: Hsla,
65
66 /// Indicates something that is predicted, like automatic code completion, or generated code.
67 pub predictive: Hsla,
68 pub predictive_background: Hsla,
69 pub predictive_border: Hsla,
70
71 /// Represents a renamed status, such as a file that has been renamed.
72 pub renamed: Hsla,
73 pub renamed_background: Hsla,
74 pub renamed_border: Hsla,
75
76 /// Indicates a successful operation or task completion.
77 pub success: Hsla,
78 pub success_background: Hsla,
79 pub success_border: Hsla,
80
81 /// Indicates some kind of unreachable status, like a block of code that can never be reached.
82 pub unreachable: Hsla,
83 pub unreachable_background: Hsla,
84 pub unreachable_border: Hsla,
85
86 /// Represents a warning status, like an operation that is about to fail.
87 pub warning: Hsla,
88 pub warning_background: Hsla,
89 pub warning_border: Hsla,
90}
91
92pub struct DiagnosticColors {
93 pub error: Hsla,
94 pub warning: Hsla,
95 pub info: Hsla,
96}
97
98impl StatusColors {
99 pub fn dark() -> Self {
100 Self {
101 conflict: red().dark().step_9(),
102 conflict_background: red().dark().step_9(),
103 conflict_border: red().dark().step_9(),
104 created: grass().dark().step_9(),
105 created_background: grass().dark().step_9().opacity(0.25),
106 created_border: grass().dark().step_9(),
107 deleted: red().dark().step_9(),
108 deleted_background: red().dark().step_9().opacity(0.25),
109 deleted_border: red().dark().step_9(),
110 error: red().dark().step_9(),
111 error_background: red().dark().step_9(),
112 error_border: red().dark().step_9(),
113 hidden: neutral().dark().step_9(),
114 hidden_background: neutral().dark().step_9(),
115 hidden_border: neutral().dark().step_9(),
116 hint: blue().dark().step_9(),
117 hint_background: blue().dark().step_9(),
118 hint_border: blue().dark().step_9(),
119 ignored: neutral().dark().step_9(),
120 ignored_background: neutral().dark().step_9(),
121 ignored_border: neutral().dark().step_9(),
122 info: blue().dark().step_9(),
123 info_background: blue().dark().step_9(),
124 info_border: blue().dark().step_9(),
125 modified: yellow().dark().step_9(),
126 modified_background: yellow().dark().step_9().opacity(0.25),
127 modified_border: yellow().dark().step_9(),
128 predictive: neutral().dark_alpha().step_9(),
129 predictive_background: neutral().dark_alpha().step_9(),
130 predictive_border: neutral().dark_alpha().step_9(),
131 renamed: blue().dark().step_9(),
132 renamed_background: blue().dark().step_9(),
133 renamed_border: blue().dark().step_9(),
134 success: grass().dark().step_9(),
135 success_background: grass().dark().step_9(),
136 success_border: grass().dark().step_9(),
137 unreachable: neutral().dark().step_10(),
138 unreachable_background: neutral().dark().step_10(),
139 unreachable_border: neutral().dark().step_10(),
140 warning: yellow().dark().step_9(),
141 warning_background: yellow().dark().step_9(),
142 warning_border: yellow().dark().step_9(),
143 }
144 }
145
146 pub fn light() -> Self {
147 Self {
148 conflict: red().light().step_9(),
149 conflict_background: red().light().step_9(),
150 conflict_border: red().light().step_9(),
151 created: grass().light().step_9(),
152 created_background: grass().light().step_9(),
153 created_border: grass().light().step_9(),
154 deleted: red().light().step_9(),
155 deleted_background: red().light().step_9(),
156 deleted_border: red().light().step_9(),
157 error: red().light().step_9(),
158 error_background: red().light().step_9(),
159 error_border: red().light().step_9(),
160 hidden: neutral().light().step_9(),
161 hidden_background: neutral().light().step_9(),
162 hidden_border: neutral().light().step_9(),
163 hint: blue().light().step_9(),
164 hint_background: blue().light().step_9(),
165 hint_border: blue().light().step_9(),
166 ignored: neutral().light().step_9(),
167 ignored_background: neutral().light().step_9(),
168 ignored_border: neutral().light().step_9(),
169 info: blue().light().step_9(),
170 info_background: blue().light().step_9(),
171 info_border: blue().light().step_9(),
172 modified: yellow().light().step_9(),
173 modified_background: yellow().light().step_9(),
174 modified_border: yellow().light().step_9(),
175 predictive: neutral().light_alpha().step_9(),
176 predictive_background: neutral().light_alpha().step_9(),
177 predictive_border: neutral().light_alpha().step_9(),
178 renamed: blue().light().step_9(),
179 renamed_background: blue().light().step_9(),
180 renamed_border: blue().light().step_9(),
181 success: grass().light().step_9(),
182 success_background: grass().light().step_9(),
183 success_border: grass().light().step_9(),
184 unreachable: neutral().light().step_10(),
185 unreachable_background: neutral().light().step_10(),
186 unreachable_border: neutral().light().step_10(),
187 warning: yellow().light().step_9(),
188 warning_background: yellow().light().step_9(),
189 warning_border: yellow().light().step_9(),
190 }
191 }
192
193 pub fn diagnostic(&self) -> DiagnosticColors {
194 DiagnosticColors {
195 error: self.error,
196 warning: self.warning,
197 info: self.info,
198 }
199 }
200}