aboutsummaryrefslogtreecommitdiffstats
path: root/src/queue.rs
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-08 01:20:43 +0200
committersalmonik <raisersoft@proton.me>2026-05-08 01:20:43 +0200
commit5c3110c7843773e617c224e16f150b25884d3fb6 (patch)
tree883b436437ee8c81794a261b242f750e286d8c82 /src/queue.rs
parentFix shuffle first song not being shuffled (diff)
downloadrsplayer-5c3110c7843773e617c224e16f150b25884d3fb6.tar.gz
rsplayer-5c3110c7843773e617c224e16f150b25884d3fb6.zip
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.
Diffstat (limited to '')
-rw-r--r--src/queue.rs7
1 files changed, 4 insertions, 3 deletions
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 {
96 } 96 }
97 } 97 }
98 98
99 pub fn display_string(&self, index: usize) -> String { 99 pub fn display_string(&self, index: usize, total: usize) -> String {
100 let album_artist = self 100 let album_artist = self
101 .artist 101 .artist
102 .clone() 102 .clone()
@@ -109,11 +109,12 @@ impl Track {
109 .unwrap_or("Unknown") 109 .unwrap_or("Unknown")
110 .to_string() 110 .to_string()
111 }); 111 });
112 let width = total.to_string().len();
112 113
113 if album_artist.is_empty() { 114 if album_artist.is_empty() {
114 format!("{}. {}", index + 1, title) 115 format!("{:0width$}. {}", index + 1, title)
115 } else { 116 } else {
116 format!("{}. {} - {}", index + 1, album_artist, title) 117 format!("{:0width$}. {} - {}", index + 1, album_artist, title)
117 } 118 }
118 } 119 }
119} 120}