Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Intuitive – A Rust crate for writing declarative TUIs (docs.rs)
5 points by enricozb on Sept 12, 2022 | hide | past | favorite | 5 comments



I've written a few TUIs in Rust, and the amount of code needed for the UI components always felt excessive. For a while, I had been toying with the idea of being able to write components in a SwiftUI-like DSL and have state managed like React does with hooks. Intuitive is the result of that frustration and desire.

Right now it's in between a proof-of-concept and an alpha version of the crate. I'm in the process of re-writing one of my TUI apps using Intuitive, and so far it has proven itself as a way to greatly reduce the amount of code necessary for a TUI.

I would be grateful for any feedback on the idea, the design, and/or the implementation. I hope it's well-received!


Wow, this looks cool! How is use_state() implemented?


Similarly to how React does it I'd imagine. There is a static vector of `State` elements that is initially empty and is filled on the first render with each call to use_state. When calling use_state on subsequent renders, this vector is read from. This is also why, like React, use_state calls must always be in the same order across renders.


Looks great. Most the TUI stuff out there Ive seen rarely has a great solve for scrolling (buffered) text boxes. Would be cool to see a clean scroll box solution here


Absolutely! I saw that lazygit recently(?) added scrollbars, and I'm actually working on adding this as a new component.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: