Skip to content

Use ratatui::run() for managing terminal lifecycle#142

Merged
joshka merged 6 commits intoratatui:mainfrom
nebkor:ratatui-run
Jul 15, 2025
Merged

Use ratatui::run() for managing terminal lifecycle#142
joshka merged 6 commits intoratatui:mainfrom
nebkor:ratatui-run

Conversation

@nebkor
Copy link
Copy Markdown
Contributor

@nebkor nebkor commented Jul 15, 2025

This removes the custom tui module for setting up the terminal and panic handlers, and instead uses the new run() function from Ratatui 0.30. Something to note is that I had to change the main func to be non-async, since the run function takes a sync closure, so I used the Tokio runtime's block_on() method inside it; I'd love to see a better way to do that.

@nebkor
Copy link
Copy Markdown
Contributor Author

nebkor commented Jul 15, 2025

It seems the formatting defaults for edition 2024 are slightly different than 2021, which is why all those extraneous changes are in there; they were done automatically.

@joshka
Copy link
Copy Markdown
Member

joshka commented Jul 15, 2025

Perhaps would you mind doing a quick PR for flipping to 2024 edition and then rebasing this change on that.

I'll have to take a deeper look at this to understand the impact on the async changes.

@nebkor
Copy link
Copy Markdown
Contributor Author

nebkor commented Jul 15, 2025

Perhaps would you mind doing a quick PR for flipping to 2024 edition and then rebasing this change on that.

I'll have to take a deeper look at this to understand the impact on the async changes.

Done! See #143 .

@joshka
Copy link
Copy Markdown
Member

joshka commented Jul 15, 2025

Added a few small tweaks to the approach:

  • slapped #[tokio::main] on the app::run method instead of manually building the async runtime
  • moved Events::new() into the run method (as it needs the async reactor to run
  • renamed draw() to render() and made it accept Frame instead of DefaultTerminal
  • put the init call that passes the cli query in App::new()

Does this look good to you?

@nebkor
Copy link
Copy Markdown
Contributor Author

nebkor commented Jul 15, 2025

Added a few small tweaks to the approach:

* slapped `#[tokio::main]` on the app::run method instead of manually building the async runtime

* moved Events::new() into the run method (as it needs the async reactor to run

* renamed draw() to render() and made it accept Frame instead of DefaultTerminal

* put the init call that passes the cli query in App::new()

Does this look good to you?

I love it!

@joshka joshka merged commit 6d35eac into ratatui:main Jul 15, 2025
8 checks passed
@github-actions github-actions bot mentioned this pull request Jul 15, 2025
@nebkor nebkor deleted the ratatui-run branch July 15, 2025 21:38
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.

2 participants