two_face/theme/
mod.rs

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