Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add prepend_rules and append_rules for [icon] #670

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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