diff options
author | Canop <cano.petrole@gmail.com> | 2019-05-10 22:48:15 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-05-10 22:48:15 +0200 |
commit | e0ac1553d6f9f300d69df6e34e5e55e634173faf (patch) | |
tree | 6f6c02aca140338234f025715067a5aa11fcbe19 /src/conf.rs | |
parent | e4d0886af013290a4d42f0c2a0e2cff1543652f7 (diff) |
skin colors changed by configuration according to new fg,bg,attrs syntax:
[skin]
directory = "red yellow bold"
tree = "gray(3) none"
file = "rgb(255,187,0) black italic"
selected_line = "none cyan"
Diffstat (limited to 'src/conf.rs')
-rw-r--r-- | src/conf.rs | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/conf.rs b/src/conf.rs index a2c7915..106dade 100644 --- a/src/conf.rs +++ b/src/conf.rs @@ -9,8 +9,10 @@ use std::io; use std::path::{Path, PathBuf}; use std::result::Result; use toml::{self, Value}; +use crossterm::ObjectStyle; use crate::errors::ConfError; +use crate::skin_conf; /// what's needed to handle a verb #[derive(Debug)] @@ -24,10 +26,9 @@ pub struct VerbConf { pub confirm: Option<bool>, } -#[derive(Debug)] pub struct Conf { pub verbs: Vec<VerbConf>, - pub skin_entries: HashMap<String, String>, + pub skin: HashMap<String, ObjectStyle>, } fn string_field(value: &Value, field_name: &str) -> Option<String> { @@ -129,21 +130,21 @@ impl Conf { } } // reading the skin - let mut skin_entries = HashMap::new(); - //if let Some(Value::Table(entries_tbl)) = &root.get("skin") { - // for (k, v) in entries_tbl.iter() { - // if let Some(s) = v.as_str() { - // match skin_conf::parse_config_entry(k, s) { - // Ok(ske) => { skin_entries.insert(k.to_string(), ske); }, - // Err(e) => { eprintln!("{}", e); } - // } - // } - // } - //} + let mut skin = HashMap::new(); + if let Some(Value::Table(entries_tbl)) = &root.get("skin") { + for (k, v) in entries_tbl.iter() { + if let Some(s) = v.as_str() { + match skin_conf::parse_object_style(s) { + Ok(ske) => { skin.insert(k.to_string(), ske); }, + Err(e) => { eprintln!("{}", e); } + } + } + } + } Ok(Conf { verbs, - skin_entries, + skin, }) } } |