Skip to content

Commit

Permalink
feat: add prepend_rules and append_rules for [icon] (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
grig-iv authored Feb 13, 2024
1 parent 8bf0d64 commit b027487
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
18 changes: 0 additions & 18 deletions yazi-config/src/keymap/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,6 @@ impl<'de> Deserialize<'de> for Keymap {
#[rustfmt::skip]
Preset::mix(&mut shadow.completion.keymap, shadow.completion.prepend_keymap, shadow.completion.append_keymap);

// TODO: remove this when v0.2.3 is released --
if !shadow.input.keymap.iter().any(|c| c.on() == "<Backspace>") {
println!(
"WARNING: Default keybinding for `<Backspace>` is missing, please add a `{}` to the `[input]` section of `keymap.toml`.
In Yazi v0.2.0, `<Backspace>` previously hardcoded within the input component has been moved to `keymap.toml` to allow users to customize it.",
r#"{ on = [ "<Backspace>" ], exec = "backspace" }"#
);
}
// TODO: -- remove this when v0.2.3 is released

// TODO: remove this when v0.2.3 is released --
if shadow.manager.keymap.iter().any(|c| c.exec().contains("--empty=name")) {
println!(
"WARNING: `rename --empty=name` is deprecated in Yazi v0.2.2, please use `rename --empty=stem` instead.",
);
}
// TODO: -- remove this when v0.2.3 is released

Ok(Self {
manager: shadow.manager.keymap,
tasks: shadow.tasks.keymap,
Expand Down
13 changes: 10 additions & 3 deletions yazi-config/src/theme/icon.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use serde::{Deserialize, Deserializer};

use super::Style;
use crate::{theme::{Color, StyleShadow}, Pattern};
use crate::{preset::Preset, theme::{Color, StyleShadow}, Pattern};

pub struct Icon {
pub name: Pattern,
Expand All @@ -16,7 +16,11 @@ impl Icon {
{
#[derive(Deserialize)]
struct IconOuter {
rules: Vec<IconRule>,
rules: Vec<IconRule>,
#[serde(default)]
prepend_rules: Vec<IconRule>,
#[serde(default)]
append_rules: Vec<IconRule>,
}
#[derive(Deserialize)]
struct IconRule {
Expand All @@ -26,8 +30,11 @@ impl Icon {
fg: Option<Color>,
}

let mut outer = IconOuter::deserialize(deserializer)?;
Preset::mix(&mut outer.rules, outer.prepend_rules, outer.append_rules);

Ok(
IconOuter::deserialize(deserializer)?
outer
.rules
.into_iter()
.map(|r| Icon {
Expand Down

0 comments on commit b027487

Please sign in to comment.