Closed soifou closed 6 days ago
What else could the ellipsis be realistically configured to? I have never seen anything other than ...
. The proposed implementation also does not take into account the length of the configured value when calculating when to display ellipsis.
Good catch with the current implementation being off!
What else could the ellipsis be realistically configured to? I have never seen anything other than ...
This is indeed the convention, but for instance if you have Nerd Fonts, you would want to use a glyph instead ⋯
or …
. It subtle, I grant you that.
does not take into account the length of the configured value when calculating when to display ellipsis.
Good catch too. I just wanted to know if you were interested before polishing this a bit.
Sure, go ahead, I would use the nerd font symbols myself if you finish this!
Hmm need some guidance here, is there some padding lying around cells in queue pane?
Because the reported cell width from ratatui needs to be substracted by 4 to be "ellipsized" correctly. Sounds too magic that I feel I'm missing something...
If you want to test directly from master
branch, the following hack gets ellipsis trigger correctly:
diff --git a/src/ui/panes/queue.rs b/src/ui/panes/queue.rs
index 81f2937..45d7db1 100644
--- a/src/ui/panes/queue.rs
+++ b/src/ui/panes/queue.rs
@@ -99,7 +99,11 @@ impl Pane for QueuePane {
.map(|song| {
let is_current = status.songid.as_ref().is_some_and(|v| *v == song.id);
let columns = (0..formats.len()).map(|i| {
- song.as_line_ellipsized(formats[i].prop, widths[i].width.into())
+ let mut max_len: usize = widths[i].width.into();
+ if max_len > 10 {
+ max_len -= 4;
+ }
+ song.as_line_ellipsized(formats[i].prop, max_len)
.unwrap_or_default()
.alignment(formats[i].alignment.into())
});
This is most likely due to compounding error with the table having spacing of 1 between columns, so the max width should be something like widths[i].width - i
. There is also a mess of areas/blocks in there which could use some cleanup, sorry for that. The table also loses one column from each side on line 155
let table_area = table_block.inner(queue_section);
when it really needs to lose one on the right side to make space for the scrollbar. I think all these add up to the weirdness you are seeing.
The ellipsis used to work, but I think I completely borked it when I introduced the song table format configs.
Thanks for your prompt reply!
I've come up with 65243f3. Might not be ideal but more concise without refactoring the whole logic. Let me know if it fits for you.
This config results in panic on your branch and is fine on master, this should be easily fixable by using saturating_sub()
though.
But I am still getting weird behavior especially on the last column with fixed length and the first column sometimes has two columns spacing, which is weird.
Take a look at this solution, maybe its good enough or maybe you can get some ideas from it: (its a patch on top of your branch)
In short I tried to mimick the way ratatui's table splits the widths with flex and spacing and then juggled some blocks around. Seems to work nicer this way.
That's strange for the panic because I tested it with a similar config (with fixed duration col) and it was ok. Speaking of duration column, might be good to suggest in default theme the fixed width of 5 cols instead.
And thanks so much for the heavy lifting, I took your solution and reworked it a bit the layout to get a nicer alignment with the scrollbar and removed all the weirdness of adding and removing cols either side. Tested with and without header.
Let me know what you think and thanks again for your patience.
Yeah, you can change the default theme if you want, but dont forget about the one in the docs if you do.
Looks good to me now, we can merge after the small change i noted above. Thanks for taking the time to fix this!
you can change the default theme if you want, but dont forget about the one in the docs if you do.
this involve to update the screenshot i think so i'd rather not to change for now, however this could be the subject of another theme.
Anyway, ready to merge!
done, thanks!
Allow to customize the ellipsis symbol. I make it optional to not introduce a breaking change in user's theme. Fallback to
...
.We should handle the text truncation in the others panes/columns since this is only enabled in queue for now. Also I notice the truncation trigger a bit late (see selected song above).
In any case, what do you think?