4 ms·
Show HN: Intuitive – A Rust crate for writing declarative TUIs
- enricozb 4y agoI'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!
- citywide-fondue 4y agoWow, this looks cool! How is use_state() implemented?
- enricozb 4y agoSimilarly 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.
- cdaringe 4y agoLooks 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
- enricozb 4y agoAbsolutely! I saw that lazygit recently(?) added scrollbars, and I'm actually working on adding this as a new component.