1use std::sync::Arc;
2
3use gpui::Hsla;
4use serde::Deserialize;
5
6use crate::{
7 amber, blue, cyan, gold, grass, indigo, iris, jade, lime, orange, pink, purple, tomato,
8};
9
10/// A collection of colors that are used to color indent aware lines in the editor.
11#[derive(Clone, Debug, Deserialize, PartialEq)]
12pub struct AccentColors(pub Arc<[Hsla]>);
13
14impl Default for AccentColors {
15 /// Don't use this!
16 /// We have to have a default to be `[refineable::Refinable]`.
17 /// TODO "Find a way to not need this for Refinable"
18 fn default() -> Self {
19 Self::dark()
20 }
21}
22
23impl AccentColors {
24 /// Returns the set of dark accent colors.
25 pub fn dark() -> Self {
26 Self(Arc::from(vec![
27 blue().dark().step_9(),
28 orange().dark().step_9(),
29 pink().dark().step_9(),
30 lime().dark().step_9(),
31 purple().dark().step_9(),
32 amber().dark().step_9(),
33 jade().dark().step_9(),
34 tomato().dark().step_9(),
35 cyan().dark().step_9(),
36 gold().dark().step_9(),
37 grass().dark().step_9(),
38 indigo().dark().step_9(),
39 iris().dark().step_9(),
40 ]))
41 }
42
43 /// Returns the set of light accent colors.
44 pub fn light() -> Self {
45 Self(Arc::from(vec![
46 blue().light().step_9(),
47 orange().light().step_9(),
48 pink().light().step_9(),
49 lime().light().step_9(),
50 purple().light().step_9(),
51 amber().light().step_9(),
52 jade().light().step_9(),
53 tomato().light().step_9(),
54 cyan().light().step_9(),
55 gold().light().step_9(),
56 grass().light().step_9(),
57 indigo().light().step_9(),
58 iris().light().step_9(),
59 ]))
60 }
61}
62
63impl AccentColors {
64 /// Returns the color for the given index.
65 pub fn color_for_index(&self, index: u32) -> Hsla {
66 self.0[index as usize % self.0.len()]
67 }
68}