Conversation
I want to introduce a submodule for alignment, but then I'll need to make the `text` module public, which will expose the public `Text` component definition, resulting in it appearing in two different modules. To avoid confusion, I've moved it to a new `text::component` submodule, only visible to super, like we have with `stack::horizontal` and `stack::vertical`. I'm not at all sold on the name `component`, but I can't think of anything better at the moment -- I thought of using the component name, but `text::text` seemed more confusing than helpful (and Clippy warns about it).
Nothing's using it yet, but the `Text` component will soon.
And pass it through to the underlying `Paragraph`. Since property order doesn't matter for anyone using `render!`, and any call to `Text::new` is going to break with an added parameter anyway, I've added the new parameter at the beginning to preserve alphabetical order.
Now that the `Text` component won't appear twice, we can make the module public to expose `Alignment`.
|
I could also see putting |
|
Thank you for the PR. I'm actually in the process of rewriting intuitive completely because of a fundamental flaw (see #4). This rewrite that is in progress also removes tui-rs as a dependency in favor of a custom drawing solution. Furthermore, this re-rewrite will also pave the way for a focusing system (see #3) and precise re-renders using signals. Your suggestion to add Let me think a bit about merging this PR, since so much will change in the upcoming v0.7 anyways. |
This merge request introduces an
alignmentproperty to theTextcomponent, and a newAlignmentenum with alignment options (left, center, right).Breaking Change
This is a breaking change in that
Text::newnow takes an additional parameter — since that would be a breaking change no matter what, I addedalignmentat the beginning ofrender's parameters to preserve alphabetical order.Implementation
Under the covers, we directly translate the
Alignmentto a tui-rsAlignmentand set it onto the underlyingParagraph. The default isAlignment::Left, so there should be no change in default behavior.I also refactored the
components::textmodule a bit, so that it could become a public module (to exposeAlignment) without double-exposing theTextcomponent — I followed the pattern fromcomponents::stackof creating apub(super)submodule to hide the component. I couldn't think of a good submodule name, so I usedcomponent. I considered using the component name “text,” butcomponents::text::textseemed more confusing than helpful. I'm open to any suggestions, including using “text” if you prefer;Fixes #5.