status.rs

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