use owo_colors::OwoColorize;
use std::fmt::Display;
use crate::types::VirtAddr;
pub fn addr(value: u64) -> String {
format!("{value:016x}").bright_white().bold().to_string()
}
pub fn addr_opt(value: VirtAddr) -> String {
if value.is_zero() {
muted("unavailable")
} else {
addr(value.0)
}
}
pub fn symbol(sym: &str) -> String {
if sym.starts_with("0x") {
return muted(sym);
}
match sym.rfind("+0x") {
Some(idx) => format!("{}{}", (&sym[..idx]).green(), (&sym[idx..]).bright_black()),
None => sym.green().to_string(),
}
}
pub fn muted(text: &str) -> String {
text.bright_black().to_string()
}
pub fn label(text: &str) -> String {
text.bold().to_string()
}
pub fn bp_id(id: impl Display) -> String {
format!("#{id}").cyan().to_string()
}