tui-realm-treeview icon indicating copy to clipboard operation
tui-realm-treeview copied to clipboard

[Feature Request] - Optionally skip rendering the root node

Open rparrett opened this issue 2 years ago โ€ข 2 comments

Description

For my use case, I'm not finding it useful to be able to collapse the root node of a tree, and displaying the root node of the tree directly below the component title is a bit redundant.

There would be no reason for my users to collapse the root node, so I don't want to let them.

I'm not sure that I described that well, so here's what I'm trying to accomplish:

 โ•ญtree-viewerโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
 โ”‚๐Ÿฆ„ Cargo.toml                               โ”‚
 โ”‚   target โ–ถ                                 โ”‚
 โ”‚   Cargo.lock                               โ”‚
 โ”‚   .gitignore                               โ”‚
 โ”‚   .git โ–ถ                                   โ”‚
 โ”‚   src โ–ถ                                    โ”‚
 โ”‚                                            โ”‚
 โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Changes

Add an option that when used, skips the root node like shown above.

Implementation

I am not completely up to speed yet, but I'd like to do something along the lines of

  • Add a hide_root_node method to TreeView
  • Add hide_root_node field to TreeWidget
  • Add a separate render_root_node function to TreeWidget that just iterates children if hide_root_node is true, or calls iter_nodes if not.

I've implemented the render_root_node part and things seem to work.

If the approach above sounds acceptable, I'd be happy to attempt a PR with the rest.

rparrett avatar Jan 25 '22 22:01 rparrett