termusiclib/config/tui_overlay.rs
1use crate::config::v2::tui::CoverArtProtocol;
2
3/// The TUI Settings to use, with possible overwrite (like from CLI)
4#[derive(Debug, Clone, PartialEq, Default)]
5#[allow(clippy::module_name_repetitions)]
6pub struct TuiOverlay {
7 /// The saved TUI-Settings
8 pub settings: super::v2::tui::TuiSettings,
9
10 /// Disable TUI images (like cover-art) from being displayed in the terminal
11 ///
12 /// This option will not be saved to the config and prevent saving to the config value
13 ///
14 /// (disables ueberzug, sixel, iterm, kitty image displaying)
15 pub coverart_hidden_overwrite: Option<bool>,
16
17 /// Enable/Disable checking for cover support.
18 ///
19 /// If `false`, will treat as if no cover features are compiled-in.
20 pub cover_features: bool,
21}
22
23impl TuiOverlay {
24 /// Get whether the coverart should be hidden or not, either the overwrite if present, otherwise the config itself
25 ///
26 /// true => hidden
27 #[must_use]
28 pub fn get_coverart_hidden(&self) -> bool {
29 if let Some(overwrite) = self.coverart_hidden_overwrite {
30 overwrite
31 } else {
32 self.settings.coverart.hidden
33 }
34 }
35
36 /// Get whether cover features should be enabled or not, regardless if they are compiled-in or not.
37 #[must_use]
38 pub fn cover_features_enabled(&self) -> bool {
39 self.cover_features
40 }
41
42 /// Check if a given [`CoverArtProtocol`] is enabled.
43 #[inline]
44 #[must_use]
45 pub fn cover_protocol_enabled(&self, protocol: CoverArtProtocol) -> bool {
46 self.settings.coverart.protocols.includes_protocol(protocol)
47 }
48}