@@ -73,6 +73,7 @@ pub struct ConfigValues {
|
||||
pub cover_max_scale: Option<f32>,
|
||||
pub playback_state: Option<PlaybackState>,
|
||||
pub track_format: Option<TrackFormat>,
|
||||
pub statusbar_format: Option<String>,
|
||||
pub library_tabs: Option<Vec<LibraryTab>>,
|
||||
pub hide_display_names: Option<bool>,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub enum Playable {
|
||||
}
|
||||
|
||||
impl Playable {
|
||||
pub fn format(playable: Playable, formatting: String, library: Arc<Library>) -> String {
|
||||
pub fn format(playable: &Playable, formatting: &str, library: Arc<Library>) -> String {
|
||||
formatting
|
||||
.replace(
|
||||
"%artists",
|
||||
|
||||
@@ -192,7 +192,7 @@ impl ListItem for Track {
|
||||
let default = config::TrackFormat::default().left.unwrap();
|
||||
let left = formatting.left.unwrap_or_else(|| default.clone());
|
||||
if left != default {
|
||||
Playable::format(Playable::Track(self.clone()), left, library)
|
||||
Playable::format(&Playable::Track(self.clone()), &left, library)
|
||||
} else {
|
||||
format!("{}", self)
|
||||
}
|
||||
@@ -208,7 +208,7 @@ impl ListItem for Track {
|
||||
let default = config::TrackFormat::default().center.unwrap();
|
||||
let center = formatting.center.unwrap_or_else(|| default.clone());
|
||||
if center != default {
|
||||
Playable::format(Playable::Track(self.clone()), center, library)
|
||||
Playable::format(&Playable::Track(self.clone()), ¢er, library)
|
||||
} else {
|
||||
self.album.clone().unwrap_or_default()
|
||||
}
|
||||
@@ -224,7 +224,7 @@ impl ListItem for Track {
|
||||
let default = config::TrackFormat::default().right.unwrap();
|
||||
let right = formatting.right.unwrap_or_else(|| default.clone());
|
||||
if right != default {
|
||||
Playable::format(Playable::Track(self.clone()), right, library)
|
||||
Playable::format(&Playable::Track(self.clone()), &right, library)
|
||||
} else {
|
||||
let saved = if library.is_saved_track(&Playable::Track(self.clone())) {
|
||||
if library.cfg.values().use_nerdfont.unwrap_or(false) {
|
||||
|
||||
@@ -9,6 +9,7 @@ use cursive::Printer;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
use crate::library::Library;
|
||||
use crate::model::playable::Playable;
|
||||
use crate::queue::{Queue, RepeatSetting};
|
||||
use crate::spotify::{PlayerEvent, Spotify};
|
||||
|
||||
@@ -68,6 +69,17 @@ impl StatusBar {
|
||||
(self.spotify.volume() as f64 / 65535_f64 * 100.0).round() as u16
|
||||
)
|
||||
}
|
||||
|
||||
fn format_track(&self, t: &Playable) -> String {
|
||||
let format = self
|
||||
.library
|
||||
.cfg
|
||||
.values()
|
||||
.statusbar_format
|
||||
.clone()
|
||||
.unwrap_or_else(|| "%artists - %title".to_string());
|
||||
Playable::format(t, &format, self.library.clone())
|
||||
}
|
||||
}
|
||||
|
||||
impl View for StatusBar {
|
||||
@@ -174,7 +186,7 @@ impl View for StatusBar {
|
||||
|
||||
printer.with_color(style, |printer| {
|
||||
if let Some(ref t) = self.queue.get_current() {
|
||||
printer.print((4, 1), &t.to_string());
|
||||
printer.print((4, 1), &self.format_track(t));
|
||||
}
|
||||
printer.print((offset, 1), &right);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user