mirror of
https://github.com/house-of-vanity/tmux-helper.git
synced 2026-02-04 01:37:57 +00:00
Improve player metadata displaying.
This commit is contained in:
39
src/main.rs
39
src/main.rs
@@ -169,6 +169,26 @@ fn main() {
|
|||||||
let mut artist_len = 30;
|
let mut artist_len = 30;
|
||||||
let mut separator: String = " - ".to_string();
|
let mut separator: String = " - ".to_string();
|
||||||
let max_shift = 6;
|
let max_shift = 6;
|
||||||
|
if track_info.artist.chars().count() == 0 {
|
||||||
|
separator = "".to_string();
|
||||||
|
title_len += artist_len;
|
||||||
|
}
|
||||||
|
if artist_len + max_shift >= track_info.artist.chars().count() {
|
||||||
|
artist_len = track_info.artist.chars().count()
|
||||||
|
}
|
||||||
|
if track_info.artist.len() > artist_len {
|
||||||
|
let mut artist: String = String::new();
|
||||||
|
let mut counter = 0;
|
||||||
|
for ch in track_info.artist.chars() {
|
||||||
|
if counter == artist_len {
|
||||||
|
artist.push_str("..");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
artist.push(ch);
|
||||||
|
counter += 1;
|
||||||
|
}
|
||||||
|
track_info.artist = artist;
|
||||||
|
}
|
||||||
if title_len + max_shift >= track_info.title.chars().count() {
|
if title_len + max_shift >= track_info.title.chars().count() {
|
||||||
title_len = track_info.title.chars().count()
|
title_len = track_info.title.chars().count()
|
||||||
}
|
}
|
||||||
@@ -177,31 +197,14 @@ fn main() {
|
|||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
for ch in track_info.title.chars() {
|
for ch in track_info.title.chars() {
|
||||||
if counter == title_len {
|
if counter == title_len {
|
||||||
|
title.push_str("..");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
title.push(ch);
|
title.push(ch);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
title.push_str("..");
|
|
||||||
track_info.title = title;
|
track_info.title = title;
|
||||||
}
|
}
|
||||||
if artist_len + max_shift >= track_info.artist.chars().count() {
|
|
||||||
artist_len = track_info.artist.chars().count()
|
|
||||||
}
|
|
||||||
if track_info.artist.chars().count() == 0 {separator = "".to_string()}
|
|
||||||
if track_info.artist.len() > artist_len {
|
|
||||||
let mut artist: String = String::new();
|
|
||||||
let mut counter = 0;
|
|
||||||
for ch in track_info.artist.chars() {
|
|
||||||
if counter == artist_len {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
artist.push(ch);
|
|
||||||
counter += 1;
|
|
||||||
}
|
|
||||||
artist.push_str("..");
|
|
||||||
track_info.artist = artist;
|
|
||||||
}
|
|
||||||
println!(
|
println!(
|
||||||
"#[none]#[bold]{}{}{}#[none]{}{}{}{} {}[{}/{}] {} {}",
|
"#[none]#[bold]{}{}{}#[none]{}{}{}{} {}[{}/{}] {} {}",
|
||||||
TRACK_NAME,
|
TRACK_NAME,
|
||||||
|
|||||||
Reference in New Issue
Block a user