1#![allow(missing_docs)]
2
3use serde::{Deserialize, Serialize};
4use std::str::FromStr;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
8#[serde(rename_all = "snake_case")]
9pub enum GlyphSet {
10 Unicode,
11 Ascii,
12 Nerd,
13}
14
15impl Default for GlyphSet {
16 fn default() -> Self {
17 GlyphSet::Unicode
18 }
19}
20
21impl std::fmt::Display for GlyphSet {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 match self {
24 GlyphSet::Unicode => write!(f, "unicode"),
25 GlyphSet::Ascii => write!(f, "ascii"),
26 GlyphSet::Nerd => write!(f, "nerd"),
27 }
28 }
29}
30
31impl FromStr for GlyphSet {
32 type Err = String;
33 fn from_str(s: &str) -> Result<Self, Self::Err> {
34 match s.to_lowercase().as_str() {
35 "unicode" => Ok(GlyphSet::Unicode),
36 "ascii" => Ok(GlyphSet::Ascii),
37 "nerd" => Ok(GlyphSet::Nerd),
38 _ => Err(format!("Unknown glyph set: {s}")),
39 }
40 }
41}
42
43impl GlyphSet {
44 pub fn label(&self) -> &'static str {
45 match self {
46 GlyphSet::Unicode => "Unicode",
47 GlyphSet::Ascii => "ASCII",
48 GlyphSet::Nerd => "Nerd",
49 }
50 }
51}
52
53impl GlyphSet {
54 pub fn next(self) -> Self {
56 match self {
57 GlyphSet::Unicode => GlyphSet::Ascii,
58 GlyphSet::Ascii => GlyphSet::Nerd,
59 GlyphSet::Nerd => GlyphSet::Unicode,
60 }
61 }
62}
63
64pub mod nerd {
71 pub const MODEL: &str = "\u{F06A9} ";
73 pub const THINK: &str = "\u{F06E8} ";
75 pub const RUN: &str = "\u{F04C5} ";
77 pub const DIR: &str = "\u{F024B} ";
79 pub const GIT: &str = "\u{F02A2} ";
81 pub const CTX: &str = "\u{F01BC} ";
83 pub const BRAIN: &str = "\u{F09E0}";
85}
86pub type UnknownGlyphSet = String;