pub const CURSOR_SELECTED: &str = ">";
pub const CURSOR_BLANK: &str = " ";
pub const HLINE: &str = "─";
pub const VLINE: &str = "│";
pub const CORNER_TL: &str = "┌";
pub const CORNER_TR: &str = "┐";
pub const CORNER_BL: &str = "└";
pub const CORNER_BR: &str = "┘";
pub const TOP_MID: &str = "┬";
pub const BOTTOM_MID: &str = "┴";
pub const MID_LEFT: &str = "├";
pub const MID_RIGHT: &str = "┤";
pub const CROSS_MID: &str = "┼";
pub const ROUNDED_TL: &str = "╭";
pub const ROUNDED_BL: &str = "╰";
pub const HLINE_HEAVY: &str = "━";
pub const VLINE_HEAVY: &str = "┃";
pub const HEAVY_TL: &str = "┏";
pub const HEAVY_TR: &str = "┓";
pub const HEAVY_BL: &str = "┗";
pub const HEAVY_BR: &str = "┛";
pub const BRANCH_MID: &str = "├─";
pub const BRANCH_END: &str = "└─";
pub const BRANCH_FIRST: &str = "┌─";
pub const BRANCH_FIRST_SP: &str = "┌─ ";
pub const BRANCH_MID_SP: &str = "├─ ";
pub const BRANCH_END_SP: &str = "└─ ";
pub const BRANCH_VERT_PAD: &str = "│ ";
pub const INDENT_VERT: &str = "│ ";
pub const CHILD_VERT_PAD: &str = " │ ";
pub const CHECK: &str = "✓";
pub const CROSS: &str = "✗";
pub const DOT_FILLED: &str = "●";
pub const DOT_EMPTY: &str = "○";
pub const DOT_ALT: &str = "◉";
pub const ARROW_DOWN: &str = "\u{2193}";
pub const ARROW_SWAP: &str = "\u{21C4}";
pub const ARROW_UP: &str = "\u{2191}";
pub const ARROW_LEFT: &str = "←";
pub const ARROW_RIGHT: &str = "→";
pub const TRIANGLE_UP: &str = "▲";
pub const TRIANGLE_DOWN: &str = "▼";
pub const BLOCK_FULL: &str = "█";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TreeNodeKind {
Header,
ChildMiddle,
ChildLast,
Continuation,
}
pub fn tree_connector(kind: TreeNodeKind) -> &'static str {
match kind {
TreeNodeKind::Header => BRANCH_END_SP,
TreeNodeKind::ChildMiddle => BRANCH_MID_SP,
TreeNodeKind::ChildLast => BRANCH_END_SP,
TreeNodeKind::Continuation => BRANCH_VERT_PAD,
}
}
pub fn tree_child_prefix(kind: TreeNodeKind) -> &'static str {
match kind {
TreeNodeKind::ChildMiddle => " ├─ ",
TreeNodeKind::ChildLast => " └─ ",
TreeNodeKind::Header => BRANCH_END_SP,
TreeNodeKind::Continuation => CHILD_VERT_PAD,
}
}
use ratatui::text::{Line, Span};
pub fn tree_detail_line<'a>(indent: &str, kind: TreeNodeKind, content: Vec<Span<'a>>) -> Line<'a> {
let mut spans: Vec<Span<'a>> = vec![
Span::raw(CURSOR_BLANK.to_string()),
Span::raw(" "),
Span::raw(indent.to_string()),
Span::raw(tree_connector(kind).to_string()),
];
spans.extend(content);
Line::from(spans)
}
pub fn tree_header_line<'a>(
cursor: &'static str,
indent: &str,
content: Vec<Span<'a>>,
) -> Line<'a> {
let mut spans: Vec<Span<'a>> = vec![
Span::raw(cursor.to_string()),
Span::raw(" "),
Span::raw(indent.to_string()),
];
spans.extend(content);
Line::from(spans)
}