From 5c3110c7843773e617c224e16f150b25884d3fb6 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 8 May 2026 01:20:43 +0200 Subject: Pad queue display numbers with leading zeros display_string now takes a total parameter to compute the zero-padding width. Queue positions are formatted as 01, 02, ..., 10 instead of 1, 2, ..., 10, keeping columns aligned. --- src/queue.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/queue.rs') diff --git a/src/queue.rs b/src/queue.rs index dca8e3d..9e8e1af 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -96,7 +96,7 @@ impl Track { } } - pub fn display_string(&self, index: usize) -> String { + pub fn display_string(&self, index: usize, total: usize) -> String { let album_artist = self .artist .clone() @@ -109,11 +109,12 @@ impl Track { .unwrap_or("Unknown") .to_string() }); + let width = total.to_string().len(); if album_artist.is_empty() { - format!("{}. {}", index + 1, title) + format!("{:0width$}. {}", index + 1, title) } else { - format!("{}. {} - {}", index + 1, album_artist, title) + format!("{:0width$}. {} - {}", index + 1, album_artist, title) } } } -- cgit v1.2.3