Skip to main content

yui/
icons.rs

1//! Icon character sets for terminal output.
2//!
3//! Three modes (see [`crate::config::IconsMode`]):
4//!   - `Unicode` (default): `✓ ✗ → ─` — universally renderable
5//!   - `Nerd`: Nerd-Font glyphs — requires a patched font
6//!   - `Ascii`: `[+] [-] -> -` — pure ASCII fallback for CI logs
7
8use crate::config::IconsMode;
9
10#[derive(Debug, Clone, Copy)]
11pub struct Icons {
12    pub active: &'static str,
13    pub inactive: &'static str,
14    pub arrow: &'static str,
15    pub sep: char,
16}
17
18impl Icons {
19    pub const UNICODE: Self = Self {
20        active: "\u{2713}",   // ✓
21        inactive: "\u{2717}", // ✗
22        arrow: "\u{2192}",    // →
23        sep: '\u{2500}',      // ─
24    };
25    pub const NERD: Self = Self {
26        active: "\u{f058}",   //   nf-fa-check_circle
27        inactive: "\u{f057}", //   nf-fa-times_circle
28        arrow: "\u{2192}",    // → (no need for a special arrow glyph)
29        sep: '\u{2500}',      // ─
30    };
31    pub const ASCII: Self = Self {
32        active: "[+]",
33        inactive: "[-]",
34        arrow: "->",
35        sep: '-',
36    };
37
38    pub const fn for_mode(mode: IconsMode) -> Self {
39        match mode {
40            IconsMode::Unicode => Self::UNICODE,
41            IconsMode::Nerd => Self::NERD,
42            IconsMode::Ascii => Self::ASCII,
43        }
44    }
45}