Developed by Christian Visintin
Current version: 0.2.0 (07/06/2021)
tui-realm-treeview is an implementation of a treeview component for tui-realm, it is implemented wrapping the tui-tree-widget
toml
tui-realm-treeview = "0.2.0"
View how to use the treeview-component following the example. The example contains a simple file explorer using a tree view, the depth is set to 3.
sh
cargo run --example demo
ENTER
to expand the selected directoryBACKSPACE
to go to upper directoryUP/DOWN
arrow keysPGUP/PGDOWN
RIGHT
LEFT
TAB
ESC
to quitIn this library there is a consistent use of recursion, and since rust is not functional, this might lead to stack overflows when dealing with huge trees. In addition consider that each level of depth added, will slow down the application exponentially.
Best practices:
Events:
| Event | Message | Behaviour |
|---------------------|------------|------------------------------------------------------|
| KeyCode::Down
| OnChange
| Go to next element |
| KeyCode::Up
| OnChange
| Go to previous element |
| KeyCode::PageDown
| OnChange
| Move cursor down by defined max steps or end of node |
| KeyCode::PageUp
| OnChange
| Move cursor up by defined max steps or begin of node |
| KeyCode::Right
| OnChange
| Open highlighted node |
| KeyCode::Left
| OnChange
| Close highlighted node |
| KeyCode::Char(_)
| OnKey
| Return pressed key |
Update: Msg::OnChange
if the value changed, Msg::None
otherwise.
State: the state returned is a One(Str)
containing the id of the selected node. If no node is selected None
is returned.
Properties:
with_foreground
: foreground color. The foreground will be used as foreground for the selected item, when focus is false, otherwise as backgroundwith_background
: background color. The background color will be used as background for unselected entry, but will be used as foreground for the selected entry when focus is truewith_borders
: set borders properties for componentwith_title
: Set box titlewith_highlighted_str
: The provided string will be displayed on the left side of the selected entry in the treewith_tree_and_depth
: Sets the tree and its max depth for Props builderwith_tree
: Sets the tree for Props builderwith_node
: Select initial node in the tree. This option has priority over keep_state
keep_state
: If keep is true, the selected entry will be kept after an update of the tree (obviously if the entry still exists in the tree).with_max_page_steps
: Defines the maximum amount of steps to perform after a PGDOWN / PGUPThe developer documentation can be found on Rust Docs at https://docs.rs/tui-realm-treeview
Contributions, bug reports, new features and questions are welcome! 😉 If you have any question or concern, or you want to suggest a new feature, or you want just want to improve tui-realm, feel free to open an issue or a PR.
Please follow our contributing guidelines
View tui-realm-treeview's changelog HERE
If you like tui-realm-treeview and you're grateful for the work I've done, please consider a little donation 🥳
tui-realm is licensed under the MIT license.
You can read the entire license HERE