aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorlukeflo2025-06-08 20:57:49 +0200
committerlukeflo2025-06-08 20:57:49 +0200
commit9653a63d8ad5a6cc2b5edaab971ece69440e5a52 (patch)
tree62b85d5c30bc6e187971f4839840a3ea3e4cfa39 /src/config.rs
parent14e1613f81e5b35aef4f3f9627802e86f1716c64 (diff)
downloadbibiman-9653a63d8ad5a6cc2b5edaab971ece69440e5a52.tar.gz
bibiman-9653a63d8ad5a6cc2b5edaab971ece69440e5a52.zip
Fix: light terminal flag, rm obsolete color.rs file
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs74
1 files changed, 50 insertions, 24 deletions
diff --git a/src/config.rs b/src/config.rs
index 8d50d93..f5f2dd0 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -118,30 +118,37 @@ impl Default for BibiConfig {
file_prefix: None,
pdf_path: None,
},
- colors: Colors {
- main_text_color: Color::Indexed(250),
- highlight_text_color: Color::Indexed(254),
- entry_color: Color::Indexed(36),
- keyword_color: Color::Indexed(101),
- info_color: Color::Indexed(99),
- confirm_color: Color::Indexed(47),
- warn_color: Color::Indexed(124),
- bar_bg_color: Color::Indexed(235),
- popup_bg_color: Color::Indexed(234),
- selected_row_bg_color: Color::Indexed(237),
- },
+ colors: Self::dark_colors(),
}
}
}
impl BibiConfig {
+ pub fn new(args: &CLIArgs) -> Self {
+ Self {
+ general: General {
+ bibfiles: None,
+ editor: None,
+ pdf_opener: select_opener(),
+ url_opener: select_opener(),
+ file_prefix: None,
+ pdf_path: None,
+ },
+ colors: if args.light_theme {
+ Self::light_colors()
+ } else {
+ Self::dark_colors()
+ },
+ }
+ }
+
pub fn parse_config(args: &CLIArgs) -> Result<BibiConfig> {
let cfg_file: BibiConfig = if args.cfg_path.as_ref().unwrap().is_file() {
- Figment::from(Serialized::defaults(BibiConfig::default()))
+ Figment::from(Serialized::defaults(BibiConfig::new(args)))
.merge(Toml::file(&args.cfg_path.as_ref().unwrap()))
.extract()?
} else {
- BibiConfig::default()
+ BibiConfig::new(args)
};
Ok(cfg_file)
@@ -155,17 +162,36 @@ impl BibiConfig {
}
}
+ /// Standard color scheme for terminals with dark background (default)
+ pub fn dark_colors() -> Colors {
+ Colors {
+ main_text_color: Color::Indexed(250),
+ highlight_text_color: Color::Indexed(254),
+ entry_color: Color::Indexed(36),
+ keyword_color: Color::Indexed(101),
+ info_color: Color::Indexed(99),
+ confirm_color: Color::Indexed(47),
+ warn_color: Color::Indexed(124),
+ bar_bg_color: Color::Indexed(235),
+ popup_bg_color: Color::Indexed(234),
+ selected_row_bg_color: Color::Indexed(237),
+ }
+ }
+
/// Activates the default color scheme for light background terminals
- pub fn light_colors(&mut self) {
- self.colors.main_text_color = Color::Indexed(235);
- self.colors.highlight_text_color = Color::Indexed(232);
- self.colors.entry_color = Color::Indexed(23);
- self.colors.keyword_color = Color::Indexed(58);
- self.colors.info_color = Color::Indexed(57);
- self.colors.bar_bg_color = Color::Indexed(144);
- self.colors.popup_bg_color = Color::Indexed(187);
- self.colors.confirm_color = Color::Indexed(22);
- self.colors.selected_row_bg_color = Color::Indexed(107);
+ pub fn light_colors() -> Colors {
+ Colors {
+ main_text_color: Color::Indexed(235),
+ highlight_text_color: Color::Indexed(232),
+ entry_color: Color::Indexed(23),
+ keyword_color: Color::Indexed(58),
+ info_color: Color::Indexed(57),
+ bar_bg_color: Color::Indexed(144),
+ popup_bg_color: Color::Indexed(187),
+ confirm_color: Color::Indexed(22),
+ warn_color: Color::Indexed(124),
+ selected_row_bg_color: Color::Indexed(107),
+ }
}
/// Function which offers the user to create a default config