| 1 | **tui-react** is a library to enable components with state, and with properties provided per render |
| 2 | |
| 3 | Please note that this crate is early in development and built for the needs of **dua**. |
| 4 | |
| 5 | ### How it works |
| 6 | |
| 7 | It uses the TUI infrastructure Terminal, but alters it to not enforce implementing the `Widget` trait. |
| 8 | It provides only a single, optional, trait called `TopLevelComponent`, which makes it convenient to |
| 9 | draw its implementers with `Terminal::render(..)`. However, since this enforces the absence of |
| 10 | references in your state, it's probably not suitable for most. |
| 11 | |
| 12 | Instead, any struct can implement `render` methods or functions, and freely write into the terminal. |
| 13 | That way, one can leverage everything Rust has to offer, which allows stateful components which |
| 14 | work in your favor. Thus, this crate does away with 'one size fits all' render implementations, |
| 15 | greatly adding to flexibility. |
| 16 | |
| 17 | State that one wants within the component for instance could be the scroll location. Alternatively, |
| 18 | one can configure windows by altering their public state. |
| 19 | |
| 20 | ### What's the relation to TUI / Ratatui? |
| 21 | |
| 22 | This project couldn't exist without TUI, and is happy to provide an alternative set of components |
| 23 | for use in command-line applications. Ratatui is the continuation of the tui project. |
| 24 | |
| 25 | ### Why `tui-react`? |
| 26 | |
| 27 | I kept having a terrible feeling when managing state with tui widgets when writing **dua**, and |
| 28 | after trying many things, I realized what the problem actually was. It took me some time to |
| 29 | realize it's not possible to have stateful components in with TUI, and I admire the smarts |
| 30 | that went into the API design! After all, it effectively prohibited this! Amazing! |
| 31 | |
| 32 | That's why I implemented my own terminal and some key components, based on the ones provided |
| 33 | by TUI, which can serve as standard building blocks in a stateful world. |
| 34 | |
| 35 | Thus far, the experience was fantastic, and it feels much better than before. Let's see what |
| 36 | happens with it. |
| 37 | |
| 38 | ### Changelog |
| 39 | |
| 40 | #### v0.4.1 - Simplify `block_width(…)` function |
| 41 | |
| 42 | #### v0.2.1 - add license file to crate |