Repository navigation
fix(tui::ui::components::lyric): cap lyric title lengths - #795
SomSamantray wants to merge 3 commits into
Conversation
hasezoey
left a comment
There was a problem hiding this comment.
I think this a slight improvement over the current max 20 characters per variable.
Though i dont think just unlocking the maximal length is a long-term solution (see #612 (comment) for my suggestions)
Additionally, i dont quite like that this now specifies a minimal length of 20 characters, resulting in for example:
╭────────── Lyrics of Alan Walker - Jump Start ──────────╮
// or
╭ Lyrics of Alan Walker & Imanbek Maratuly Zeikenov - Sweet Dreams ─╮Personally, as a temporary solution, i would just completely drop the min / max length. (or bound the total length to the space available to the component, but that would require some more in-depth changes)
@tramhao what do you think about this change?
|
I removed the fixed-width padding from lyric titles. Short names now render without extra spacing, long names remain complete when the panel has room, and narrow panels clip the title to the border. I pushed commit |
|
For TUI applications, word length is definitely a problem. If we don't limit the length, it'll take up all the space unless we scroll it. That's overkill for names. I think changing the length of track name to longer(maybe 40?) will suit English better. For Chinese, the length is sufficient. |
|
Thanks, tramhao. I’ve restored a 20-character cap for artist names and raised the track title cap to 40 characters. Short names stay unpadded, and narrow panels still clip at the border. I pushed this in d58d7a5. |
hasezoey
left a comment
There was a problem hiding this comment.
LGTM as a temporary solution.
| let backend = TestBackend::new(width, 3); | ||
| let mut terminal = Terminal::new(backend).unwrap(); | ||
| let title = format_lyric_title(artist, title); | ||
| let mut textarea = | ||
| Textarea::default().borders(Borders::default().modifiers(BorderType::Rounded)); | ||
| textarea = textarea.title(Title::from(title).alignment(HorizontalAlignment::Center)); | ||
|
|
||
| terminal | ||
| .draw(|frame| textarea.view(frame, frame.area())) | ||
| .unwrap(); | ||
|
|
||
| (0..width) | ||
| .map(|x| terminal.backend().buffer()[(x, 0)].symbol()) | ||
| .collect() |
There was a problem hiding this comment.
FYI tuirealm has some helpers for that, see tuirealm::testing.
The Lyrics panel keeps short names unpadded while limiting artist names to 20 characters and track titles to 40. The caps use the original character-count behavior, and narrow panels still clip the combined title at the border.
Validation:
cargo +stable fmt --all -- --check,cargo +stable clippy --all-targets --all-features -- -D warnings, andcargo +stable test --workspace --features cover,all-backends,rusty-soundtouchpassed (234 tests).AI disclosure: The original change (4361f0c) used OpenAI Codex assistance (model not recorded). Follow-up 9207f1c and this revision were made with OpenAI Codex CLI using gpt-6-luna.
re #612