tui-realm-treeview
Developed by Christian Visintin
Current version: 0.3.0 (12/08/2021)
About tui-realm-treeview 🌲
tui-realm-treeview is an implementation of a treeview component for tui-realm, it is implemented wrapping the tui-tree-widget

Get started 🏁
Add tui-realm-treeview to your Cargo.toml 🦀
= "0.3.0"
Use the treeview component
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.
- Press
ENTERto expand the selected directory - Press
BACKSPACEto go to upper directory - Move up and down with
UP/DOWNarrow keys - Advance by up to 8 entries with
PGUP/PGDOWN - Open directories with
RIGHT - Close directories with
LEFT - Change window between input field and treeview with
TAB - Press
ESCto quit
About performance
In 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:
- Except when dealing with small trees, always set a depth for the tree
- For file systems, depth 3 should be fine for each directory, then expand each directory on demand as implemented in the example
Behaviour
Events:
| Event | Message | Behaviour |
|---|---|---|
KeyCode::Enter |
OnSubmit |
Just returns submit event |
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 overkeep_statekeep_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 PG_DOWN / PG_UP
Documentation 📚
The developer documentation can be found on Rust Docs at https://docs.rs/tui-realm-treeview
Contributing and issues 🤝🏻
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
Changelog ⏳
View tui-realm-treeview's changelog HERE
Buy me a coffee ☕
If you like tui-realm-treeview and you're grateful for the work I've done, please consider a little donation 🥳
License 📃
tui-realm is licensed under the MIT license.
You can read the entire license HERE