Skip to main content

oxicode/symbols/
mod.rs

1#![allow(missing_docs)]
2
3use serde::{Deserialize, Serialize};
4use std::str::FromStr;
5
6/// Minimal glyph set selection for oxicode settings.
7#[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    /// Cycle order for the settings overlay: unicode → ascii → nerd.
55    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
64/// Nerd Font icons for the composer's context row (`glyph_set = "nerd"`).
65///
66/// All glyphs are Nerd Font private-use codepoints (Material Design
67/// range) — **never emoji**, so they render monochrome and width-1 in
68/// any terminal with a patched font. Terminals without the font show
69/// the fallback box; users opt in via settings.
70pub mod nerd {
71    /// Robot — the active model.
72    pub const MODEL: &str = "\u{F06A9} ";
73    /// Lightbulb — the thinking level.
74    pub const THINK: &str = "\u{F06E8} ";
75    /// Rocket — the live run stage.
76    pub const RUN: &str = "\u{F04C5} ";
77    /// Folder — the working directory.
78    pub const DIR: &str = "\u{F024B} ";
79    /// Git logo — the branch.
80    pub const GIT: &str = "\u{F02A2} ";
81    /// Database — context-window usage.
82    pub const CTX: &str = "\u{F01BC} ";
83    /// Brain — the oxibrain daemon chip.
84    pub const BRAIN: &str = "\u{F09E0}";
85}
86pub type UnknownGlyphSet = String;