-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(table): Add a Table::segment_size method #660
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #660 +/- ##
======================================
Coverage ? 90.9%
======================================
Files ? 42
Lines ? 12502
Branches ? 0
======================================
Hits ? 11373
Misses ? 1129
Partials ? 0 ☔ View full report in Codecov by Sentry. |
ed18445
to
3d2d451
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - 1 small nit.
Can you please update the commit message (or provide one in a comment) that describes the behavior directly rather than in reference to Layout
. This will end up in the Changelog, so think about how you'd announce the functionality rather than just describing the change and perhaps add 3 small code examples like
let area = Rect::new(0, 0, 62, 1);
let widths = [Min(10), Min(10, Min(10)];
// results in column widths 10, 10, 10
Table::new(rows).widths(widths).segment_size(SegmentSize::None);
// ...
3d2d451
to
69f73e4
Compare
BTW, for an example of this new feature in action, see asomers/ztop#33 . |
Does your CI process merge PRs with the main branch before running tests? Because the test that's failing is one that isn't in my branch. Neat, if true. |
Yep :) |
69f73e4
to
203e14f
Compare
Rebased. And I squashed my commits to satisfy the commit style checker. |
It controls how to distribute extra space to an underconstrained table. The default, legacy behavior is to leave the extra space unused. The new options are LastTakesRemainder which gets all space to the rightmost column that can used it, and EvenDistribution which divides it amongst all columns. Fixes ratatui#370
203e14f
to
70f7a11
Compare
In #660 we introduced the segment_size field to the Table struct. However, we forgot to update the default() implementation to match the new() implementation. This meant that the default() implementation picked up SegmentSize::default() instead of SegmentSize::None. Additionally the introduction of Table::default() in an earlier PR, #339, was also missing the default for the column_spacing field (1). This commit fixes the default() implementation to match the new() implementation of these two fields by implementing the Default trait manually. BREAKING CHANGE: The default() implementation of Table now sets the column_spacing field to 1 and the segment_size field to SegmentSize::None. This will affect the rendering of a small amount of apps.
In #660 we introduced the segment_size field to the Table struct. However, we forgot to update the default() implementation to match the new() implementation. This meant that the default() implementation picked up SegmentSize::default() instead of SegmentSize::None. Additionally the introduction of Table::default() in an earlier PR, #339, was also missing the default for the column_spacing field (1). This commit fixes the default() implementation to match the new() implementation of these two fields by implementing the Default trait manually. BREAKING CHANGE: The default() implementation of Table now sets the column_spacing field to 1 and the segment_size field to SegmentSize::None. This will affect the rendering of a small amount of apps.
In #660 we introduced the segment_size field to the Table struct. However, we forgot to update the default() implementation to match the new() implementation. This meant that the default() implementation picked up SegmentSize::default() instead of SegmentSize::None. Additionally the introduction of Table::default() in an earlier PR, #339, was also missing the default for the column_spacing field (1). This commit fixes the default() implementation to match the new() implementation of these two fields by implementing the Default trait manually. BREAKING CHANGE: The default() implementation of Table now sets the column_spacing field to 1 and the segment_size field to SegmentSize::None. This will affect the rendering of a small amount of apps.
It works just like Layout::segment_size, but for Tables. Previously, it was impossible to distribute extra space anywhere in a Table.
Fixes #370