From 8a1c03f97d8c56fad74f8fc40151d7b3789de4a0 Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 19 May 2020 23:02:47 +0200 Subject: [PATCH] one less public symbol --- src/components/diff.rs | 2 +- src/ui/style.rs | 41 +++++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/components/diff.rs b/src/components/diff.rs index a9273eb9..1aa599f7 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -397,7 +397,7 @@ mod tests { false, false, false, - crate::ui::style::DARK_THEME, + Theme::default(), ); assert_eq!(text.len(), 2); diff --git a/src/ui/style.rs b/src/ui/style.rs index c8dabe78..2dd1172a 100644 --- a/src/ui/style.rs +++ b/src/ui/style.rs @@ -38,22 +38,6 @@ pub struct Theme { commit_author: Color, } -pub const DARK_THEME: Theme = Theme { - selected_tab: Color::Yellow, - command_foreground: Color::White, - command_background: Color::Rgb(0, 0, 100), - command_disabled: Color::DarkGray, - diff_line_add: Color::Green, - diff_line_delete: Color::Red, - diff_file_added: Color::LightGreen, - diff_file_removed: Color::LightRed, - diff_file_moved: Color::LightMagenta, - diff_file_modified: Color::Yellow, - commit_hash: Color::Magenta, - commit_time: Color::Blue, - commit_author: Color::Green, -}; - impl Theme { pub fn block(&self, focus: bool) -> Style { if focus { @@ -196,8 +180,29 @@ impl Theme { if let Ok(x) = Theme::read_file(Theme::get_theme_file()) { x } else { - DARK_THEME.save().unwrap_or_default(); - DARK_THEME + let res = Self::default(); + res.save().unwrap_or_default(); + res + } + } +} + +impl Default for Theme { + fn default() -> Self { + Self { + selected_tab: Color::Yellow, + command_foreground: Color::White, + command_background: Color::Rgb(0, 0, 100), + command_disabled: Color::DarkGray, + diff_line_add: Color::Green, + diff_line_delete: Color::Red, + diff_file_added: Color::LightGreen, + diff_file_removed: Color::LightRed, + diff_file_moved: Color::LightMagenta, + diff_file_modified: Color::Yellow, + commit_hash: Color::Magenta, + commit_time: Color::Blue, + commit_author: Color::Green, } } }