Note: This is more or less a copy of my issue on the original tui-rs project: fdehau/tui-rs#498.
Problem
I find the fn centered_rect in examples/popup.rs to be extremely useful, so much, that I would like it to be part of the API. I'd probably copy this function to every TUI project 😅
Solution
- add the function to the public API, possibly on
Rect itself, as it always takes a Rect as an argument
- keep the
popup.rs example and use the function from the public API instead of defining it there again
Alternatives
- keep it as is
- have a
ratatui-util crate to contain functions like these
Additional context
Whether to include this in the public API depends on your inclination towards having these kinds of utility functions in the API. I have heard different opinions on this and I'd respect not adding this. IMHO if enough members of the community use this function anyway, I'd include it in the API, as it would be a good way to do cross-project code deduplication and to have a reference to the usecase in the API documentation.
Note: This is more or less a copy of my issue on the original
tui-rsproject: fdehau/tui-rs#498.Problem
I find the
fn centered_rectinexamples/popup.rsto be extremely useful, so much, that I would like it to be part of the API. I'd probably copy this function to every TUI project 😅Solution
Rectitself, as it always takes aRectas an argumentpopup.rsexample and use the function from the public API instead of defining it there againAlternatives
ratatui-utilcrate to contain functions like theseAdditional context
Whether to include this in the public API depends on your inclination towards having these kinds of utility functions in the API. I have heard different opinions on this and I'd respect not adding this. IMHO if enough members of the community use this function anyway, I'd include it in the API, as it would be a good way to do cross-project code deduplication and to have a reference to the usecase in the API documentation.