two_face/theme/
mod.rs

1//! Contains extra theme definitions and the [`LazyThemeSet`] type
2//!
3//! The extra themes are provided in an [`EmbeddedLazyThemeSet`] which is just a newtype around a
4//! [`LazyThemeSet`], but with an exhastive enumeration of its themes through the
5//! [`EmbeddedThemeName`] enum
6//!
7//! _Note: For visual examples of all of the embedded themes look at the docs for
8//! [`EmbeddedThemeName`]_
9
10mod core_types;
11
12pub use core_types::LazyThemeSet;
13
14use syntect::highlighting::{Theme, ThemeSet};
15
16/// Returns an [`EmbeddedLazyThemeSet`] with more popular theme definitions
17///
18/// These themes cover a variety of use-cases, so it's very likely that you'll only want to expose
19/// a subset or tweak the values for specific themes depending on your usage. E.g.
20/// `EmbeddedThemeName::{Ansi, Base16, Base16_256}` are all terminal related themes,
21/// `EmbeddedThemeName::InspiredGithub` uses a full-white background which wouldn't be a good fit
22/// for a static site generator, etc.
23///
24/// # Example
25///
26/// ```
27/// use two_face::theme::{extra, EmbeddedThemeName};
28///
29/// let theme_set = extra();
30/// let nord = theme_set.get(EmbeddedThemeName::Nord);
31/// ```
32pub fn extra() -> EmbeddedLazyThemeSet {
33    let theme_set =
34        syntect::dumps::from_uncompressed_data(include_bytes!("../../generated/themes.bin"))
35            .unwrap();
36    EmbeddedLazyThemeSet(theme_set)
37}
38
39/// A [`LazyThemeSet`] where we know all of the themes that are included
40pub struct EmbeddedLazyThemeSet(LazyThemeSet);
41
42impl EmbeddedLazyThemeSet {
43    /// Gets a single theme from the set
44    ///
45    /// An infallible version of [`LazyThemeSet::get()`]
46    ///
47    /// # Example
48    ///
49    /// ```
50    /// use two_face::theme::{extra, EmbeddedThemeName};
51    ///
52    /// let theme_set = extra();
53    /// // Loads the theme
54    /// let nord1 = theme_set.get(EmbeddedThemeName::Nord);
55    /// // Reuses the same loaded theme
56    /// let nord2 = theme_set.get(EmbeddedThemeName::Nord);
57    /// ```
58    pub fn get(&self, name: EmbeddedThemeName) -> &Theme {
59        self.0.get(name.as_name()).unwrap()
60    }
61
62    /// A listing of all the themes included in [`EmbeddedLazyThemeSet`]
63    ///
64    /// # Example
65    ///
66    /// ```
67    /// use two_face::theme::{EmbeddedThemeName, EmbeddedLazyThemeSet};
68    ///
69    /// // Nord should be included
70    /// assert!(EmbeddedLazyThemeSet::theme_names().contains(&EmbeddedThemeName::Nord));
71    /// ```
72    pub fn theme_names() -> &'static [EmbeddedThemeName] {
73        &[
74            EmbeddedThemeName::Ansi,
75            EmbeddedThemeName::Base16,
76            EmbeddedThemeName::Base16EightiesDark,
77            EmbeddedThemeName::Base16MochaDark,
78            EmbeddedThemeName::Base16OceanDark,
79            EmbeddedThemeName::Base16OceanLight,
80            EmbeddedThemeName::Base16_256,
81            EmbeddedThemeName::ColdarkCold,
82            EmbeddedThemeName::ColdarkDark,
83            EmbeddedThemeName::DarkNeon,
84            EmbeddedThemeName::Dracula,
85            EmbeddedThemeName::Github,
86            EmbeddedThemeName::GruvboxDark,
87            EmbeddedThemeName::GruvboxLight,
88            EmbeddedThemeName::InspiredGithub,
89            EmbeddedThemeName::Leet,
90            EmbeddedThemeName::MonokaiExtended,
91            EmbeddedThemeName::MonokaiExtendedBright,
92            EmbeddedThemeName::MonokaiExtendedLight,
93            EmbeddedThemeName::MonokaiExtendedOrigin,
94            EmbeddedThemeName::Nord,
95            EmbeddedThemeName::OneHalfDark,
96            EmbeddedThemeName::OneHalfLight,
97            EmbeddedThemeName::SolarizedDark,
98            EmbeddedThemeName::SolarizedLight,
99            EmbeddedThemeName::SublimeSnazzy,
100            EmbeddedThemeName::TwoDark,
101            EmbeddedThemeName::VisualStudioDarkPlus,
102            EmbeddedThemeName::Zenburn,
103        ]
104    }
105}
106
107impl From<EmbeddedLazyThemeSet> for LazyThemeSet {
108    fn from(embedded: EmbeddedLazyThemeSet) -> Self {
109        embedded.0
110    }
111}
112
113impl From<&EmbeddedLazyThemeSet> for ThemeSet {
114    fn from(embedded: &EmbeddedLazyThemeSet) -> Self {
115        Self::from(&embedded.0)
116    }
117}
118
119// NOTE: doc comment HTML is copied from the tests/docs_watchdog/theme.rs tests
120/// An enum that represents all themes included in [`EmbeddedLazyThemeSet`]
121///
122/// A demo is included for how each theme highlights the following Elixir snippet
123///
124/// ```elixir
125/// There currently is no ternary operator like  true ? "yes" : "no"
126/// # So the following is suggested
127/// "no" = if 1 == 0, do: "yes", else: "no"
128/// ```
129#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
130#[cfg_attr(test, derive(strum::EnumIter))]
131pub enum EmbeddedThemeName {
132    /// ANSI
133    ///
134    /// _Doesn't display as HTML well_
135    Ansi,
136    /// Base16
137    ///
138    /// _Doesn't display as HTML well_
139    Base16,
140    /// Base16 Eighties Dark
141    ///
142    /// <pre style="background-color:#2d2d2d;">
143    /// <span style="color:#747369;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
144    /// </span><span style="color:#747369;"># So the following is suggested
145    /// </span><span style="color:#d3d0c8;">&quot;</span><span style="color:#99cc99;">no</span><span style="color:#d3d0c8;">&quot; = </span><span style="color:#cc99cc;">if </span><span style="color:#f99157;">1 </span><span style="color:#d3d0c8;">== </span><span style="color:#f99157;">0</span><span style="color:#d3d0c8;">, </span><span style="color:#f99157;">do: </span><span style="color:#d3d0c8;">&quot;</span><span style="color:#99cc99;">yes</span><span style="color:#d3d0c8;">&quot;, </span><span style="color:#f99157;">else: </span><span style="color:#d3d0c8;">&quot;</span><span style="color:#99cc99;">no</span><span style="color:#d3d0c8;">&quot;
146    /// </span></pre>
147    Base16EightiesDark,
148    /// Base16 Mocha Dark Theme
149    ///
150    /// <pre style="background-color:#3b3228;">
151    /// <span style="color:#7e705a;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
152    /// </span><span style="color:#7e705a;"># So the following is suggested
153    /// </span><span style="color:#d0c8c6;">&quot;</span><span style="color:#beb55b;">no</span><span style="color:#d0c8c6;">&quot; = </span><span style="color:#a89bb9;">if </span><span style="color:#d28b71;">1 </span><span style="color:#d0c8c6;">== </span><span style="color:#d28b71;">0</span><span style="color:#d0c8c6;">, </span><span style="color:#d28b71;">do: </span><span style="color:#d0c8c6;">&quot;</span><span style="color:#beb55b;">yes</span><span style="color:#d0c8c6;">&quot;, </span><span style="color:#d28b71;">else: </span><span style="color:#d0c8c6;">&quot;</span><span style="color:#beb55b;">no</span><span style="color:#d0c8c6;">&quot;
154    /// </span></pre>
155    Base16MochaDark,
156    /// Base16 Ocean Dark
157    ///
158    /// <pre style="background-color:#2b303b;">
159    /// <span style="color:#65737e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
160    /// </span><span style="color:#65737e;"># So the following is suggested
161    /// </span><span style="color:#c0c5ce;">&quot;</span><span style="color:#a3be8c;">no</span><span style="color:#c0c5ce;">&quot; = </span><span style="color:#b48ead;">if </span><span style="color:#d08770;">1 </span><span style="color:#c0c5ce;">== </span><span style="color:#d08770;">0</span><span style="color:#c0c5ce;">, </span><span style="color:#d08770;">do: </span><span style="color:#c0c5ce;">&quot;</span><span style="color:#a3be8c;">yes</span><span style="color:#c0c5ce;">&quot;, </span><span style="color:#d08770;">else: </span><span style="color:#c0c5ce;">&quot;</span><span style="color:#a3be8c;">no</span><span style="color:#c0c5ce;">&quot;
162    /// </span></pre>
163    Base16OceanDark,
164    /// Base16 Ocean Light
165    ///
166    /// <pre style="background-color:#eff1f5;">
167    /// <span style="color:#a7adba;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
168    /// </span><span style="color:#a7adba;"># So the following is suggested
169    /// </span><span style="color:#4f5b66;">&quot;</span><span style="color:#a3be8c;">no</span><span style="color:#4f5b66;">&quot; = </span><span style="color:#b48ead;">if </span><span style="color:#d08770;">1 </span><span style="color:#4f5b66;">== </span><span style="color:#d08770;">0</span><span style="color:#4f5b66;">, </span><span style="color:#d08770;">do: </span><span style="color:#4f5b66;">&quot;</span><span style="color:#a3be8c;">yes</span><span style="color:#4f5b66;">&quot;, </span><span style="color:#d08770;">else: </span><span style="color:#4f5b66;">&quot;</span><span style="color:#a3be8c;">no</span><span style="color:#4f5b66;">&quot;
170    /// </span></pre>
171    Base16OceanLight,
172    /// Base16 256
173    ///
174    /// _Doesn't display as HTML well_
175    Base16_256,
176    /// Coldark-Cold
177    ///
178    /// <pre style="background-color:#e3eaf2;">
179    /// <span style="color:#3c526d;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
180    /// </span><span style="color:#3c526d;"># So the following is suggested
181    /// </span><span style="color:#116b00;">&quot;no&quot; </span><span style="color:#a04900;">= if </span><span style="color:#755f00;">1 </span><span style="color:#a04900;">== </span><span style="color:#755f00;">0</span><span style="color:#111b27;">, </span><span style="color:#005a8e;">do</span><span style="color:#111b27;">: </span><span style="color:#116b00;">&quot;yes&quot;</span><span style="color:#111b27;">, </span><span style="color:#005a8e;">else</span><span style="color:#111b27;">: </span><span style="color:#116b00;">&quot;no&quot;
182    /// </span></pre>
183    ColdarkCold,
184    /// Coldark-Dark
185    ///
186    /// <pre style="background-color:#111b27;">
187    /// <span style="color:#8da1b9;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
188    /// </span><span style="color:#8da1b9;"># So the following is suggested
189    /// </span><span style="color:#91d076;">&quot;no&quot; </span><span style="color:#e9ae7e;">= if </span><span style="color:#e6d37a;">1 </span><span style="color:#e9ae7e;">== </span><span style="color:#e6d37a;">0</span><span style="color:#e3eaf2;">, </span><span style="color:#6cb8e6;">do</span><span style="color:#e3eaf2;">: </span><span style="color:#91d076;">&quot;yes&quot;</span><span style="color:#e3eaf2;">, </span><span style="color:#6cb8e6;">else</span><span style="color:#e3eaf2;">: </span><span style="color:#91d076;">&quot;no&quot;
190    /// </span></pre>
191    ColdarkDark,
192    /// Dark Neon
193    ///
194    /// <pre style="background-color:#000000;">
195    /// <span style="background-color:#212121;color:#7c7c7c;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
196    /// </span><span style="background-color:#212121;color:#7c7c7c;"># So the following is suggested
197    /// </span><span style="color:#ccff66;">&quot;no&quot; </span><span style="color:#aaaaaa;">= </span><span style="color:#66ccff;">if </span><span style="font-weight:bold;color:#ff73fd;">1 </span><span style="color:#aaaaaa;">== </span><span style="font-weight:bold;color:#ff73fd;">0</span><span style="color:#ffffff;">, </span><span style="color:#99cc99;">do: </span><span style="color:#ccff66;">&quot;yes&quot;</span><span style="color:#ffffff;">, </span><span style="color:#99cc99;">else: </span><span style="color:#ccff66;">&quot;no&quot;
198    /// </span></pre>
199    DarkNeon,
200    /// Dracula
201    ///
202    /// <pre style="background-color:#282a36;">
203    /// <span style="color:#6272a4;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
204    /// </span><span style="color:#6272a4;"># So the following is suggested
205    /// </span><span style="color:#f1fa8c;">&quot;no&quot; </span><span style="color:#ff79c6;">= if </span><span style="color:#bd93f9;">1 </span><span style="color:#ff79c6;">== </span><span style="color:#bd93f9;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#bd93f9;">do: </span><span style="color:#f1fa8c;">&quot;yes&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#bd93f9;">else: </span><span style="color:#f1fa8c;">&quot;no&quot;
206    /// </span></pre>
207    Dracula,
208    /// GitHub
209    ///
210    /// <pre style="background-color:#ffffff;">
211    /// <span style="color:#969896;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
212    /// </span><span style="color:#969896;"># So the following is suggested
213    /// </span><span style="color:#183691;">&quot;no&quot; </span><span style="color:#a71d5d;">= if </span><span style="color:#0086b3;">1 </span><span style="color:#a71d5d;">== </span><span style="color:#0086b3;">0</span><span style="color:#333333;">, </span><span style="color:#0086b3;">do: </span><span style="color:#183691;">&quot;yes&quot;</span><span style="color:#333333;">, </span><span style="color:#0086b3;">else: </span><span style="color:#183691;">&quot;no&quot;
214    /// </span></pre>
215    Github,
216    /// gruvbox (Dark)
217    ///
218    /// <pre style="background-color:#282828;">
219    /// <span style="font-style:italic;color:#928374;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
220    /// </span><span style="font-style:italic;color:#928374;"># So the following is suggested
221    /// </span><span style="color:#fbf1c7;">&quot;</span><span style="color:#b8bb26;">no</span><span style="color:#fbf1c7;">&quot; </span><span style="color:#8ec07c;">= </span><span style="color:#fb4934;">if </span><span style="color:#d3869b;">1 </span><span style="color:#8ec07c;">== </span><span style="color:#d3869b;">0</span><span style="color:#fbf1c7;">, </span><span style="color:#d3869b;">do</span><span style="color:#fbf1c7;">: &quot;</span><span style="color:#b8bb26;">yes</span><span style="color:#fbf1c7;">&quot;, </span><span style="color:#d3869b;">else</span><span style="color:#fbf1c7;">: &quot;</span><span style="color:#b8bb26;">no</span><span style="color:#fbf1c7;">&quot;
222    /// </span></pre>
223    GruvboxDark,
224    /// gruvbox (Light)
225    ///
226    /// <pre style="background-color:#fbf1c7;">
227    /// <span style="font-style:italic;color:#928374;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
228    /// </span><span style="font-style:italic;color:#928374;"># So the following is suggested
229    /// </span><span style="color:#282828;">&quot;</span><span style="color:#79740e;">no</span><span style="color:#282828;">&quot; </span><span style="color:#427b58;">= </span><span style="color:#9d0006;">if </span><span style="color:#8f3f71;">1 </span><span style="color:#427b58;">== </span><span style="color:#8f3f71;">0</span><span style="color:#282828;">, </span><span style="color:#8f3f71;">do</span><span style="color:#282828;">: &quot;</span><span style="color:#79740e;">yes</span><span style="color:#282828;">&quot;, </span><span style="color:#8f3f71;">else</span><span style="color:#282828;">: &quot;</span><span style="color:#79740e;">no</span><span style="color:#282828;">&quot;
230    /// </span></pre>
231    GruvboxLight,
232    /// Inspired GitHub
233    ///
234    /// <pre style="background-color:#ffffff;">
235    /// <span style="font-style:italic;color:#969896;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
236    /// </span><span style="font-style:italic;color:#969896;"># So the following is suggested
237    /// </span><span style="color:#183691;">&quot;no&quot; </span><span style="font-weight:bold;color:#a71d5d;">= if </span><span style="color:#0086b3;">1 </span><span style="font-weight:bold;color:#a71d5d;">== </span><span style="color:#0086b3;">0</span><span style="color:#323232;">, </span><span style="color:#0086b3;">do: </span><span style="color:#183691;">&quot;yes&quot;</span><span style="color:#323232;">, </span><span style="color:#0086b3;">else: </span><span style="color:#183691;">&quot;no&quot;
238    /// </span></pre>
239    InspiredGithub,
240    /// 1337
241    ///
242    /// <pre style="background-color:#191919;">
243    /// <span style="color:#6d6d6d;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
244    /// </span><span style="color:#6d6d6d;"># So the following is suggested
245    /// </span><span style="color:#ffffff;">&quot;</span><span style="color:#fbe3bf;">no</span><span style="color:#ffffff;">&quot; </span><span style="color:#ff5e5e;">= if </span><span style="color:#fdb082;">1 </span><span style="color:#ff5e5e;">== </span><span style="color:#fdb082;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#fdb082;">do: </span><span style="color:#ffffff;">&quot;</span><span style="color:#fbe3bf;">yes</span><span style="color:#ffffff;">&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#fdb082;">else: </span><span style="color:#ffffff;">&quot;</span><span style="color:#fbe3bf;">no</span><span style="color:#ffffff;">&quot;
246    /// </span></pre>
247    Leet,
248    /// Monokai Extended
249    ///
250    /// <pre style="background-color:#222222;">
251    /// <span style="color:#75715e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
252    /// </span><span style="color:#75715e;"># So the following is suggested
253    /// </span><span style="color:#e6db74;">&quot;no&quot; </span><span style="color:#f92672;">= if </span><span style="color:#be84ff;">1 </span><span style="color:#f92672;">== </span><span style="color:#be84ff;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#be84ff;">do: </span><span style="color:#e6db74;">&quot;yes&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#be84ff;">else: </span><span style="color:#e6db74;">&quot;no&quot;
254    /// </span></pre>
255    MonokaiExtended,
256    /// Monokai Extended Bright
257    ///
258    /// <pre style="background-color:#272822;">
259    /// <span style="color:#75715e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
260    /// </span><span style="color:#75715e;"># So the following is suggested
261    /// </span><span style="color:#e6db74;">&quot;no&quot; </span><span style="color:#f92672;">= if </span><span style="color:#ae81ff;">1 </span><span style="color:#f92672;">== </span><span style="color:#ae81ff;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#ae81ff;">do: </span><span style="color:#e6db74;">&quot;yes&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#ae81ff;">else: </span><span style="color:#e6db74;">&quot;no&quot;
262    /// </span></pre>
263    MonokaiExtendedBright,
264    /// Monokai Extended Light
265    ///
266    /// <pre style="background-color:#fafafa;">
267    /// <span style="color:#75715e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
268    /// </span><span style="color:#75715e;"># So the following is suggested
269    /// </span><span style="color:#998f2f;">&quot;no&quot; </span><span style="color:#f9005a;">= if </span><span style="color:#684d99;">1 </span><span style="color:#f9005a;">== </span><span style="color:#684d99;">0</span><span style="color:#49483e;">, </span><span style="color:#684d99;">do: </span><span style="color:#998f2f;">&quot;yes&quot;</span><span style="color:#49483e;">, </span><span style="color:#684d99;">else: </span><span style="color:#998f2f;">&quot;no&quot;
270    /// </span></pre>
271    MonokaiExtendedLight,
272    /// Monokai Extended Origin
273    ///
274    /// <pre style="background-color:#272822;">
275    /// <span style="color:#75715e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
276    /// </span><span style="color:#75715e;"># So the following is suggested
277    /// </span><span style="color:#e6db74;">&quot;no&quot; </span><span style="color:#f92672;">= if </span><span style="color:#ae81ff;">1 </span><span style="color:#f92672;">== </span><span style="color:#ae81ff;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#ae81ff;">do: </span><span style="color:#e6db74;">&quot;yes&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#ae81ff;">else: </span><span style="color:#e6db74;">&quot;no&quot;
278    /// </span></pre>
279    MonokaiExtendedOrigin,
280    /// Nord
281    ///
282    /// <pre style="background-color:#2e3440;">
283    /// <span style="color:#616e88;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
284    /// </span><span style="color:#616e88;"># So the following is suggested
285    /// </span><span style="color:#a3be8c;">&quot;no&quot; </span><span style="color:#81a1c1;">= if </span><span style="color:#b48ead;">1 </span><span style="color:#81a1c1;">== </span><span style="color:#b48ead;">0</span><span style="color:#eceff4;">, </span><span style="color:#d8dee9;">do: </span><span style="color:#a3be8c;">&quot;yes&quot;</span><span style="color:#eceff4;">, </span><span style="color:#d8dee9;">else: </span><span style="color:#a3be8c;">&quot;no&quot;
286    /// </span></pre>
287    Nord,
288    /// One Half Dark
289    ///
290    /// <pre style="background-color:#282c34;">
291    /// <span style="color:#5c6370;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
292    /// </span><span style="color:#5c6370;"># So the following is suggested
293    /// </span><span style="color:#98c379;">&quot;no&quot; </span><span style="color:#c678dd;">= if </span><span style="color:#e5c07b;">1 </span><span style="color:#c678dd;">== </span><span style="color:#e5c07b;">0</span><span style="color:#dcdfe4;">, </span><span style="color:#e5c07b;">do: </span><span style="color:#98c379;">&quot;yes&quot;</span><span style="color:#dcdfe4;">, </span><span style="color:#e5c07b;">else: </span><span style="color:#98c379;">&quot;no&quot;
294    /// </span></pre>
295    OneHalfDark,
296    /// One Half Light
297    ///
298    /// <pre style="background-color:#fafafa;">
299    /// <span style="color:#a0a1a7;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
300    /// </span><span style="color:#a0a1a7;"># So the following is suggested
301    /// </span><span style="color:#50a14f;">&quot;no&quot; </span><span style="color:#a626a4;">= if </span><span style="color:#c18401;">1 </span><span style="color:#a626a4;">== </span><span style="color:#c18401;">0</span><span style="color:#383a42;">, </span><span style="color:#c18401;">do: </span><span style="color:#50a14f;">&quot;yes&quot;</span><span style="color:#383a42;">, </span><span style="color:#c18401;">else: </span><span style="color:#50a14f;">&quot;no&quot;
302    /// </span></pre>
303    OneHalfLight,
304    /// Solarized (dark)
305    ///
306    /// <pre style="background-color:#002b36;">
307    /// <span style="color:#586e75;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
308    /// </span><span style="color:#586e75;"># So the following is suggested
309    /// </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">no</span><span style="color:#839496;">&quot; </span><span style="color:#657b83;">= </span><span style="color:#859900;">if </span><span style="color:#6c71c4;">1 </span><span style="color:#657b83;">== </span><span style="color:#6c71c4;">0</span><span style="color:#839496;">, </span><span style="color:#cb4b16;">do: </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">yes</span><span style="color:#839496;">&quot;, </span><span style="color:#cb4b16;">else: </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">no</span><span style="color:#839496;">&quot;
310    /// </span></pre>
311    SolarizedDark,
312    /// Solarized (light)
313    ///
314    /// <pre style="background-color:#fdf6e3;">
315    /// <span style="color:#93a1a1;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
316    /// </span><span style="color:#93a1a1;"># So the following is suggested
317    /// </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">no</span><span style="color:#839496;">&quot; </span><span style="color:#657b83;">= </span><span style="color:#859900;">if </span><span style="color:#6c71c4;">1 </span><span style="color:#657b83;">== </span><span style="color:#6c71c4;">0</span><span style="color:#657b83;">, </span><span style="color:#cb4b16;">do: </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">yes</span><span style="color:#839496;">&quot;</span><span style="color:#657b83;">, </span><span style="color:#cb4b16;">else: </span><span style="color:#839496;">&quot;</span><span style="color:#2aa198;">no</span><span style="color:#839496;">&quot;
318    /// </span></pre>
319    SolarizedLight,
320    /// Sublime Snazzy
321    ///
322    /// <pre style="background-color:#282a36;">
323    /// <span style="color:#686868;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
324    /// </span><span style="color:#686868;"># So the following is suggested
325    /// </span><span style="color:#f3f99d;">&quot;no&quot; </span><span style="color:#ff5c57;">= if </span><span style="color:#f1f1f0;">1 </span><span style="color:#ff5c57;">== </span><span style="color:#f1f1f0;">0</span><span style="color:#f8f8f2;">, </span><span style="color:#5af78e;">do: </span><span style="color:#f3f99d;">&quot;yes&quot;</span><span style="color:#f8f8f2;">, </span><span style="color:#5af78e;">else: </span><span style="color:#f3f99d;">&quot;no&quot;
326    /// </span></pre>
327    SublimeSnazzy,
328    /// TwoDark
329    ///
330    /// <pre style="background-color:#282c34;">
331    /// <span style="font-style:italic;color:#5c6370;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
332    /// </span><span style="font-style:italic;color:#5c6370;"># So the following is suggested
333    /// </span><span style="color:#98c379;">&quot;no&quot; </span><span style="color:#abb2bf;">= </span><span style="color:#c678dd;">if </span><span style="color:#d19a66;">1 </span><span style="color:#abb2bf;">== </span><span style="color:#d19a66;">0</span><span style="color:#abb2bf;">, </span><span style="color:#d19a66;">do: </span><span style="color:#98c379;">&quot;yes&quot;</span><span style="color:#abb2bf;">, </span><span style="color:#d19a66;">else: </span><span style="color:#98c379;">&quot;no&quot;
334    /// </span></pre>
335    TwoDark,
336    /// Visual Studio Dark+
337    ///
338    /// <pre style="background-color:#1e1e1e;">
339    /// <span style="color:#608b4e;"># There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
340    /// </span><span style="color:#608b4e;"># So the following is suggested
341    /// </span><span style="color:#d69d85;">&quot;no&quot; </span><span style="color:#dcdcdc;">= </span><span style="color:#c586c0;">if </span><span style="color:#b5cea8;">1 </span><span style="color:#dcdcdc;">== </span><span style="color:#b5cea8;">0</span><span style="color:#dcdcdc;">, </span><span style="color:#b4cea8;">do: </span><span style="color:#d69d85;">&quot;yes&quot;</span><span style="color:#dcdcdc;">, </span><span style="color:#b4cea8;">else: </span><span style="color:#d69d85;">&quot;no&quot;
342    /// </span></pre>
343    VisualStudioDarkPlus,
344    /// zenburn
345    ///
346    /// <pre style="background-color:#3f3f3f;">
347    /// <span style="color:#a0cfa1;">#</span><span style="color:#87ae86;"> There currently is no ternary operator like  true ? &quot;yes&quot; : &quot;no&quot;
348    /// </span><span style="color:#a0cfa1;">#</span><span style="color:#87ae86;"> So the following is suggested
349    /// </span><span style="color:#d6d6d680;">&quot;</span><span style="color:#d68686;">no</span><span style="color:#d6d6d680;">&quot; </span><span style="color:#ececec;">= </span><span style="color:#fed6af;">if </span><span style="font-weight:bold;color:#87d6d5;">1 </span><span style="color:#ececec;">== </span><span style="font-weight:bold;color:#87d6d5;">0</span><span style="color:#dedede;">, </span><span style="font-weight:bold;color:#d58684;">do: </span><span style="color:#d6d6d680;">&quot;</span><span style="color:#d68686;">yes</span><span style="color:#d6d6d680;">&quot;</span><span style="color:#dedede;">, </span><span style="font-weight:bold;color:#d58684;">else: </span><span style="color:#d6d6d680;">&quot;</span><span style="color:#d68686;">no</span><span style="color:#d6d6d680;">&quot;
350    /// </span></pre>
351    Zenburn,
352}
353
354impl EmbeddedThemeName {
355    /// The name of each embedded theme
356    ///
357    /// This matches the key used for each theme in [`ThemeSet`]'s `themes`
358    ///
359    /// ```
360    /// use two_face::theme::EmbeddedThemeName;
361    ///
362    /// assert_eq!(
363    ///     EmbeddedThemeName::Leet.as_name(),
364    ///     "1337",
365    /// );
366    /// assert_eq!(
367    ///     EmbeddedThemeName::VisualStudioDarkPlus.as_name(),
368    ///     "Visual Studio Dark+",
369    /// );
370    /// ```
371    pub fn as_name(self) -> &'static str {
372        match self {
373            Self::Ansi => "ansi",
374            Self::Base16 => "base16",
375            Self::Base16EightiesDark => "base16-eighties.dark",
376            Self::Base16MochaDark => "base16-mocha.dark",
377            Self::Base16OceanDark => "base16-ocean.dark",
378            Self::Base16OceanLight => "base16-ocean.light",
379            Self::Base16_256 => "base16-256",
380            Self::ColdarkCold => "Coldark-Cold",
381            Self::ColdarkDark => "Coldark-Dark",
382            Self::DarkNeon => "DarkNeon",
383            Self::Dracula => "Dracula",
384            Self::Github => "GitHub",
385            Self::GruvboxDark => "gruvbox-dark",
386            Self::GruvboxLight => "gruvbox-light",
387            Self::InspiredGithub => "InspiredGitHub",
388            Self::Leet => "1337",
389            Self::MonokaiExtended => "Monokai Extended",
390            Self::MonokaiExtendedBright => "Monokai Extended Bright",
391            Self::MonokaiExtendedLight => "Monokai Extended Light",
392            Self::MonokaiExtendedOrigin => "Monokai Extended Origin",
393            Self::Nord => "Nord",
394            Self::OneHalfDark => "OneHalfDark",
395            Self::OneHalfLight => "OneHalfLight",
396            Self::SolarizedDark => "Solarized (dark)",
397            Self::SolarizedLight => "Solarized (light)",
398            Self::SublimeSnazzy => "Sublime Snazzy",
399            Self::TwoDark => "TwoDark",
400            Self::VisualStudioDarkPlus => "Visual Studio Dark+",
401            Self::Zenburn => "zenburn",
402        }
403    }
404}
405
406#[cfg(test)]
407mod tests {
408    use std::collections::BTreeSet;
409
410    use super::*;
411
412    use strum::IntoEnumIterator;
413
414    #[test]
415    fn embedded_theme_is_exhaustive() {
416        let theme_set = extra();
417        for theme_name in EmbeddedThemeName::iter() {
418            println!("Getting: {:?}", theme_name);
419            let _ = theme_set.get(theme_name);
420        }
421
422        assert_eq!(theme_set.0.themes.len(), EmbeddedThemeName::iter().len());
423        assert_eq!(
424            EmbeddedLazyThemeSet::theme_names().len(),
425            EmbeddedThemeName::iter().len()
426        );
427
428        let all_unique: BTreeSet<_> = EmbeddedLazyThemeSet::theme_names().iter().collect();
429        assert_eq!(all_unique.len(), EmbeddedLazyThemeSet::theme_names().len());
430    }
431}