-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
323 additions
and
244 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use std::{fmt, str::FromStr}; | ||
|
||
use anyhow::Result; | ||
use serde::{de::{self, Visitor}, Deserializer}; | ||
use yazi_shared::event::Cmd; | ||
|
||
use crate::keymap::Key; | ||
|
||
pub(super) fn deserialize_on<'de, D>(deserializer: D) -> Result<Vec<Key>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
struct OnVisitor; | ||
|
||
impl<'de> Visitor<'de> for OnVisitor { | ||
type Value = Vec<Key>; | ||
|
||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
formatter.write_str("a `on` string or array of strings within keymap.toml") | ||
} | ||
|
||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> | ||
where | ||
A: de::SeqAccess<'de>, | ||
{ | ||
let mut cmds = vec![]; | ||
while let Some(value) = &seq.next_element::<String>()? { | ||
cmds.push(Key::from_str(value).map_err(de::Error::custom)?); | ||
} | ||
if cmds.is_empty() { | ||
return Err(de::Error::custom("`on` within keymap.toml cannot be empty")); | ||
} | ||
Ok(cmds) | ||
} | ||
|
||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> | ||
where | ||
E: de::Error, | ||
{ | ||
Ok(vec![Key::from_str(value).map_err(de::Error::custom)?]) | ||
} | ||
} | ||
|
||
deserializer.deserialize_any(OnVisitor) | ||
} | ||
|
||
pub(super) fn deserialize_run<'de, D>(deserializer: D) -> Result<Vec<Cmd>, D::Error> | ||
where | ||
D: Deserializer<'de>, | ||
{ | ||
struct RunVisitor; | ||
|
||
impl<'de> Visitor<'de> for RunVisitor { | ||
type Value = Vec<Cmd>; | ||
|
||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { | ||
formatter.write_str("a `run` string or array of strings within keymap.toml") | ||
} | ||
|
||
fn visit_seq<A>(self, mut seq: A) -> Result<Self::Value, A::Error> | ||
where | ||
A: de::SeqAccess<'de>, | ||
{ | ||
let mut cmds = vec![]; | ||
while let Some(value) = &seq.next_element::<String>()? { | ||
cmds.push(Cmd::from_str(value).map_err(de::Error::custom)?); | ||
} | ||
if cmds.is_empty() { | ||
return Err(de::Error::custom("`run` within keymap.toml cannot be empty")); | ||
} | ||
Ok(cmds) | ||
} | ||
|
||
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E> | ||
where | ||
E: de::Error, | ||
{ | ||
Ok(vec![Cmd::from_str(value).map_err(de::Error::custom)?]) | ||
} | ||
} | ||
|
||
deserializer.deserialize_any(RunVisitor) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
mod control; | ||
mod cow; | ||
mod deserializers; | ||
mod key; | ||
mod keymap; | ||
mod run; | ||
|
||
pub use control::*; | ||
pub use cow::*; | ||
use deserializers::*; | ||
pub use key::*; | ||
pub use keymap::*; | ||
#[allow(unused_imports)] | ||
pub use run::*; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
os.setlocale("") | ||
package.path = BOOT.plugin_dir .. "/?.yazi/init.lua;" .. package.path | ||
|
||
require("dds"):setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters