tui_treelistview/
context.rs1use ratatui::style::Style;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum TreeExpansionState {
6 Leaf,
7 Collapsed,
8 Expanded,
9 ForcedByFilter,
10 Unloaded,
11 Loading,
12}
13
14impl TreeExpansionState {
15 #[must_use]
17 pub const fn is_expanded(self) -> bool {
18 matches!(self, Self::Expanded | Self::ForcedByFilter)
19 }
20
21 #[must_use]
23 pub const fn is_expandable(self) -> bool {
24 !matches!(self, Self::Leaf | Self::Loading)
25 }
26}
27
28#[derive(Clone, Copy, Debug, PartialEq, Eq)]
30pub enum TreeMatchState {
31 Unfiltered,
32 Direct,
33 Ancestor,
34}
35
36#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
38pub enum TreeMarkState {
39 #[default]
40 Unmarked,
41 Partial,
42 Marked,
43}
44
45#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub struct TreeRowNodeState {
48 pub expansion: TreeExpansionState,
49 pub mark: TreeMarkState,
50 pub match_state: TreeMatchState,
51}
52
53#[derive(Clone, Copy, Debug, PartialEq, Eq)]
55pub struct TreeRowRenderState {
56 pub draw_lines: bool,
57 pub is_selected: bool,
58 pub selected_column: Option<usize>,
59}
60
61#[derive(Clone, Copy, Debug, PartialEq, Eq)]
63pub struct TreeRowContext<'a> {
64 pub level: usize,
66 pub is_tail_stack: &'a [bool],
68 pub node: TreeRowNodeState,
69 pub render: TreeRowRenderState,
70 pub line_style: Style,
71}