mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01:05 +00:00
refactor: simplify FromStr implementations with strum
This commit is contained in:
parent
4857d46918
commit
ad655eda52
31 changed files with 108 additions and 231 deletions
35
Cargo.lock
generated
35
Cargo.lock
generated
|
|
@ -1946,9 +1946,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.13.0"
|
version = "2.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
|
checksum = "45a8a2b9cb3e0b0c1803dbb0758ffac5de2f425b23c28f518faabd9d805342ff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.16.1",
|
"hashbrown 0.16.1",
|
||||||
|
|
@ -3075,7 +3075,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07"
|
checksum = "740ebea15c5d1428f910cd1a5f52cebf8d25006245ed8ade92702f4943d91e07"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"quick-xml",
|
"quick-xml",
|
||||||
"serde",
|
"serde",
|
||||||
"time",
|
"time",
|
||||||
|
|
@ -3938,7 +3938,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"hex",
|
"hex",
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"schemars 0.9.0",
|
"schemars 0.9.0",
|
||||||
"schemars 1.2.1",
|
"schemars 1.2.1",
|
||||||
"serde_core",
|
"serde_core",
|
||||||
|
|
@ -4578,7 +4578,7 @@ version = "1.1.2+spec-1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
|
checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"serde_core",
|
"serde_core",
|
||||||
"serde_spanned",
|
"serde_spanned",
|
||||||
"toml_datetime",
|
"toml_datetime",
|
||||||
|
|
@ -4998,7 +4998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"wasm-encoder",
|
"wasm-encoder",
|
||||||
"wasmparser",
|
"wasmparser",
|
||||||
]
|
]
|
||||||
|
|
@ -5011,7 +5011,7 @@ checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.11.0",
|
"bitflags 2.11.0",
|
||||||
"hashbrown 0.15.5",
|
"hashbrown 0.15.5",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"semver",
|
"semver",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -5507,7 +5507,7 @@ checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"heck",
|
"heck",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"prettyplease",
|
"prettyplease",
|
||||||
"syn 2.0.117",
|
"syn 2.0.117",
|
||||||
"wasm-metadata",
|
"wasm-metadata",
|
||||||
|
|
@ -5538,7 +5538,7 @@ checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bitflags 2.11.0",
|
"bitflags 2.11.0",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
|
|
@ -5557,7 +5557,7 @@ checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"id-arena",
|
"id-arena",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"log",
|
"log",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
@ -5613,6 +5613,7 @@ dependencies = [
|
||||||
"yazi-runner",
|
"yazi-runner",
|
||||||
"yazi-scheduler",
|
"yazi-scheduler",
|
||||||
"yazi-shared",
|
"yazi-shared",
|
||||||
|
"yazi-shim",
|
||||||
"yazi-term",
|
"yazi-term",
|
||||||
"yazi-tty",
|
"yazi-tty",
|
||||||
"yazi-vfs",
|
"yazi-vfs",
|
||||||
|
|
@ -5633,6 +5634,7 @@ dependencies = [
|
||||||
"palette",
|
"palette",
|
||||||
"quantette",
|
"quantette",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
|
"strum 0.28.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"yazi-config",
|
"yazi-config",
|
||||||
|
|
@ -5640,6 +5642,7 @@ dependencies = [
|
||||||
"yazi-fs",
|
"yazi-fs",
|
||||||
"yazi-macro",
|
"yazi-macro",
|
||||||
"yazi-shared",
|
"yazi-shared",
|
||||||
|
"yazi-shim",
|
||||||
"yazi-tty",
|
"yazi-tty",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -5668,6 +5671,7 @@ dependencies = [
|
||||||
"yazi-fs",
|
"yazi-fs",
|
||||||
"yazi-macro",
|
"yazi-macro",
|
||||||
"yazi-shared",
|
"yazi-shared",
|
||||||
|
"yazi-shim",
|
||||||
"yazi-vfs",
|
"yazi-vfs",
|
||||||
"yazi-widgets",
|
"yazi-widgets",
|
||||||
]
|
]
|
||||||
|
|
@ -5742,10 +5746,11 @@ dependencies = [
|
||||||
"crossterm 0.29.0",
|
"crossterm 0.29.0",
|
||||||
"globset",
|
"globset",
|
||||||
"hashbrown 0.16.1",
|
"hashbrown 0.16.1",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
|
"strum 0.28.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"toml",
|
"toml",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
|
@ -5763,12 +5768,13 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"crossterm 0.29.0",
|
"crossterm 0.29.0",
|
||||||
"hashbrown 0.16.1",
|
"hashbrown 0.16.1",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"mlua",
|
"mlua",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_with",
|
"serde_with",
|
||||||
|
"strum 0.28.0",
|
||||||
"syntect",
|
"syntect",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
|
|
@ -5798,7 +5804,7 @@ version = "26.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"hashbrown 0.16.1",
|
"hashbrown 0.16.1",
|
||||||
"indexmap 2.13.0",
|
"indexmap 2.13.1",
|
||||||
"mlua",
|
"mlua",
|
||||||
"ordered-float 5.3.0",
|
"ordered-float 5.3.0",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
|
|
@ -5907,6 +5913,7 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
"serde",
|
"serde",
|
||||||
|
"strum 0.28.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"trash",
|
"trash",
|
||||||
|
|
@ -5939,6 +5946,7 @@ dependencies = [
|
||||||
"paste",
|
"paste",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
"serde",
|
"serde",
|
||||||
|
"strum 0.28.0",
|
||||||
"tokio",
|
"tokio",
|
||||||
"yazi-binding",
|
"yazi-binding",
|
||||||
"yazi-boot",
|
"yazi-boot",
|
||||||
|
|
@ -6021,6 +6029,7 @@ dependencies = [
|
||||||
"mlua",
|
"mlua",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"serde",
|
"serde",
|
||||||
|
"strum 0.28.0",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ foldhash = "0.2.0"
|
||||||
futures = "0.3.32"
|
futures = "0.3.32"
|
||||||
globset = "0.4.18"
|
globset = "0.4.18"
|
||||||
hashbrown = { version = "0.16.1", features = [ "serde" ] }
|
hashbrown = { version = "0.16.1", features = [ "serde" ] }
|
||||||
indexmap = { version = "2.13.0", features = [ "serde" ] }
|
indexmap = { version = "2.13.1", features = [ "serde" ] }
|
||||||
libc = "0.2.184"
|
libc = "0.2.184"
|
||||||
lru = "0.16.3"
|
lru = "0.16.3"
|
||||||
mlua = { version = "0.11.6", features = [ "anyhow", "async", "error-send", "lua55", "macros", "serde" ] }
|
mlua = { version = "0.11.6", features = [ "anyhow", "async", "error-send", "lua55", "macros", "serde" ] }
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ yazi-proxy = { path = "../yazi-proxy", version = "26.2.2" }
|
||||||
yazi-runner = { path = "../yazi-runner", version = "26.2.2" }
|
yazi-runner = { path = "../yazi-runner", version = "26.2.2" }
|
||||||
yazi-scheduler = { path = "../yazi-scheduler", version = "26.2.2" }
|
yazi-scheduler = { path = "../yazi-scheduler", version = "26.2.2" }
|
||||||
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
||||||
|
yazi-shim = { path = "../yazi-shim", version = "26.2.2" }
|
||||||
yazi-term = { path = "../yazi-term", version = "26.2.2" }
|
yazi-term = { path = "../yazi-term", version = "26.2.2" }
|
||||||
yazi-tty = { path = "../yazi-tty", version = "26.2.2" }
|
yazi-tty = { path = "../yazi-tty", version = "26.2.2" }
|
||||||
yazi-vfs = { path = "../yazi-vfs", version = "26.2.2" }
|
yazi-vfs = { path = "../yazi-vfs", version = "26.2.2" }
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ pub struct Preflight;
|
||||||
impl Preflight {
|
impl Preflight {
|
||||||
pub fn act<'a>(cx: &mut Ctx, opt: (SparkKind, Spark<'a>)) -> Result<Spark<'a>> {
|
pub fn act<'a>(cx: &mut Ctx, opt: (SparkKind, Spark<'a>)) -> Result<Spark<'a>> {
|
||||||
let kind = opt.0;
|
let kind = opt.0;
|
||||||
let Some(handlers) = LOCAL.read().get(kind.as_ref()).filter(|&m| !m.is_empty()).cloned() else {
|
let Some(handlers) = LOCAL.read().get(kind.into()).filter(|&m| !m.is_empty()).cloned() else {
|
||||||
return Ok(opt.1);
|
return Ok(opt.1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ use std::ops::Deref;
|
||||||
|
|
||||||
use mlua::{AnyUserData, UserData, UserDataFields, Value};
|
use mlua::{AnyUserData, UserData, UserDataFields, Value};
|
||||||
use yazi_binding::cached_field;
|
use yazi_binding::cached_field;
|
||||||
|
use yazi_shim::strum::IntoStr;
|
||||||
|
|
||||||
use super::{Lives, PtrCell};
|
use super::{Lives, PtrCell};
|
||||||
|
|
||||||
|
|
@ -41,11 +42,11 @@ impl UserData for Preference {
|
||||||
fields.add_field_method_get("show_hidden", |_, me| Ok(me.show_hidden));
|
fields.add_field_method_get("show_hidden", |_, me| Ok(me.show_hidden));
|
||||||
|
|
||||||
// Sorting
|
// Sorting
|
||||||
cached_field!(fields, sort_by, |_, me| Ok(me.sort_by.to_string()));
|
cached_field!(fields, sort_by, |_, me| Ok(me.sort_by.into_str()));
|
||||||
fields.add_field_method_get("sort_sensitive", |_, me| Ok(me.sort_sensitive));
|
fields.add_field_method_get("sort_sensitive", |_, me| Ok(me.sort_sensitive));
|
||||||
fields.add_field_method_get("sort_reverse", |_, me| Ok(me.sort_reverse));
|
fields.add_field_method_get("sort_reverse", |_, me| Ok(me.sort_reverse));
|
||||||
fields.add_field_method_get("sort_dir_first", |_, me| Ok(me.sort_dir_first));
|
fields.add_field_method_get("sort_dir_first", |_, me| Ok(me.sort_dir_first));
|
||||||
fields.add_field_method_get("sort_translit", |_, me| Ok(me.sort_translit));
|
fields.add_field_method_get("sort_translit", |_, me| Ok(me.sort_translit));
|
||||||
fields.add_field_method_get("sort_fallback", |_, me| Ok(me.sort_fallback.to_string()));
|
fields.add_field_method_get("sort_fallback", |_, me| Ok(me.sort_fallback.into_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,7 @@ impl Actor for Search {
|
||||||
handle.abort();
|
handle.abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut input =
|
let mut input = InputProxy::show(InputCfg::search(opt.via.into()).with_value(&*opt.subject));
|
||||||
InputProxy::show(InputCfg::search(opt.via.into_str()).with_value(&*opt.subject));
|
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Some(InputEvent::Submit(subject)) = input.recv().await {
|
if let Some(InputEvent::Submit(subject)) = input.recv().await {
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ yazi-emulator = { path = "../yazi-emulator", version = "26.2.2" }
|
||||||
yazi-fs = { path = "../yazi-fs", version = "26.2.2" }
|
yazi-fs = { path = "../yazi-fs", version = "26.2.2" }
|
||||||
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
||||||
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
||||||
|
yazi-shim = { path = "../yazi-shim", version = "26.2.2" }
|
||||||
yazi-tty = { path = "../yazi-tty", version = "26.2.2" }
|
yazi-tty = { path = "../yazi-tty", version = "26.2.2" }
|
||||||
|
|
||||||
# External dependencies
|
# External dependencies
|
||||||
|
|
@ -30,6 +31,7 @@ moxcms = "0.8.1"
|
||||||
palette = { version = "0.7.6", default-features = false }
|
palette = { version = "0.7.6", default-features = false }
|
||||||
quantette = { version = "0.5.1", default-features = false }
|
quantette = { version = "0.5.1", default-features = false }
|
||||||
ratatui = { workspace = true }
|
ratatui = { workspace = true }
|
||||||
|
strum = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
use std::{env, fmt::Display, path::PathBuf};
|
use std::{env, path::PathBuf};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
|
use strum::{Display, IntoStaticStr};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
use yazi_emulator::{Emulator, TMUX};
|
use yazi_emulator::{Emulator, TMUX};
|
||||||
use yazi_shared::env_exists;
|
use yazi_shared::env_exists;
|
||||||
|
|
||||||
use crate::{Adapters, SHOWN, drivers};
|
use crate::{Adapters, SHOWN, drivers};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Display, Eq, IntoStaticStr, PartialEq)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum Adapter {
|
pub enum Adapter {
|
||||||
Kgp,
|
Kgp,
|
||||||
KgpOld,
|
KgpOld,
|
||||||
|
|
@ -21,20 +23,6 @@ pub enum Adapter {
|
||||||
Chafa,
|
Chafa,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Adapter {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Self::Kgp => write!(f, "kgp"),
|
|
||||||
Self::KgpOld => write!(f, "kgp-old"),
|
|
||||||
Self::Iip => write!(f, "iip"),
|
|
||||||
Self::Sixel => write!(f, "sixel"),
|
|
||||||
Self::X11 => write!(f, "x11"),
|
|
||||||
Self::Wayland => write!(f, "wayland"),
|
|
||||||
Self::Chafa => write!(f, "chafa"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Adapter {
|
impl Adapter {
|
||||||
pub async fn image_show<P>(self, path: P, max: Rect) -> Result<Rect>
|
pub async fn image_show<P>(self, path: P, max: Rect) -> Result<Rect>
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ use tracing::{debug, warn};
|
||||||
use yazi_config::YAZI;
|
use yazi_config::YAZI;
|
||||||
use yazi_emulator::Dimension;
|
use yazi_emulator::Dimension;
|
||||||
use yazi_shared::{LOG_LEVEL, RoCell, env_exists};
|
use yazi_shared::{LOG_LEVEL, RoCell, env_exists};
|
||||||
|
use yazi_shim::strum::IntoStr;
|
||||||
|
|
||||||
use crate::Adapter;
|
use crate::Adapter;
|
||||||
|
|
||||||
|
|
@ -86,7 +87,7 @@ impl Ueberzug {
|
||||||
|
|
||||||
fn create_demon(adapter: Adapter) -> Result<Child> {
|
fn create_demon(adapter: Adapter) -> Result<Child> {
|
||||||
let result = Command::new("ueberzugpp")
|
let result = Command::new("ueberzugpp")
|
||||||
.args(["layer", "-so", &adapter.to_string()])
|
.args(["layer", "-so", adapter.into_str()])
|
||||||
.env("SPDLOG_LEVEL", if LOG_LEVEL.get().is_none() { "" } else { "debug" })
|
.env("SPDLOG_LEVEL", if LOG_LEVEL.get().is_none() { "" } else { "debug" })
|
||||||
.kill_on_drop(true)
|
.kill_on_drop(true)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ yazi-config = { path = "../yazi-config", version = "26.2.2" }
|
||||||
yazi-fs = { path = "../yazi-fs", version = "26.2.2" }
|
yazi-fs = { path = "../yazi-fs", version = "26.2.2" }
|
||||||
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
||||||
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
yazi-shared = { path = "../yazi-shared", version = "26.2.2" }
|
||||||
|
yazi-shim = { path = "../yazi-shim", version = "26.2.2" }
|
||||||
yazi-vfs = { path = "../yazi-vfs", version = "26.2.2" }
|
yazi-vfs = { path = "../yazi-vfs", version = "26.2.2" }
|
||||||
yazi-widgets = { path = "../yazi-widgets", version = "26.2.2" }
|
yazi-widgets = { path = "../yazi-widgets", version = "26.2.2" }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{ops::Deref, str::FromStr};
|
use std::{ops::Deref, str::FromStr};
|
||||||
|
|
||||||
use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, Value};
|
use mlua::{AnyUserData, ExternalError, ExternalResult, FromLua, IntoLua, Lua, MetaMethod, Table, UserData, Value};
|
||||||
|
use yazi_shim::strum::IntoStr;
|
||||||
|
|
||||||
use super::Pad;
|
use super::Pad;
|
||||||
|
|
||||||
|
|
@ -82,7 +83,7 @@ impl Pos {
|
||||||
impl UserData for Pos {
|
impl UserData for Pos {
|
||||||
fn add_fields<F: mlua::UserDataFields<Self>>(fields: &mut F) {
|
fn add_fields<F: mlua::UserDataFields<Self>>(fields: &mut F) {
|
||||||
// TODO: cache
|
// TODO: cache
|
||||||
fields.add_field_method_get("1", |_, me| Ok(me.origin.to_string()));
|
fields.add_field_method_get("1", |_, me| Ok(me.origin.into_str()));
|
||||||
fields.add_field_method_get("x", |_, me| Ok(me.offset.x));
|
fields.add_field_method_get("x", |_, me| Ok(me.offset.x));
|
||||||
fields.add_field_method_get("y", |_, me| Ok(me.offset.y));
|
fields.add_field_method_get("y", |_, me| Ok(me.offset.y));
|
||||||
fields.add_field_method_get("w", |_, me| Ok(me.offset.width));
|
fields.add_field_method_get("w", |_, me| Ok(me.offset.width));
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
use mlua::{MetaMethod, UserData};
|
use mlua::{MetaMethod, UserData};
|
||||||
|
use yazi_shim::strum::IntoStr;
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Layer(yazi_shared::Layer);
|
pub struct Layer(yazi_shared::Layer);
|
||||||
|
|
@ -9,6 +10,6 @@ impl From<yazi_shared::Layer> for Layer {
|
||||||
|
|
||||||
impl UserData for Layer {
|
impl UserData for Layer {
|
||||||
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
||||||
methods.add_meta_method(MetaMethod::ToString, |_, me, ()| Ok(me.0.to_string()));
|
methods.add_meta_method(MetaMethod::ToString, |_, me, ()| Ok(me.0.into_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ use std::ops::Deref;
|
||||||
use mlua::{UserData, UserDataFields, Value};
|
use mlua::{UserData, UserDataFields, Value};
|
||||||
use yazi_fs::FsScheme;
|
use yazi_fs::FsScheme;
|
||||||
use yazi_shared::scheme::SchemeLike;
|
use yazi_shared::scheme::SchemeLike;
|
||||||
|
use yazi_shim::strum::IntoStr;
|
||||||
|
|
||||||
use crate::{Path, cached_field};
|
use crate::{Path, cached_field};
|
||||||
|
|
||||||
|
|
@ -27,7 +28,7 @@ impl Scheme {
|
||||||
|
|
||||||
impl UserData for Scheme {
|
impl UserData for Scheme {
|
||||||
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
|
fn add_fields<F: UserDataFields<Self>>(fields: &mut F) {
|
||||||
cached_field!(fields, kind, |_, me| Ok(Into::<&'static str>::into(me.kind())));
|
cached_field!(fields, kind, |_, me| Ok(me.kind().into_str()));
|
||||||
cached_field!(fields, cache, |_, me| Ok(me.cache().map(Path::new)));
|
cached_field!(fields, cache, |_, me| Ok(me.cache().map(Path::new)));
|
||||||
|
|
||||||
fields.add_field_method_get("is_virtual", |_, me| Ok(me.is_virtual()));
|
fields.add_field_method_get("is_virtual", |_, me| Ok(me.is_virtual()));
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ indexmap = { workspace = true }
|
||||||
ratatui = { workspace = true }
|
ratatui = { workspace = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
strum = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
toml = { workspace = true }
|
toml = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use std::{fmt::Display, str::FromStr};
|
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use strum::{EnumString, IntoStaticStr};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum Origin {
|
pub enum Origin {
|
||||||
#[default]
|
#[default]
|
||||||
TopLeft,
|
TopLeft,
|
||||||
|
|
@ -17,28 +17,3 @@ pub enum Origin {
|
||||||
Center,
|
Center,
|
||||||
Hovered,
|
Hovered,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Origin {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
f.write_str(match self {
|
|
||||||
Self::TopLeft => "top-left",
|
|
||||||
Self::TopCenter => "top-center",
|
|
||||||
Self::TopRight => "top-right",
|
|
||||||
|
|
||||||
Self::BottomLeft => "bottom-left",
|
|
||||||
Self::BottomCenter => "bottom-center",
|
|
||||||
Self::BottomRight => "bottom-right",
|
|
||||||
|
|
||||||
Self::Center => "center",
|
|
||||||
Self::Hovered => "hovered",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Origin {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ parking_lot = { workspace = true }
|
||||||
ratatui = { workspace = true }
|
ratatui = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_with = { workspace = true }
|
serde_with = { workspace = true }
|
||||||
|
strum = { workspace = true }
|
||||||
syntect = { workspace = true }
|
syntect = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tokio-stream = { workspace = true }
|
tokio-stream = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use strum::{EnumString, IntoStaticStr};
|
||||||
use yazi_shared::{SStr, event::ActionCow, url::{UrlCow, UrlLike}};
|
use yazi_shared::{SStr, event::ActionCow, url::{UrlCow, UrlLike}};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
@ -39,28 +38,11 @@ impl TryFrom<ActionCow> for SearchOpt {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Via
|
// Via
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum SearchVia {
|
pub enum SearchVia {
|
||||||
Rg,
|
Rg,
|
||||||
Rga,
|
Rga,
|
||||||
Fd,
|
Fd,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for SearchVia {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SearchVia {
|
|
||||||
pub fn into_str(self) -> &'static str {
|
|
||||||
match self {
|
|
||||||
Self::Rg => "rg",
|
|
||||||
Self::Rga => "rga",
|
|
||||||
Self::Fd => "fd",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ rand = { workspace = true }
|
||||||
regex = { workspace = true }
|
regex = { workspace = true }
|
||||||
scopeguard = { workspace = true }
|
scopeguard = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
strum = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tracing = { workspace = true }
|
tracing = { workspace = true }
|
||||||
typed-path = { workspace = true }
|
typed-path = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
use std::{fmt::Display, str::FromStr};
|
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use strum::{EnumString, IntoStaticStr};
|
||||||
|
|
||||||
// --- by
|
// --- by
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Default, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq, Serialize,
|
||||||
|
)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum SortBy {
|
pub enum SortBy {
|
||||||
#[default]
|
#[default]
|
||||||
None,
|
None,
|
||||||
|
|
@ -17,51 +19,14 @@ pub enum SortBy {
|
||||||
Random,
|
Random,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for SortBy {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for SortBy {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
f.write_str(match self {
|
|
||||||
Self::None => "none",
|
|
||||||
Self::Mtime => "mtime",
|
|
||||||
Self::Btime => "btime",
|
|
||||||
Self::Extension => "extension",
|
|
||||||
Self::Alphabetical => "alphabetical",
|
|
||||||
Self::Natural => "natural",
|
|
||||||
Self::Size => "size",
|
|
||||||
Self::Random => "random",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// --- fallback
|
// --- fallback
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Default, Deserialize, EnumString, Eq, IntoStaticStr, PartialEq, Serialize,
|
||||||
|
)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum SortFallback {
|
pub enum SortFallback {
|
||||||
#[default]
|
#[default]
|
||||||
Alphabetical,
|
Alphabetical,
|
||||||
Natural,
|
Natural,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for SortFallback {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for SortFallback {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
f.write_str(match self {
|
|
||||||
Self::Alphabetical => "alphabetical",
|
|
||||||
Self::Natural => "natural",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -31,15 +31,16 @@ yazi-vfs = { path = "../yazi-vfs", version = "26.2.2" }
|
||||||
yazi-widgets = { path = "../yazi-widgets", version = "26.2.2" }
|
yazi-widgets = { path = "../yazi-widgets", version = "26.2.2" }
|
||||||
|
|
||||||
# External dependencies
|
# External dependencies
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
bitflags = { workspace = true }
|
bitflags = { workspace = true }
|
||||||
crossterm = { workspace = true }
|
crossterm = { workspace = true }
|
||||||
hashbrown = { workspace = true }
|
hashbrown = { workspace = true }
|
||||||
mlua = { workspace = true }
|
mlua = { workspace = true }
|
||||||
paste = { workspace = true }
|
paste = { workspace = true }
|
||||||
ratatui = { workspace = true }
|
ratatui = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
tokio = { workspace = true }
|
strum = { workspace = true }
|
||||||
|
tokio = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
crossterm = { workspace = true, features = [ "use-dev-tty", "libc" ] }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
use std::{borrow::Cow, str::FromStr};
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use strum::EnumString;
|
||||||
use yazi_shared::{SStr, event::ActionCow, strand::AsStrand};
|
use yazi_shared::{SStr, event::ActionCow, strand::AsStrand};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -30,22 +31,15 @@ impl IntoLua for CopyForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Separator
|
// --- Separator
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Deserialize)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, EnumString, Eq, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum CopySeparator {
|
pub enum CopySeparator {
|
||||||
#[default]
|
#[default]
|
||||||
Auto,
|
Auto,
|
||||||
Unix,
|
Unix,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for CopySeparator {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CopySeparator {
|
impl CopySeparator {
|
||||||
pub fn transform<T>(self, s: &T) -> Cow<'_, [u8]>
|
pub fn transform<T>(self, s: &T) -> Cow<'_, [u8]>
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use std::fmt::Display;
|
use strum::{Display, IntoStaticStr};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Display, Eq, IntoStaticStr, PartialEq)]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum SparkKind {
|
pub enum SparkKind {
|
||||||
// app:title
|
// app:title
|
||||||
IndAppTitle,
|
IndAppTitle,
|
||||||
|
|
@ -23,34 +24,3 @@ pub enum SparkKind {
|
||||||
// notify:push
|
// notify:push
|
||||||
RelayNotifyPush,
|
RelayNotifyPush,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AsRef<str> for SparkKind {
|
|
||||||
fn as_ref(&self) -> &str {
|
|
||||||
match self {
|
|
||||||
// app:title
|
|
||||||
Self::IndAppTitle => "ind-app-title",
|
|
||||||
|
|
||||||
// mgr:hidden
|
|
||||||
Self::KeyHidden => "key-hidden",
|
|
||||||
Self::IndHidden => "ind-hidden",
|
|
||||||
// mgr:sort
|
|
||||||
Self::KeySort => "key-sort",
|
|
||||||
Self::IndSort => "ind-sort",
|
|
||||||
// mgr:stash
|
|
||||||
Self::IndStash => "ind-stash",
|
|
||||||
Self::RelayStash => "relay-stash",
|
|
||||||
// mgr:quit
|
|
||||||
Self::KeyQuit => "key-quit",
|
|
||||||
|
|
||||||
// which:activate
|
|
||||||
Self::IndWhichActivate => "ind-which-activate",
|
|
||||||
|
|
||||||
// notify:push
|
|
||||||
Self::RelayNotifyPush => "relay-notify-push",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for SparkKind {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(self.as_ref()) }
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ hashbrown = { workspace = true }
|
||||||
mlua = { workspace = true }
|
mlua = { workspace = true }
|
||||||
parking_lot = { workspace = true }
|
parking_lot = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
|
strum = { workspace = true }
|
||||||
thiserror = { workspace = true }
|
thiserror = { workspace = true }
|
||||||
tokio = { workspace = true }
|
tokio = { workspace = true }
|
||||||
tokio-util = { workspace = true }
|
tokio-util = { workspace = true }
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
use std::{borrow::Cow, fmt, fmt::Debug, str::FromStr};
|
use std::{borrow::Cow, fmt, fmt::Debug};
|
||||||
|
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use dyn_clone::DynClone;
|
use dyn_clone::DynClone;
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use mlua::{Lua, Table};
|
use mlua::{Lua, Table};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use strum::EnumString;
|
||||||
use yazi_shared::{SStr, data::{Data, DataKey}, event::{Action, ActionCow}};
|
use yazi_shared::{SStr, data::{Data, DataKey}, event::{Action, ActionCow}};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
|
|
@ -57,8 +58,9 @@ impl PluginOpt {
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Mode
|
// --- Mode
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, EnumString, Eq, PartialEq)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum PluginMode {
|
pub enum PluginMode {
|
||||||
#[default]
|
#[default]
|
||||||
Auto,
|
Auto,
|
||||||
|
|
@ -66,14 +68,6 @@ pub enum PluginMode {
|
||||||
Async,
|
Async,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for PluginMode {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PluginMode {
|
impl PluginMode {
|
||||||
pub fn auto_then(self, sync: bool) -> Self {
|
pub fn auto_then(self, sync: bool) -> Self {
|
||||||
if self != Self::Auto {
|
if self != Self::Auto {
|
||||||
|
|
|
||||||
|
|
@ -268,11 +268,11 @@ impl<'de> Deserializer<'de> for &'de Data {
|
||||||
Err(Error::custom("identifier not supported"))
|
Err(Error::custom("identifier not supported"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_ignored_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
|
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where
|
where
|
||||||
V: de::Visitor<'de>,
|
V: de::Visitor<'de>,
|
||||||
{
|
{
|
||||||
Err(Error::custom("ignored any not supported"))
|
visitor.visit_unit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -273,11 +273,11 @@ impl<'de> Deserializer<'de> for Data {
|
||||||
Err(Error::custom("identifier not supported"))
|
Err(Error::custom("identifier not supported"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_ignored_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
|
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
where
|
where
|
||||||
V: de::Visitor<'de>,
|
V: de::Visitor<'de>,
|
||||||
{
|
{
|
||||||
Err(Error::custom("ignored any not supported"))
|
visitor.visit_unit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
use std::{fmt::Display, str::FromStr};
|
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use strum::{Display, EnumString, IntoStaticStr};
|
||||||
|
|
||||||
#[derive(Debug, Default, PartialEq, Eq, Hash, Clone, Copy, Deserialize)]
|
#[derive(
|
||||||
|
Clone, Copy, Debug, Default, Deserialize, Display, EnumString, Eq, Hash, IntoStaticStr, PartialEq,
|
||||||
|
)]
|
||||||
#[serde(rename_all = "kebab-case")]
|
#[serde(rename_all = "kebab-case")]
|
||||||
|
#[strum(serialize_all = "kebab-case")]
|
||||||
pub enum Layer {
|
pub enum Layer {
|
||||||
#[default]
|
#[default]
|
||||||
App,
|
App,
|
||||||
|
|
@ -18,29 +20,3 @@ pub enum Layer {
|
||||||
Which,
|
Which,
|
||||||
Notify,
|
Notify,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Layer {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
f.write_str(match self {
|
|
||||||
Self::App => "app",
|
|
||||||
Self::Mgr => "mgr",
|
|
||||||
Self::Tasks => "tasks",
|
|
||||||
Self::Spot => "spot",
|
|
||||||
Self::Pick => "pick",
|
|
||||||
Self::Input => "input",
|
|
||||||
Self::Confirm => "confirm",
|
|
||||||
Self::Help => "help",
|
|
||||||
Self::Cmp => "cmp",
|
|
||||||
Self::Which => "which",
|
|
||||||
Self::Notify => "notify",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FromStr for Layer {
|
|
||||||
type Err = serde::de::value::Error;
|
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
||||||
Self::deserialize(serde::de::value::StrDeserializer::new(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,9 @@ workspace = true
|
||||||
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
yazi-macro = { path = "../yazi-macro", version = "26.2.2" }
|
||||||
|
|
||||||
# External dependencies
|
# External dependencies
|
||||||
crossterm = { workspace = true }
|
crossterm = { workspace = true }
|
||||||
ratatui = { workspace = true }
|
ratatui = { workspace = true }
|
||||||
twox-hash = { workspace = true }
|
twox-hash = { workspace = true }
|
||||||
unicode-width = { workspace = true }
|
unicode-width = { workspace = true }
|
||||||
|
|
||||||
[dependencies.unicode-segmentation]
|
[dependencies.unicode-segmentation]
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
yazi_macro::mod_pub!(crossterm ratatui);
|
yazi_macro::mod_pub!(crossterm ratatui strum);
|
||||||
|
|
||||||
yazi_macro::mod_flat!(twox);
|
yazi_macro::mod_flat!(twox);
|
||||||
|
|
|
||||||
1
yazi-shim/src/strum/mod.rs
Normal file
1
yazi-shim/src/strum/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
yazi_macro::mod_flat!(traits);
|
||||||
10
yazi-shim/src/strum/traits.rs
Normal file
10
yazi-shim/src/strum/traits.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
pub trait IntoStr {
|
||||||
|
fn into_str(self) -> &'static str;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> IntoStr for T
|
||||||
|
where
|
||||||
|
T: Into<&'static str>,
|
||||||
|
{
|
||||||
|
fn into_str(self) -> &'static str { self.into() }
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue