tui-rs
tui-rs copied to clipboard
Table layout seems to be broken
Description
Maybe it is me, or my understanding, but it feels like the table layout is pretty broken.
To Reproduce
For example: Add two columns, with Max(64)
, Min(10)
.
Expected behavior
I would expect that the first column gets "a maximum of 64 characters", and the other one "at least 10".
Screenshots
What actually happens is, that the first column isn't rendered at all.
Environment
- OS: Linux, Fedora 36
- Terminal Emulator: Konsole (KDE Terminal)
- Font: Not relevant, I guess
- Crate version: 0.18
- Backend: crossterm
Additional context
I know that table layouting is hard. However, I would hope that there are some basics available. Or at least, there is some mechanism to provide the actual sizes manually.
I would expect some common scenarios to be possible:
- Consume at least X characters
- Do not consume more then X characters
- Grow row if there more space available (maybe with a factor/weight)
And maybe it is just me, then I would appreciate a few examples.
I would expect that the first column gets "a maximum of 64 characters", and the other one "at least 10".
This translates to w == x + y && x <= 64 && y >= 10
.
Assuming a total available size of w == 20
units, then x == 0 && y == 20
is valid for the above constraint: 0 =< 64 && 20 >= 10
. The problem is that there are ten different ways to resolve the same constraint with that w
(e.g. (5, 15)
or (10, 10)
).
You simply didn't provide enough information for the system to determine which of those ten different ways should be picked, so to the algorithm, they are all equally "good".
mechanism to provide the actual sizes manually
That's Constraint::Length
.
Consume at least X characters
That's Constraint::Min
.
Do not consume more then X characters
That's Constraint::Max
.
Grow row if there more space available (maybe with a factor/weight)
Constraint::Min
allows the element to extend into available space.
Weights are supported by cassowary
, but not used/exposed by tui
.
I would appreciate a few examples.
The system to specify table column sizes is the same one used to create layouts. So all examples for the latter apply to the former, too.
Ok, so maybe the system needs something like a "greedy" flag for Max
?
I'm hitting a similar issue. I have this:
layout::Constraint::Min(0),
layout::Constraint::Length(FD_WIDTH),
I would expect the right column to be exactly FD_WIDTH and the left one to take all of the remaining space, but what happens is only the right one gets rendered. How do I provide enough information for the layout to know what I need it to do?
I have the same issue :frowning_face:
layout::Constraint::Min
acts like layout::Constraint::Max
.
Hey guys, we're working on a fork to continue maintaining this crate, would love to see this issue re-opened there !