Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify text of a leaf #39

Open
dvdsk opened this issue May 26, 2024 · 1 comment
Open

Modify text of a leaf #39

dvdsk opened this issue May 26, 2024 · 1 comment

Comments

@dvdsk
Copy link

dvdsk commented May 26, 2024

Hi, I would like to use tui-rs-tree to display sensor readings. In addition of using the tree to browse the sensor information I would like to display the current value in the tree, like this:

  • kitchen
    • temperature: 22 C
    • humidity: 56 %
  • hallway

Right now I have to rebuild the whole tree to update these values as I see no way to edit the text of a TreeItem. The docs of TreeItem do speak of the ability to change an identifier:
https://docs.rs/tui-tree-widget/0.20.0/tui_tree_widget/struct.TreeItem.html#method.child_mut

Am I missing something? And if not could you please add the ability to change the text of a TreeItem

@EdJoPaTo
Copy link
Owner

The idea of the tui-rs widgets where being short-lived and to not keep the data in the background. On each render the content that should be displayed is referenced in the entities like ListItem or TreeItem and dropped after the render. It was never the idea to keep data long term.

The docs of TreeItem do speak of the ability to change an identifier:
https://docs.rs/tui-tree-widget/0.20.0/tui_tree_widget/struct.TreeItem.html#method.child_mut

You can add more children which, but you currently can not update the identifier (and shouldn't because of the stated reason). I think it would be correct to adapt that comment.

And if not could you please add the ability to change the text of a TreeItem

I'm not sure yet whether I would like that… It would be better to keep the data and the way to display it separated.
On the other hand, the widgets seem to get more into the direction of keeping their state so it might be worth looking into keeping the state… 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants