pub const CURRENT: &str = "●";
pub const AVAILABLE: &str = "○";
pub const SELECTION: &str = "▸";
pub const USER: &str = "▎";
pub const TRANSCRIPT_RAIL: &str = "▏ ";
pub const DONE: &str = "✓";
pub const FAILED: &str = "✕";
pub const ATTENTION: &str = "◆";
pub const READY: &str = "○";
pub const PAUSED: &str = "⏸";
pub const ROLE_MANAGER: &str = "◆";
pub const ROLE_BUILDER: &str = "■";
pub const ROLE_REVIEWER: &str = "◇";
pub const ROLE_VERIFIER: &str = CURRENT;
pub const ROLE_SYNTHESIZER: &str = "▲";
pub const NEUTRAL: &str = "·";
#[must_use]
pub const fn selection_marker(selected: bool) -> &'static str {
if selected { SELECTION } else { " " }
}
#[must_use]
pub fn ascii_fallback(symbol: &str) -> Option<&'static str> {
match symbol {
"─" | "━" | "═" | "╌" | "╍" | "┄" | "┅" | "┈" | "┉" | "—" | "–" => {
Some("-")
}
"│" | "┃" | "║" | "╎" | "╏" | "▏" | "▎" | "▍" | "▌" | "▐" | "▕" => {
Some("|")
}
"┌" | "┐" | "└" | "┘" | "╭" | "╮" | "╰" | "╯" | "├" | "┤" | "┬" | "┴" | "┼" => {
Some("+")
}
"█" | "▉" | "▊" | "▋" | "▀" | "▄" | "▅" | "▆" | "▇" | "▙" | "▛" | "▜" | "▟" | "▰" => {
Some("#")
}
"▁" | "▂" | "▃" => Some("_"),
"▖" | "▗" | "▘" | "▝" => Some("."),
"▚" => Some("\\"),
"▞" => Some("/"),
"░" | "▒" | "▓" => Some(":"),
"▱" => Some("-"),
"▶" | "▷" | "▸" | "›" | "❯" | "→" | "↗" | "↘" | "»" => Some(">"),
"◀" | "◂" | "‹" | "❮" | "←" | "↖" | "↙" | "«" => Some("<"),
"▼" | "▾" | "▽" | "↓" => Some("v"),
"▲" | "△" | "↑" => Some("^"),
"◆" | "◇" | "♦" | "✦" | "◍" | "◉" | "★" | "☆" => Some("*"),
"■" | "□" | "▪" | "▫" | "◼" | "◻" => Some("#"),
"●" | "○" | "∘" | "•" | "·" | "☐" => Some("."),
"◌" | "˚" | "°" | "◦" => Some("o"),
"✓" | "✔" | "☑" => Some("Y"),
"✕" | "×" | "⊘" | "✗" | "✘" | "☒" => Some("X"),
"⏸" => Some("="),
"≈≈>" => Some("~>"),
"≈" | "~" => Some("~"),
"🐳" | "🐋" => Some("w"),
"…" => Some("."),
_ => None,
}
}
#[must_use]
pub fn braille_ascii_fallback(ch: char) -> Option<&'static str> {
if !(('\u{2800}'..='\u{28FF}').contains(&ch)) {
return None;
}
let dots = ((ch as u32) - 0x2800).count_ones();
Some(match dots {
0 => " ",
1..=2 => ".",
3..=4 => ":",
5..=6 => "+",
_ => "#",
})
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn charter_has_narrow_semantic_fallbacks() {
for (rich, safe) in [
(SELECTION, ">"),
("▷", ">"),
(CURRENT, "."),
(USER, "|"),
(DONE, "Y"),
(FAILED, "X"),
(ATTENTION, "*"),
("≈≈>", "~>"),
("≈", "~"),
("~", "~"),
] {
assert_eq!(ascii_fallback(rich), Some(safe));
}
assert_eq!(braille_ascii_fallback('\u{2801}'), Some("."));
assert_eq!(braille_ascii_fallback('A'), None);
}
}