magi-code 0.105.1

Repository-aware CLI coding agent for terminal work
Documentation
/// Return complete two-row lettering, or let the caller use compact text.
pub(super) fn block_title_rows(title: &str, width: usize) -> Option<[String; 2]> {
    let mut rows = [String::new(), String::new()];
    let mut used = 0;
    for character in title.chars() {
        let glyph = match character.to_ascii_uppercase() {
            'A' => ["▄▀█", "█▀█"],
            'B' => ["█▄▄", "█▄█"],
            'C' => ["█▀▀", "█▄▄"],
            'D' => ["█▀▄", "█▄▀"],
            'E' => ["█▀▀", "██▄"],
            'F' => ["█▀▀", "█▀ "],
            'G' => ["█▀▀", "█▄█"],
            'H' => ["█ █", "█▀█"],
            'I' => ["█", "█"],
            'J' => ["  █", "█▄█"],
            'K' => ["█▄▀", "█ █"],
            'L' => ["█  ", "█▄▄"],
            'M' => ["█▀▄▀█", "█ ▀ █"],
            'N' => ["█▄ █", "█ ▀█"],
            'O' => ["█▀█", "█▄█"],
            'P' => ["█▀█", "█▀▀"],
            'Q' => ["█▀█", "▀▀█"],
            'R' => ["█▀█", "█▀▄"],
            'S' => ["█▀▀", "▄▄█"],
            'T' => ["▀█▀", " █ "],
            'U' => ["█ █", "█▄█"],
            'V' => ["█ █", "▀▄▀"],
            'W' => ["█ █ █", "▀▄▀▄▀"],
            'X' => ["▀▄▀", "█ █"],
            'Y' => ["▀▄▀", " █ "],
            'Z' => ["▀▀█", "█▄▄"],
            ' ' => [" ", " "],
            _ => return None,
        };
        let gap = usize::from(used > 0);
        used += gap + glyph[0].chars().count();
        if used > width {
            return None;
        }
        for (row, text) in rows.iter_mut().zip(glyph) {
            if gap > 0 {
                row.push(' ');
            }
            row.push_str(text);
        }
    }
    Some(rows)
}