Skip to content

include fn centered_rect from examples/popup.rs in API #617

@wookietreiber

Description

@wookietreiber

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions