Skip to main content

rab/agent/ui/
render_utils.rs

1/// Pad (or truncate) a string to a given visible width.
2pub fn pad_to_width(s: &str, width: usize) -> String {
3    let vw = crate::tui::util::visible_width(s);
4    if vw > width {
5        crate::tui::util::truncate_to_width(s, width, "", false)
6    } else if vw < width {
7        format!("{}{}", s, " ".repeat(width - vw))
8    } else {
9        s.to_string()
10    }
11}
12
13/// Map a thinking level string to a theme color name for per-level colors.
14pub fn thinking_level_color(level: &str) -> Option<&'static str> {
15    match level {
16        "off" | "none" => None,
17        "minimal" => Some("thinking_level_low"),
18        "low" => Some("thinking_level_low"),
19        "medium" => Some("thinking_level_medium"),
20        "high" => Some("thinking_level_high"),
21        "xhigh" | "max" => Some("thinking_level_xhigh"),
22        _ => None,
23    }
24}