libnotcurses_sys/widgets/tree/methods/
options.rs

1//!
2
3use crate::widgets::{NcTreeItem, NcTreeItemCbUnsafe, NcTreeOptions};
4
5#[allow(unused_imports)] // for doc comments
6use crate::widgets::NcTree;
7
8/// # `NcTreeOptions` constructors
9impl NcTreeOptions {
10    /// New NcTreeOptions for [`NcTree`].
11    pub fn new(items: &[NcTreeItem], indentcols: u32) -> Self {
12        Self::with_all_args(items, items.len(), None, indentcols, 0)
13    }
14
15    /// New NcTreeOptions for [`NcTree`], with all args.
16    pub fn with_all_args(
17        // top-level nctree_item array
18        items: &[NcTreeItem],
19
20        // size of |items|
21        count: usize,
22
23        // item callback function
24        // TODO: use NcTreeItemCb and convert to NcTreeItemCbUnsafe
25        nctreecb: Option<NcTreeItemCbUnsafe>,
26
27        // columns to indent per level of hierarchy
28        indentcols: u32,
29
30        // bitfield of `NCTREE_OPTION_*` (there's none for now)
31        flags: u64,
32    ) -> Self {
33        Self {
34            items: items as *const _ as *const NcTreeItem,
35            count: count as u32,
36            nctreecb,
37            indentcols: indentcols as i32,
38            flags,
39        }
40    }
41}