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

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

Merged
merged 2 commits into from
May 27, 2024

Conversation

matta
Copy link
Contributor

@matta matta commented May 26, 2024

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 Byron/tui-crates#9

@Byron
Copy link
Owner

Byron commented May 27, 2024

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.

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.
Copy link
Owner

@Byron Byron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great work, thanks a lot! Will merge once CI is green.

@Byron Byron merged commit ced3b4f into Byron:main May 27, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants