use ratatui::style::Style;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TreeExpansionState {
Leaf,
Collapsed,
Expanded,
ForcedByFilter,
Unloaded,
Loading,
}
impl TreeExpansionState {
#[must_use]
pub const fn is_expanded(self) -> bool {
matches!(self, Self::Expanded | Self::ForcedByFilter)
}
#[must_use]
pub const fn is_expandable(self) -> bool {
!matches!(self, Self::Leaf | Self::Loading)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TreeMatchState {
Unfiltered,
Direct,
Ancestor,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TreeMarkState {
#[default]
Unmarked,
Partial,
Marked,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TreeRowNodeState {
pub expansion: TreeExpansionState,
pub mark: TreeMarkState,
pub match_state: TreeMatchState,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TreeRowRenderState {
pub draw_lines: bool,
pub is_selected: bool,
pub selected_column: Option<usize>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct TreeRowContext<'a> {
pub level: usize,
pub is_tail_stack: &'a [bool],
pub node: TreeRowNodeState,
pub render: TreeRowRenderState,
pub line_style: Style,
}