Open chrisbouchard opened 1 year ago
I could also see putting Alignment
somewhere else, e.g., if it might some day also be used to align the title on Section
.
Thank you for the PR.
I'm actually in the process of rewriting intuitive completely because of a fundamental flaw (see https://github.com/enricozb/intuitive/issues/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 https://github.com/enricozb/intuitive/issues/3) and precise re-renders using signals.
Your suggestion to add Alignment
to Text
, and possibly Section
, is a really good one, and I'll consider adding it to the rewrite as well. I'm trying to have it close to feature parity with v0.6 before pushing any code.
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
alignment
property to theText
component, and a newAlignment
enum with alignment options (left, center, right).Breaking Change
This is a breaking change in that
Text::new
now takes an additional parameter — since that would be a breaking change no matter what, I addedalignment
at the beginning ofrender
's parameters to preserve alphabetical order.Implementation
Under the covers, we directly translate the
Alignment
to a tui-rsAlignment
and set it onto the underlyingParagraph
. The default isAlignment::Left
, so there should be no change in default behavior.I also refactored the
components::text
module a bit, so that it could become a public module (to exposeAlignment
) without double-exposing theText
component — I followed the pattern fromcomponents::stack
of 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::text
seemed more confusing than helpful. I'm open to any suggestions, including using “text” if you prefer;Fixes #5.