use lipgloss_tree::Children;
pub type Enumerator = fn(&dyn Children, usize) -> String;
pub type Indenter = fn(&dyn Children, usize) -> String;
const ABC_LEN: usize = 26;
pub fn alphabet(_items: &dyn Children, i: usize) -> String {
if i >= ABC_LEN * ABC_LEN + ABC_LEN {
let c1 = ((i / ABC_LEN / ABC_LEN) - 1) % ABC_LEN;
let c2 = ((i / ABC_LEN) - 1) % ABC_LEN;
let c3 = i % ABC_LEN;
format!(
"{}{}{}.",
char::from(b'A' + c1 as u8),
char::from(b'A' + c2 as u8),
char::from(b'A' + c3 as u8)
)
} else if i >= ABC_LEN {
let c1 = (i / ABC_LEN) - 1;
let c2 = i % ABC_LEN;
format!(
"{}{}.",
char::from(b'A' + c1 as u8),
char::from(b'A' + c2 as u8)
)
} else {
format!("{}.", char::from(b'A' + (i % ABC_LEN) as u8))
}
}
pub fn arabic(_items: &dyn Children, i: usize) -> String {
format!("{}.", i + 1)
}
pub fn roman(_items: &dyn Children, mut i: usize) -> String {
let roman = [
"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I",
];
let arabic = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
let mut result = String::new();
i += 1;
for (idx, &value) in arabic.iter().enumerate() {
while i >= value {
i -= value;
result.push_str(roman[idx]);
}
}
result.push('.');
result
}
pub fn bullet(_items: &dyn Children, _i: usize) -> String {
"•".to_string()
}
pub fn asterisk(_items: &dyn Children, _i: usize) -> String {
"*".to_string()
}
pub fn dash(_items: &dyn Children, _i: usize) -> String {
"-".to_string()
}