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