Byron / dua-cli

View disk space usage and delete unwanted data, fast.
https://lib.rs/crates/dua-cli
MIT License
3.67k stars 102 forks source link

Replace tui_react::Terminal with tui::Terminal #246

Closed matta closed 1 month ago

matta commented 1 month ago

This is an experiment in converting a program that used the Terminal provided by tui-react into a program that uses the Terminal provided by ratatui. My hypothesis was that the two were not significantly different from eachother, and this seems to be true in this case.

I found that Widget trait used by ratatui's Terminal is sufficiently powerful to pass arbitrary mutable state to rendering code. A relatively simple FunctionWidget trampoline is used to achieve this.

The tui_react dependency is retained. The code still calls some tui_react utility functions and uses its List widget instead of the ratatui List widget. These utilities do not depend on the tui_react Terminal and could, in theory, be split out of tui-react into a separate crate.

See also https://github.com/Byron/tui-crates/discussions/9

Byron commented 1 month ago

Thanks a lot for making this happen, and sorry for the hassle with clippy. It would have been fine to fix this here as well, but the respective PR #247 is on its way to be merged now.

Windows seems to have other issues due to time and nightly probably, maybe a regression in the compiler, so it's fair to just ignore that for now.