Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add 'enable_text_emphasis' behavior config option
  • Loading branch information
kepae committed Sep 11, 2020
commit 35d9b796890fece8cd6558bcaba26c0be557bc0d
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ behavior:
volume_increment: 10
# The lower the number the higher the "frames per second". You can decrease this number so that the audio visualisation is smoother but this can be expensive!
tick_rate_milliseconds: 250
# Enable text emphasis (typically italic/bold text styling). Disabling this might be important if the terminal config is otherwise restricted and rendering text escapes interferes with the UI.
enable_text_emphasis: true
# controls whether to show a loading indicator in the top right of the UI whenever communicating with Spotify API
show_loading_indicator: true

Expand Down
7 changes: 6 additions & 1 deletion src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,12 +872,17 @@ where
let perc = get_track_progress_percentage(app.song_progress_ms, duration_ms);

let song_progress_label = display_track_progress(app.song_progress_ms, duration_ms);
let modifier = if app.user_config.behavior.enable_text_emphasis {
Modifier::ITALIC | Modifier::BOLD
} else {
Modifier::empty()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

};
let song_progress = Gauge::default()
.gauge_style(
Style::default()
.fg(app.user_config.theme.playbar_progress)
.bg(app.user_config.theme.playbar_background)
.add_modifier(Modifier::ITALIC | Modifier::BOLD),
.add_modifier(modifier),
)
.percent(perc)
.label(Span::styled(
Expand Down
7 changes: 7 additions & 0 deletions src/user_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ pub struct BehaviorConfigString {
pub seek_milliseconds: Option<u32>,
pub volume_increment: Option<u8>,
pub tick_rate_milliseconds: Option<u64>,
pub enable_text_emphasis: Option<bool>,
pub show_loading_indicator: Option<bool>,
}

Expand All @@ -205,6 +206,7 @@ pub struct BehaviorConfig {
pub seek_milliseconds: u32,
pub volume_increment: u8,
pub tick_rate_milliseconds: u64,
pub enable_text_emphasis: bool,
pub show_loading_indicator: bool,
}

Expand Down Expand Up @@ -254,6 +256,7 @@ impl UserConfig {
seek_milliseconds: 5 * 1000,
volume_increment: 10,
tick_rate_milliseconds: 250,
enable_text_emphasis: true,
show_loading_indicator: true,
},
path_to_config: None,
Expand Down Expand Up @@ -370,6 +373,10 @@ impl UserConfig {
}
}

if let Some(text_emphasis) = behavior_config.enable_text_emphasis {
self.behavior.enable_text_emphasis = text_emphasis;
}

if let Some(loading_indicator) = behavior_config.show_loading_indicator {
self.behavior.show_loading_indicator = loading_indicator;
}
Expand Down