|
|
@ -296,53 +296,58 @@ impl TryFrom<Value> for ThemePalette {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[cfg(test)]
|
|
|
|
fn test_parse_style_string() {
|
|
|
|
mod tests {
|
|
|
|
let fg = Value::String("#ffffff".to_string());
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
|
|
|
|
let mut style = Style::default();
|
|
|
|
#[test]
|
|
|
|
let palette = ThemePalette::default();
|
|
|
|
fn test_parse_style_string() {
|
|
|
|
palette.parse_style(&mut style, fg).unwrap();
|
|
|
|
let fg = Value::String("#ffffff".to_string());
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
|
|
|
|
let mut style = Style::default();
|
|
|
|
}
|
|
|
|
let palette = ThemePalette::default();
|
|
|
|
|
|
|
|
palette.parse_style(&mut style, fg).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
|
|
|
|
fn test_palette() {
|
|
|
|
}
|
|
|
|
use helix_core::hashmap;
|
|
|
|
|
|
|
|
let fg = Value::String("my_color".to_string());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut style = Style::default();
|
|
|
|
#[test]
|
|
|
|
let palette =
|
|
|
|
fn test_palette() {
|
|
|
|
ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) });
|
|
|
|
use helix_core::hashmap;
|
|
|
|
palette.parse_style(&mut style, fg).unwrap();
|
|
|
|
let fg = Value::String("my_color".to_string());
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
|
|
|
|
let mut style = Style::default();
|
|
|
|
}
|
|
|
|
let palette =
|
|
|
|
|
|
|
|
ThemePalette::new(hashmap! { "my_color".to_string() => Color::Rgb(255, 255, 255) });
|
|
|
|
|
|
|
|
palette.parse_style(&mut style, fg).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
assert_eq!(style, Style::default().fg(Color::Rgb(255, 255, 255)));
|
|
|
|
fn test_parse_style_table() {
|
|
|
|
}
|
|
|
|
let table = toml::toml! {
|
|
|
|
|
|
|
|
"keyword" = {
|
|
|
|
|
|
|
|
fg = "#ffffff",
|
|
|
|
|
|
|
|
bg = "#000000",
|
|
|
|
|
|
|
|
modifiers = ["bold"],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut style = Style::default();
|
|
|
|
#[test]
|
|
|
|
let palette = ThemePalette::default();
|
|
|
|
fn test_parse_style_table() {
|
|
|
|
if let Value::Table(entries) = table {
|
|
|
|
let table = toml::toml! {
|
|
|
|
for (_name, value) in entries {
|
|
|
|
"keyword" = {
|
|
|
|
palette.parse_style(&mut style, value).unwrap();
|
|
|
|
fg = "#ffffff",
|
|
|
|
|
|
|
|
bg = "#000000",
|
|
|
|
|
|
|
|
modifiers = ["bold"],
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut style = Style::default();
|
|
|
|
|
|
|
|
let palette = ThemePalette::default();
|
|
|
|
|
|
|
|
if let Value::Table(entries) = table {
|
|
|
|
|
|
|
|
for (_name, value) in entries {
|
|
|
|
|
|
|
|
palette.parse_style(&mut style, value).unwrap();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert_eq!(
|
|
|
|
assert_eq!(
|
|
|
|
style,
|
|
|
|
style,
|
|
|
|
Style::default()
|
|
|
|
Style::default()
|
|
|
|
.fg(Color::Rgb(255, 255, 255))
|
|
|
|
.fg(Color::Rgb(255, 255, 255))
|
|
|
|
.bg(Color::Rgb(0, 0, 0))
|
|
|
|
.bg(Color::Rgb(0, 0, 0))
|
|
|
|
.add_modifier(Modifier::BOLD)
|
|
|
|
.add_modifier(Modifier::BOLD)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|