From c28d2e8180b2fe60222414a6aaee76b923e694d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20misaki=20masa?= Date: Fri, 18 Jul 2025 14:31:16 +0800 Subject: [PATCH] refactor: eliminate the tab conceptual hierarchy (#2999) --- Cargo.lock | 3 + Cargo.toml | 2 +- yazi-actor/src/actor.rs | 2 +- yazi-actor/src/cmp/arrow.rs | 2 +- yazi-actor/src/cmp/close.rs | 2 +- yazi-actor/src/cmp/show.rs | 2 +- yazi-actor/src/cmp/trigger.rs | 2 +- yazi-actor/src/confirm/arrow.rs | 2 +- yazi-actor/src/confirm/close.rs | 2 +- yazi-actor/src/confirm/show.rs | 2 +- yazi-actor/src/help/arrow.rs | 2 +- yazi-actor/src/help/escape.rs | 2 +- yazi-actor/src/help/filter.rs | 2 +- yazi-actor/src/help/toggle.rs | 2 +- yazi-actor/src/input/close.rs | 2 +- yazi-actor/src/input/escape.rs | 2 +- yazi-actor/src/input/show.rs | 2 +- yazi-actor/src/mgr/arrow.rs | 2 +- yazi-actor/src/mgr/back.rs | 4 +- yazi-actor/src/mgr/bulk_rename.rs | 2 +- yazi-actor/src/mgr/cd.rs | 4 +- yazi-actor/src/mgr/close.rs | 2 +- yazi-actor/src/mgr/copy.rs | 4 +- yazi-actor/src/mgr/create.rs | 2 +- yazi-actor/src/mgr/enter.rs | 4 +- yazi-actor/src/mgr/escape.rs | 14 ++-- yazi-actor/src/mgr/filter.rs | 4 +- yazi-actor/src/mgr/filter_do.rs | 4 +- yazi-actor/src/mgr/find.rs | 4 +- yazi-actor/src/mgr/find_arrow.rs | 4 +- yazi-actor/src/mgr/find_do.rs | 4 +- yazi-actor/src/mgr/follow.rs | 2 +- yazi-actor/src/mgr/forward.rs | 4 +- yazi-actor/src/mgr/hardlink.rs | 2 +- yazi-actor/src/mgr/hidden.rs | 2 +- yazi-actor/src/mgr/hover.rs | 6 +- yazi-actor/src/mgr/leave.rs | 4 +- yazi-actor/src/mgr/linemode.rs | 2 +- yazi-actor/src/mgr/link.rs | 2 +- yazi-actor/src/mgr/open.rs | 4 +- yazi-actor/src/mgr/paste.rs | 2 +- yazi-actor/src/mgr/peek.rs | 2 +- yazi-actor/src/mgr/quit.rs | 2 +- yazi-actor/src/mgr/refresh.rs | 2 +- yazi-actor/src/mgr/remove.rs | 4 +- yazi-actor/src/mgr/rename.rs | 2 +- yazi-actor/src/mgr/reveal.rs | 4 +- yazi-actor/src/mgr/search.rs | 6 +- yazi-actor/src/mgr/seek.rs | 2 +- yazi-actor/src/mgr/shell.rs | 4 +- yazi-actor/src/mgr/sort.rs | 2 +- yazi-actor/src/mgr/spot.rs | 2 +- yazi-actor/src/mgr/suspend.rs | 2 +- yazi-actor/src/mgr/tab_close.rs | 2 +- yazi-actor/src/mgr/tab_create.rs | 4 +- yazi-actor/src/mgr/tab_swap.rs | 2 +- yazi-actor/src/mgr/tab_switch.rs | 2 +- yazi-actor/src/mgr/toggle.rs | 4 +- yazi-actor/src/mgr/toggle_all.rs | 4 +- yazi-actor/src/mgr/unyank.rs | 2 +- yazi-actor/src/mgr/update_files.rs | 2 +- yazi-actor/src/mgr/update_mimes.rs | 2 +- yazi-actor/src/mgr/update_paged.rs | 2 +- yazi-actor/src/mgr/update_peeked.rs | 4 +- yazi-actor/src/mgr/update_spotted.rs | 4 +- yazi-actor/src/mgr/update_tasks.rs | 2 +- yazi-actor/src/mgr/update_yanked.rs | 2 +- yazi-actor/src/mgr/visual_mode.rs | 4 +- yazi-actor/src/mgr/watch.rs | 2 +- yazi-actor/src/mgr/yank.rs | 2 +- yazi-actor/src/pick/arrow.rs | 2 +- yazi-actor/src/pick/close.rs | 2 +- yazi-actor/src/pick/show.rs | 2 +- yazi-actor/src/spot/arrow.rs | 2 +- yazi-actor/src/spot/close.rs | 2 +- yazi-actor/src/spot/copy.rs | 2 +- yazi-actor/src/spot/swipe.rs | 2 +- yazi-actor/src/tasks/arrow.rs | 2 +- yazi-actor/src/tasks/cancel.rs | 2 +- yazi-actor/src/tasks/close.rs | 2 +- yazi-actor/src/tasks/inspect.rs | 2 +- yazi-actor/src/tasks/open_with.rs | 2 +- yazi-actor/src/tasks/process_exec.rs | 2 +- yazi-actor/src/tasks/show.rs | 2 +- yazi-actor/src/which/callback.rs | 2 +- yazi-actor/src/which/show.rs | 2 +- yazi-binding/src/lib.rs | 2 +- yazi-binding/src/source.rs | 7 ++ yazi-core/src/spot/spot.rs | 2 +- yazi-core/src/tab/preview.rs | 2 +- yazi-dds/src/body/before_default.rs | 72 +++++++++++++++++++ yazi-dds/src/body/before_quit.rs | 35 ++++++++- yazi-dds/src/body/body.rs | 7 +- yazi-dds/src/body/mod.rs | 2 +- yazi-dds/src/lib.rs | 2 + yazi-dds/src/macros.rs | 8 +++ yazi-dds/src/payload.rs | 1 + yazi-fm/src/app/commands/accept_payload.rs | 35 ++++++++- yazi-fm/src/app/commands/bootstrap.rs | 2 +- yazi-fm/src/executor.rs | 11 ++- yazi-macro/src/actor.rs | 7 +- yazi-parser/src/lib.rs | 2 +- yazi-parser/src/{tab => mgr}/back.rs | 0 yazi-parser/src/{tab => mgr}/cd.rs | 0 yazi-parser/src/{tab => mgr}/copy.rs | 0 yazi-parser/src/{tab => mgr}/enter.rs | 0 yazi-parser/src/{tab => mgr}/escape.rs | 0 yazi-parser/src/{tab => mgr}/filter.rs | 0 yazi-parser/src/{tab => mgr}/find.rs | 0 yazi-parser/src/{tab => mgr}/find_arrow.rs | 0 yazi-parser/src/{tab => mgr}/find_do.rs | 0 yazi-parser/src/{tab => mgr}/forward.rs | 0 yazi-parser/src/{tab => mgr}/hover.rs | 0 yazi-parser/src/mgr/mod.rs | 18 +++++ yazi-parser/src/mgr/quit.rs | 2 +- yazi-parser/src/{tab => mgr}/reveal.rs | 2 +- yazi-parser/src/{tab => mgr}/shell.rs | 0 yazi-parser/src/{tab => mgr}/toggle.rs | 0 yazi-parser/src/{tab => mgr}/toggle_all.rs | 0 yazi-parser/src/{tab => mgr}/update_peeked.rs | 0 .../src/{tab => mgr}/update_spotted.rs | 0 yazi-parser/src/{tab => mgr}/visual_mode.rs | 0 yazi-parser/src/tab/hidden.rs | 1 - yazi-parser/src/tab/mod.rs | 23 ------ yazi-parser/src/tab/search.rs | 1 - yazi-parser/src/tab/sort.rs | 1 - yazi-plugin/src/utils/preview.rs | 2 +- yazi-plugin/src/utils/spot.rs | 2 +- yazi-proxy/src/mgr.rs | 2 +- yazi-shared/src/source.rs | 3 +- yazi-widgets/src/input/commands/forward.rs | 2 +- 131 files changed, 325 insertions(+), 166 deletions(-) create mode 100644 yazi-binding/src/source.rs create mode 100644 yazi-dds/src/body/before_default.rs create mode 100644 yazi-dds/src/macros.rs rename yazi-parser/src/{tab => mgr}/back.rs (100%) rename yazi-parser/src/{tab => mgr}/cd.rs (100%) rename yazi-parser/src/{tab => mgr}/copy.rs (100%) rename yazi-parser/src/{tab => mgr}/enter.rs (100%) rename yazi-parser/src/{tab => mgr}/escape.rs (100%) rename yazi-parser/src/{tab => mgr}/filter.rs (100%) rename yazi-parser/src/{tab => mgr}/find.rs (100%) rename yazi-parser/src/{tab => mgr}/find_arrow.rs (100%) rename yazi-parser/src/{tab => mgr}/find_do.rs (100%) rename yazi-parser/src/{tab => mgr}/forward.rs (100%) rename yazi-parser/src/{tab => mgr}/hover.rs (100%) rename yazi-parser/src/{tab => mgr}/reveal.rs (96%) rename yazi-parser/src/{tab => mgr}/shell.rs (100%) rename yazi-parser/src/{tab => mgr}/toggle.rs (100%) rename yazi-parser/src/{tab => mgr}/toggle_all.rs (100%) rename yazi-parser/src/{tab => mgr}/update_peeked.rs (100%) rename yazi-parser/src/{tab => mgr}/update_spotted.rs (100%) rename yazi-parser/src/{tab => mgr}/visual_mode.rs (100%) delete mode 100644 yazi-parser/src/tab/hidden.rs delete mode 100644 yazi-parser/src/tab/mod.rs delete mode 100644 yazi-parser/src/tab/search.rs delete mode 100644 yazi-parser/src/tab/sort.rs diff --git a/Cargo.lock b/Cargo.lock index 671c8632..25499046 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,6 +258,9 @@ name = "bitflags" version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" +dependencies = [ + "serde", +] [[package]] name = "bitstream-io" diff --git a/Cargo.toml b/Cargo.toml index 65f26de8..8914f0cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ lto = false ansi-to-tui = "7.0.0" anyhow = "1.0.98" base64 = "0.22.1" -bitflags = "2.9.1" +bitflags = { version = "2.9.1", features = [ "serde" ] } clap = { version = "4.5.41", features = [ "derive" ] } core-foundation-sys = "0.8.7" crossterm = { version = "0.29.0", features = [ "event-stream" ] } diff --git a/yazi-actor/src/actor.rs b/yazi-actor/src/actor.rs index 4e349981..280c2303 100644 --- a/yazi-actor/src/actor.rs +++ b/yazi-actor/src/actor.rs @@ -6,7 +6,7 @@ use crate::Ctx; pub trait Actor { type Options; - const NAME: &'static str; + const NAME: &str; fn act(cx: &mut Ctx, opt: Self::Options) -> Result; } diff --git a/yazi-actor/src/cmp/arrow.rs b/yazi-actor/src/cmp/arrow.rs index f4dca5c6..373719e0 100644 --- a/yazi-actor/src/cmp/arrow.rs +++ b/yazi-actor/src/cmp/arrow.rs @@ -11,7 +11,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { succ!(render!(cx.cmp.scroll(opt.step))); diff --git a/yazi-actor/src/cmp/close.rs b/yazi-actor/src/cmp/close.rs index aa40ab0e..6551f604 100644 --- a/yazi-actor/src/cmp/close.rs +++ b/yazi-actor/src/cmp/close.rs @@ -12,7 +12,7 @@ pub struct Close; impl Actor for Close { type Options = CloseOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let cmp = &mut cx.core.cmp; diff --git a/yazi-actor/src/cmp/show.rs b/yazi-actor/src/cmp/show.rs index 45b1197f..64a3343c 100644 --- a/yazi-actor/src/cmp/show.rs +++ b/yazi-actor/src/cmp/show.rs @@ -14,7 +14,7 @@ pub struct Show; impl Actor for Show { type Options = ShowOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let cmp = &mut cx.cmp; diff --git a/yazi-actor/src/cmp/trigger.rs b/yazi-actor/src/cmp/trigger.rs index b5086a13..80e511d3 100644 --- a/yazi-actor/src/cmp/trigger.rs +++ b/yazi-actor/src/cmp/trigger.rs @@ -15,7 +15,7 @@ pub struct Trigger; impl Actor for Trigger { type Options = TriggerOpt; - const NAME: &'static str = "trigger"; + const NAME: &str = "trigger"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let cmp = &mut cx.cmp; diff --git a/yazi-actor/src/confirm/arrow.rs b/yazi-actor/src/confirm/arrow.rs index fa38848d..74e23162 100644 --- a/yazi-actor/src/confirm/arrow.rs +++ b/yazi-actor/src/confirm/arrow.rs @@ -10,7 +10,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let confirm = &mut cx.core.confirm; diff --git a/yazi-actor/src/confirm/close.rs b/yazi-actor/src/confirm/close.rs index fcbb4e2b..90551b8b 100644 --- a/yazi-actor/src/confirm/close.rs +++ b/yazi-actor/src/confirm/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = CloseOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if let Some(cb) = cx.confirm.callback.take() { diff --git a/yazi-actor/src/confirm/show.rs b/yazi-actor/src/confirm/show.rs index 66e9c13e..b313d6c1 100644 --- a/yazi-actor/src/confirm/show.rs +++ b/yazi-actor/src/confirm/show.rs @@ -10,7 +10,7 @@ pub struct Show; impl Actor for Show { type Options = ShowOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(confirm:close, cx)?; diff --git a/yazi-actor/src/help/arrow.rs b/yazi-actor/src/help/arrow.rs index ab59d822..fc2412b0 100644 --- a/yazi-actor/src/help/arrow.rs +++ b/yazi-actor/src/help/arrow.rs @@ -11,7 +11,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { succ!(render!(cx.help.scroll(opt.step))); diff --git a/yazi-actor/src/help/escape.rs b/yazi-actor/src/help/escape.rs index e03c84a5..041b50f3 100644 --- a/yazi-actor/src/help/escape.rs +++ b/yazi-actor/src/help/escape.rs @@ -10,7 +10,7 @@ pub struct Escape; impl Actor for Escape { type Options = VoidOpt; - const NAME: &'static str = "escape"; + const NAME: &str = "escape"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { if cx.help.keyword().is_none() { diff --git a/yazi-actor/src/help/filter.rs b/yazi-actor/src/help/filter.rs index 120ddfa6..d20d2f72 100644 --- a/yazi-actor/src/help/filter.rs +++ b/yazi-actor/src/help/filter.rs @@ -10,7 +10,7 @@ pub struct Filter; impl Actor for Filter { type Options = VoidOpt; - const NAME: &'static str = "filter"; + const NAME: &str = "filter"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let help = &mut cx.help; diff --git a/yazi-actor/src/help/toggle.rs b/yazi-actor/src/help/toggle.rs index c67d9666..a2c90d52 100644 --- a/yazi-actor/src/help/toggle.rs +++ b/yazi-actor/src/help/toggle.rs @@ -10,7 +10,7 @@ pub struct Toggle; impl Actor for Toggle { type Options = ToggleOpt; - const NAME: &'static str = "toggle"; + const NAME: &str = "toggle"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let help = &mut cx.help; diff --git a/yazi-actor/src/input/close.rs b/yazi-actor/src/input/close.rs index c11ea87f..a63097ab 100644 --- a/yazi-actor/src/input/close.rs +++ b/yazi-actor/src/input/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = CloseOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let input = &mut cx.input; diff --git a/yazi-actor/src/input/escape.rs b/yazi-actor/src/input/escape.rs index ce62f47e..1d84d0d9 100644 --- a/yazi-actor/src/input/escape.rs +++ b/yazi-actor/src/input/escape.rs @@ -11,7 +11,7 @@ pub struct Escape; impl Actor for Escape { type Options = VoidOpt; - const NAME: &'static str = "escape"; + const NAME: &str = "escape"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { use yazi_widgets::input::InputMode as M; diff --git a/yazi-actor/src/input/show.rs b/yazi-actor/src/input/show.rs index 0bd61562..b18a37e0 100644 --- a/yazi-actor/src/input/show.rs +++ b/yazi-actor/src/input/show.rs @@ -14,7 +14,7 @@ pub struct Show; impl Actor for Show { type Options = ShowOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(input:close, cx)?; diff --git a/yazi-actor/src/mgr/arrow.rs b/yazi-actor/src/mgr/arrow.rs index 06fcd675..fd69f36d 100644 --- a/yazi-actor/src/mgr/arrow.rs +++ b/yazi-actor/src/mgr/arrow.rs @@ -10,7 +10,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/back.rs b/yazi-actor/src/mgr/back.rs index 8163d386..c6332deb 100644 --- a/yazi-actor/src/mgr/back.rs +++ b/yazi-actor/src/mgr/back.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{act, succ}; -use yazi_parser::{VoidOpt, tab::CdSource}; +use yazi_parser::{VoidOpt, mgr::CdSource}; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct Back; impl Actor for Back { type Options = VoidOpt; - const NAME: &'static str = "back"; + const NAME: &str = "back"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { if let Some(u) = cx.tab_mut().backstack.shift_backward().cloned() { diff --git a/yazi-actor/src/mgr/bulk_rename.rs b/yazi-actor/src/mgr/bulk_rename.rs index 6cf2d673..27adba4d 100644 --- a/yazi-actor/src/mgr/bulk_rename.rs +++ b/yazi-actor/src/mgr/bulk_rename.rs @@ -20,7 +20,7 @@ pub struct BulkRename; impl Actor for BulkRename { type Options = VoidOpt; - const NAME: &'static str = "bulk_rename"; + const NAME: &str = "bulk_rename"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let Some(opener) = YAZI.opener.block(YAZI.open.all("bulk-rename.txt", "text/plain")) else { diff --git a/yazi-actor/src/mgr/cd.rs b/yazi-actor/src/mgr/cd.rs index 52f9cda1..751c819a 100644 --- a/yazi-actor/src/mgr/cd.rs +++ b/yazi-actor/src/mgr/cd.rs @@ -7,7 +7,7 @@ use yazi_config::popup::InputCfg; use yazi_dds::Pubsub; use yazi_fs::{File, FilesOp, expand_path}; use yazi_macro::{act, err, render, succ}; -use yazi_parser::tab::CdOpt; +use yazi_parser::mgr::CdOpt; use yazi_proxy::{CmpProxy, InputProxy, MgrProxy}; use yazi_shared::{Debounce, errors::InputError, event::Data, url::Url}; @@ -18,7 +18,7 @@ pub struct Cd; impl Actor for Cd { type Options = CdOpt; - const NAME: &'static str = "cd"; + const NAME: &str = "cd"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; diff --git a/yazi-actor/src/mgr/close.rs b/yazi-actor/src/mgr/close.rs index a5fc4807..e2a6bd50 100644 --- a/yazi-actor/src/mgr/close.rs +++ b/yazi-actor/src/mgr/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = CloseOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if cx.tabs().len() > 1 { diff --git a/yazi-actor/src/mgr/copy.rs b/yazi-actor/src/mgr/copy.rs index cee378f3..74b7f93c 100644 --- a/yazi-actor/src/mgr/copy.rs +++ b/yazi-actor/src/mgr/copy.rs @@ -2,7 +2,7 @@ use std::{ffi::OsString, path::Path}; use anyhow::{Result, bail}; use yazi_macro::{act, succ}; -use yazi_parser::tab::CopyOpt; +use yazi_parser::mgr::CopyOpt; use yazi_shared::event::Data; use yazi_widgets::CLIPBOARD; @@ -13,7 +13,7 @@ pub struct Copy; impl Actor for Copy { type Options = CopyOpt; - const NAME: &'static str = "copy"; + const NAME: &str = "copy"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; diff --git a/yazi-actor/src/mgr/create.rs b/yazi-actor/src/mgr/create.rs index 59480ddb..2b423361 100644 --- a/yazi-actor/src/mgr/create.rs +++ b/yazi-actor/src/mgr/create.rs @@ -14,7 +14,7 @@ pub struct Create; impl Actor for Create { type Options = CreateOpt; - const NAME: &'static str = "create"; + const NAME: &str = "create"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let cwd = cx.cwd().to_owned(); diff --git a/yazi-actor/src/mgr/enter.rs b/yazi-actor/src/mgr/enter.rs index 81642f04..c6afb1e3 100644 --- a/yazi-actor/src/mgr/enter.rs +++ b/yazi-actor/src/mgr/enter.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{act, succ}; -use yazi_parser::{VoidOpt, tab::CdSource}; +use yazi_parser::{VoidOpt, mgr::CdSource}; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct Enter; impl Actor for Enter { type Options = VoidOpt; - const NAME: &'static str = "enter"; + const NAME: &str = "enter"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let Some(h) = cx.hovered().filter(|h| h.is_dir()) else { succ!() }; diff --git a/yazi-actor/src/mgr/escape.rs b/yazi-actor/src/mgr/escape.rs index 4f9761ad..59d8ee5c 100644 --- a/yazi-actor/src/mgr/escape.rs +++ b/yazi-actor/src/mgr/escape.rs @@ -1,6 +1,6 @@ use anyhow::{Result, bail}; use yazi_macro::{act, render, render_and, succ}; -use yazi_parser::{VoidOpt, tab::EscapeOpt}; +use yazi_parser::{VoidOpt, mgr::EscapeOpt}; use yazi_proxy::AppProxy; use yazi_shared::event::Data; @@ -11,7 +11,7 @@ pub struct Escape; impl Actor for Escape { type Options = EscapeOpt; - const NAME: &'static str = "escape"; + const NAME: &str = "escape"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if opt.is_empty() { @@ -48,7 +48,7 @@ pub struct EscapeFind; impl Actor for EscapeFind { type Options = VoidOpt; - const NAME: &'static str = "escape_find"; + const NAME: &str = "escape_find"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { succ!(render_and!(cx.tab_mut().finder.take().is_some())) @@ -61,7 +61,7 @@ pub struct EscapeVisual; impl Actor for EscapeVisual { type Options = VoidOpt; - const NAME: &'static str = "escape_visual"; + const NAME: &str = "escape_visual"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tab = cx.tab_mut(); @@ -93,7 +93,7 @@ pub struct EscapeFilter; impl Actor for EscapeFilter { type Options = VoidOpt; - const NAME: &'static str = "escape_filter"; + const NAME: &str = "escape_filter"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { if cx.current_mut().files.filter().is_none() { @@ -112,7 +112,7 @@ pub struct EscapeSelect; impl Actor for EscapeSelect { type Options = VoidOpt; - const NAME: &'static str = "escape_select"; + const NAME: &str = "escape_select"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tab = cx.tab_mut(); @@ -136,7 +136,7 @@ pub struct EscapeSearch; impl Actor for EscapeSearch { type Options = VoidOpt; - const NAME: &'static str = "escape_search"; + const NAME: &str = "escape_search"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let b = cx.cwd().is_search(); diff --git a/yazi-actor/src/mgr/filter.rs b/yazi-actor/src/mgr/filter.rs index fd112045..e09a5fda 100644 --- a/yazi-actor/src/mgr/filter.rs +++ b/yazi-actor/src/mgr/filter.rs @@ -5,7 +5,7 @@ use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use yazi_config::popup::InputCfg; use yazi_macro::succ; -use yazi_parser::tab::FilterOpt; +use yazi_parser::mgr::FilterOpt; use yazi_proxy::{InputProxy, MgrProxy}; use yazi_shared::{Debounce, errors::InputError, event::Data}; @@ -16,7 +16,7 @@ pub struct Filter; impl Actor for Filter { type Options = FilterOpt; - const NAME: &'static str = "filter"; + const NAME: &str = "filter"; fn act(_: &mut Ctx, opt: Self::Options) -> Result { let input = InputProxy::show(InputCfg::filter()); diff --git a/yazi-actor/src/mgr/filter_do.rs b/yazi-actor/src/mgr/filter_do.rs index 780ac91d..41c3b557 100644 --- a/yazi-actor/src/mgr/filter_do.rs +++ b/yazi-actor/src/mgr/filter_do.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_fs::Filter; use yazi_macro::{act, render, succ}; -use yazi_parser::tab::FilterOpt; +use yazi_parser::mgr::FilterOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -11,7 +11,7 @@ pub struct FilterDo; impl Actor for FilterDo { type Options = FilterOpt; - const NAME: &'static str = "filter_do"; + const NAME: &str = "filter_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let filter = if opt.query.is_empty() { None } else { Some(Filter::new(&opt.query, opt.case)?) }; diff --git a/yazi-actor/src/mgr/find.rs b/yazi-actor/src/mgr/find.rs index 735a215c..bd663090 100644 --- a/yazi-actor/src/mgr/find.rs +++ b/yazi-actor/src/mgr/find.rs @@ -5,7 +5,7 @@ use tokio::pin; use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream}; use yazi_config::popup::InputCfg; use yazi_macro::succ; -use yazi_parser::tab::{FindDoOpt, FindOpt}; +use yazi_parser::mgr::{FindDoOpt, FindOpt}; use yazi_proxy::{InputProxy, MgrProxy}; use yazi_shared::{Debounce, errors::InputError, event::Data}; @@ -16,7 +16,7 @@ pub struct Find; impl Actor for Find { type Options = FindOpt; - const NAME: &'static str = "find"; + const NAME: &str = "find"; fn act(_: &mut Ctx, opt: Self::Options) -> Result { let input = InputProxy::show(InputCfg::find(opt.prev)); diff --git a/yazi-actor/src/mgr/find_arrow.rs b/yazi-actor/src/mgr/find_arrow.rs index 67522f55..6bdbd0b8 100644 --- a/yazi-actor/src/mgr/find_arrow.rs +++ b/yazi-actor/src/mgr/find_arrow.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{act, render, succ}; -use yazi_parser::tab::FindArrowOpt; +use yazi_parser::mgr::FindArrowOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct FindArrow; impl Actor for FindArrow { type Options = FindArrowOpt; - const NAME: &'static str = "find_arrow"; + const NAME: &str = "find_arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/find_do.rs b/yazi-actor/src/mgr/find_do.rs index c50e9d48..c4d75d0b 100644 --- a/yazi-actor/src/mgr/find_do.rs +++ b/yazi-actor/src/mgr/find_do.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_core::tab::Finder; use yazi_macro::{act, render, succ}; -use yazi_parser::tab::FindDoOpt; +use yazi_parser::mgr::FindDoOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -11,7 +11,7 @@ pub struct FindDo; impl Actor for FindDo { type Options = FindDoOpt; - const NAME: &'static str = "find_do"; + const NAME: &str = "find_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if opt.query.is_empty() { diff --git a/yazi-actor/src/mgr/follow.rs b/yazi-actor/src/mgr/follow.rs index 7ac6963e..02914f78 100644 --- a/yazi-actor/src/mgr/follow.rs +++ b/yazi-actor/src/mgr/follow.rs @@ -11,7 +11,7 @@ pub struct Follow; impl Actor for Follow { type Options = VoidOpt; - const NAME: &'static str = "follow"; + const NAME: &str = "follow"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let Some(file) = cx.hovered() else { succ!() }; diff --git a/yazi-actor/src/mgr/forward.rs b/yazi-actor/src/mgr/forward.rs index 14f2a1ea..de572e74 100644 --- a/yazi-actor/src/mgr/forward.rs +++ b/yazi-actor/src/mgr/forward.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{act, succ}; -use yazi_parser::{VoidOpt, tab::CdSource}; +use yazi_parser::{VoidOpt, mgr::CdSource}; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct Forward; impl Actor for Forward { type Options = VoidOpt; - const NAME: &'static str = "forward"; + const NAME: &str = "forward"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { match cx.tab_mut().backstack.shift_forward().cloned() { diff --git a/yazi-actor/src/mgr/hardlink.rs b/yazi-actor/src/mgr/hardlink.rs index 751f4ea1..1c51ec5c 100644 --- a/yazi-actor/src/mgr/hardlink.rs +++ b/yazi-actor/src/mgr/hardlink.rs @@ -10,7 +10,7 @@ pub struct Hardlink; impl Actor for Hardlink { type Options = HardlinkOpt; - const NAME: &'static str = "hardlink"; + const NAME: &str = "hardlink"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let mgr = &mut cx.core.mgr; diff --git a/yazi-actor/src/mgr/hidden.rs b/yazi-actor/src/mgr/hidden.rs index 1755c4ee..0dc85ed7 100644 --- a/yazi-actor/src/mgr/hidden.rs +++ b/yazi-actor/src/mgr/hidden.rs @@ -10,7 +10,7 @@ pub struct Hidden; impl Actor for Hidden { type Options = HiddenOpt; - const NAME: &'static str = "hidden"; + const NAME: &str = "hidden"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/hover.rs b/yazi-actor/src/mgr/hover.rs index c49b8a0e..9b4b1489 100644 --- a/yazi-actor/src/mgr/hover.rs +++ b/yazi-actor/src/mgr/hover.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_dds::Pubsub; use yazi_macro::{act, err, render, succ}; -use yazi_parser::tab::{HoverDoOpt, HoverOpt}; +use yazi_parser::mgr::{HoverDoOpt, HoverOpt}; use yazi_shared::{event::Data, url::Urn}; use crate::{Actor, Ctx}; @@ -11,7 +11,7 @@ pub struct Hover; impl Actor for Hover { type Options = HoverOpt; - const NAME: &'static str = "hover"; + const NAME: &str = "hover"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if let Some(u) = opt.url { @@ -33,7 +33,7 @@ pub struct HoverDo; impl Actor for HoverDo { type Options = HoverDoOpt; - const NAME: &'static str = "hover_do"; + const NAME: &str = "hover_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { // Hover on the file diff --git a/yazi-actor/src/mgr/leave.rs b/yazi-actor/src/mgr/leave.rs index dabb7bbd..0d005582 100644 --- a/yazi-actor/src/mgr/leave.rs +++ b/yazi-actor/src/mgr/leave.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{act, succ}; -use yazi_parser::{VoidOpt, tab::CdSource}; +use yazi_parser::{VoidOpt, mgr::CdSource}; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct Leave; impl Actor for Leave { type Options = VoidOpt; - const NAME: &'static str = "leave"; + const NAME: &str = "leave"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let url = cx diff --git a/yazi-actor/src/mgr/linemode.rs b/yazi-actor/src/mgr/linemode.rs index 33843790..c5a23b52 100644 --- a/yazi-actor/src/mgr/linemode.rs +++ b/yazi-actor/src/mgr/linemode.rs @@ -10,7 +10,7 @@ pub struct Linemode; impl Actor for Linemode { type Options = LinemodeOpt; - const NAME: &'static str = "linemode"; + const NAME: &str = "linemode"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/link.rs b/yazi-actor/src/mgr/link.rs index 4bd770da..cc86dce2 100644 --- a/yazi-actor/src/mgr/link.rs +++ b/yazi-actor/src/mgr/link.rs @@ -10,7 +10,7 @@ pub struct Link; impl Actor for Link { type Options = LinkOpt; - const NAME: &'static str = "link"; + const NAME: &str = "link"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let mgr = &mut cx.core.mgr; diff --git a/yazi-actor/src/mgr/open.rs b/yazi-actor/src/mgr/open.rs index 62f72de5..00a6c570 100644 --- a/yazi-actor/src/mgr/open.rs +++ b/yazi-actor/src/mgr/open.rs @@ -18,7 +18,7 @@ pub struct Open; impl Actor for Open { type Options = OpenOpt; - const NAME: &'static str = "open"; + const NAME: &str = "open"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; @@ -78,7 +78,7 @@ pub struct OpenDo; impl Actor for OpenDo { type Options = OpenDoOpt; - const NAME: &'static str = "open_do"; + const NAME: &str = "open_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let mut targets = opt.targets; diff --git a/yazi-actor/src/mgr/paste.rs b/yazi-actor/src/mgr/paste.rs index 880ee6d5..b4f482c6 100644 --- a/yazi-actor/src/mgr/paste.rs +++ b/yazi-actor/src/mgr/paste.rs @@ -10,7 +10,7 @@ pub struct Paste; impl Actor for Paste { type Options = PasteOpt; - const NAME: &'static str = "paste"; + const NAME: &str = "paste"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let mgr = &mut cx.core.mgr; diff --git a/yazi-actor/src/mgr/peek.rs b/yazi-actor/src/mgr/peek.rs index 4bc78e4f..f9f2f83a 100644 --- a/yazi-actor/src/mgr/peek.rs +++ b/yazi-actor/src/mgr/peek.rs @@ -11,7 +11,7 @@ pub struct Peek; impl Actor for Peek { type Options = PeekOpt; - const NAME: &'static str = "peek"; + const NAME: &str = "peek"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let Some(hovered) = cx.hovered().cloned() else { diff --git a/yazi-actor/src/mgr/quit.rs b/yazi-actor/src/mgr/quit.rs index 41da9e09..528fbc33 100644 --- a/yazi-actor/src/mgr/quit.rs +++ b/yazi-actor/src/mgr/quit.rs @@ -16,7 +16,7 @@ pub struct Quit; impl Actor for Quit { type Options = QuitOpt; - const NAME: &'static str = "quit"; + const NAME: &str = "quit"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let event = opt.into(); diff --git a/yazi-actor/src/mgr/refresh.rs b/yazi-actor/src/mgr/refresh.rs index e48edd02..cb8ec856 100644 --- a/yazi-actor/src/mgr/refresh.rs +++ b/yazi-actor/src/mgr/refresh.rs @@ -14,7 +14,7 @@ pub struct Refresh; impl Actor for Refresh { type Options = VoidOpt; - const NAME: &'static str = "refresh"; + const NAME: &str = "refresh"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { if let (_, Some(s)) = (CWD.set(cx.cwd()), YAZI.mgr.title()) { diff --git a/yazi-actor/src/mgr/remove.rs b/yazi-actor/src/mgr/remove.rs index 2dca462f..23fb1d37 100644 --- a/yazi-actor/src/mgr/remove.rs +++ b/yazi-actor/src/mgr/remove.rs @@ -12,7 +12,7 @@ pub struct Remove; impl Actor for Remove { type Options = RemoveOpt; - const NAME: &'static str = "remove"; + const NAME: &str = "remove"; fn act(cx: &mut Ctx, mut opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; @@ -50,7 +50,7 @@ pub struct RemoveDo; impl Actor for RemoveDo { type Options = RemoveOpt; - const NAME: &'static str = "remove_do"; + const NAME: &str = "remove_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let mgr = &mut cx.mgr; diff --git a/yazi-actor/src/mgr/rename.rs b/yazi-actor/src/mgr/rename.rs index 5bc5d283..74b6e3ef 100644 --- a/yazi-actor/src/mgr/rename.rs +++ b/yazi-actor/src/mgr/rename.rs @@ -15,7 +15,7 @@ pub struct Rename; impl Actor for Rename { type Options = RenameOpt; - const NAME: &'static str = "rename"; + const NAME: &str = "rename"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; diff --git a/yazi-actor/src/mgr/reveal.rs b/yazi-actor/src/mgr/reveal.rs index 247b6497..6db7b019 100644 --- a/yazi-actor/src/mgr/reveal.rs +++ b/yazi-actor/src/mgr/reveal.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_fs::{File, FilesOp}; use yazi_macro::{act, succ}; -use yazi_parser::tab::RevealOpt; +use yazi_parser::mgr::RevealOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -11,7 +11,7 @@ pub struct Reveal; impl Actor for Reveal { type Options = RevealOpt; - const NAME: &'static str = "reveal"; + const NAME: &str = "reveal"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let Some((parent, child)) = opt.target.pair() else { succ!() }; diff --git a/yazi-actor/src/mgr/search.rs b/yazi-actor/src/mgr/search.rs index 0324541c..8399168b 100644 --- a/yazi-actor/src/mgr/search.rs +++ b/yazi-actor/src/mgr/search.rs @@ -18,7 +18,7 @@ pub struct Search; impl Actor for Search { type Options = SearchOpt; - const NAME: &'static str = "search"; + const NAME: &str = "search"; fn act(cx: &mut Ctx, mut opt: Self::Options) -> Result { if let Some(handle) = cx.tab_mut().search.take() { @@ -44,7 +44,7 @@ pub struct SearchDo; impl Actor for SearchDo { type Options = SearchOpt; - const NAME: &'static str = "search_do"; + const NAME: &str = "search_do"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); @@ -99,7 +99,7 @@ pub struct SearchStop; impl Actor for SearchStop { type Options = (); - const NAME: &'static str = "search_stop"; + const NAME: &str = "search_stop"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/seek.rs b/yazi-actor/src/mgr/seek.rs index 1195136d..25fdbc78 100644 --- a/yazi-actor/src/mgr/seek.rs +++ b/yazi-actor/src/mgr/seek.rs @@ -12,7 +12,7 @@ pub struct Seek; impl Actor for Seek { type Options = SeekOpt; - const NAME: &'static str = "seek"; + const NAME: &str = "seek"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let Some(hovered) = cx.hovered() else { diff --git a/yazi-actor/src/mgr/shell.rs b/yazi-actor/src/mgr/shell.rs index 2bae44da..69f922e9 100644 --- a/yazi-actor/src/mgr/shell.rs +++ b/yazi-actor/src/mgr/shell.rs @@ -3,7 +3,7 @@ use std::borrow::Cow; use anyhow::Result; use yazi_config::{opener::OpenerRule, popup::InputCfg}; use yazi_macro::{act, succ}; -use yazi_parser::tab::ShellOpt; +use yazi_parser::mgr::ShellOpt; use yazi_proxy::{InputProxy, TasksProxy}; use yazi_shared::event::Data; @@ -14,7 +14,7 @@ pub struct Shell; impl Actor for Shell { type Options = ShellOpt; - const NAME: &'static str = "shell"; + const NAME: &str = "shell"; fn act(cx: &mut Ctx, mut opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; diff --git a/yazi-actor/src/mgr/sort.rs b/yazi-actor/src/mgr/sort.rs index 4eb04253..dc8b4db7 100644 --- a/yazi-actor/src/mgr/sort.rs +++ b/yazi-actor/src/mgr/sort.rs @@ -12,7 +12,7 @@ pub struct Sort; impl Actor for Sort { type Options = CmdCow; - const NAME: &'static str = "sort"; + const NAME: &str = "sort"; fn act(cx: &mut Ctx, c: Self::Options) -> Result { let mut new = cx.tab().pref.clone(); diff --git a/yazi-actor/src/mgr/spot.rs b/yazi-actor/src/mgr/spot.rs index 70d8aa9f..7fbedbc8 100644 --- a/yazi-actor/src/mgr/spot.rs +++ b/yazi-actor/src/mgr/spot.rs @@ -10,7 +10,7 @@ pub struct Spot; impl Actor for Spot { type Options = SpotOpt; - const NAME: &'static str = "spot"; + const NAME: &str = "spot"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let Some(hovered) = cx.hovered().cloned() else { succ!() }; diff --git a/yazi-actor/src/mgr/suspend.rs b/yazi-actor/src/mgr/suspend.rs index 35e72250..c8b881f3 100644 --- a/yazi-actor/src/mgr/suspend.rs +++ b/yazi-actor/src/mgr/suspend.rs @@ -10,7 +10,7 @@ pub struct Suspend; impl Actor for Suspend { type Options = VoidOpt; - const NAME: &'static str = "suspend"; + const NAME: &str = "suspend"; fn act(_: &mut Ctx, _: Self::Options) -> Result { #[cfg(unix)] diff --git a/yazi-actor/src/mgr/tab_close.rs b/yazi-actor/src/mgr/tab_close.rs index eee20fd0..4c1be15d 100644 --- a/yazi-actor/src/mgr/tab_close.rs +++ b/yazi-actor/src/mgr/tab_close.rs @@ -10,7 +10,7 @@ pub struct TabClose; impl Actor for TabClose { type Options = TabCloseOpt; - const NAME: &'static str = "tab_close"; + const NAME: &str = "tab_close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let len = cx.tabs().len(); diff --git a/yazi-actor/src/mgr/tab_create.rs b/yazi-actor/src/mgr/tab_create.rs index 8a1457e7..60167988 100644 --- a/yazi-actor/src/mgr/tab_create.rs +++ b/yazi-actor/src/mgr/tab_create.rs @@ -1,7 +1,7 @@ use anyhow::Result; use yazi_core::tab::Tab; use yazi_macro::{act, render, succ}; -use yazi_parser::{mgr::TabCreateOpt, tab::CdSource}; +use yazi_parser::mgr::{CdSource, TabCreateOpt}; use yazi_proxy::AppProxy; use yazi_shared::event::Data; @@ -14,7 +14,7 @@ pub struct TabCreate; impl Actor for TabCreate { type Options = TabCreateOpt; - const NAME: &'static str = "tab_create"; + const NAME: &str = "tab_create"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if cx.tabs().len() >= MAX_TABS { diff --git a/yazi-actor/src/mgr/tab_swap.rs b/yazi-actor/src/mgr/tab_swap.rs index 664102c7..5f26ec0d 100644 --- a/yazi-actor/src/mgr/tab_swap.rs +++ b/yazi-actor/src/mgr/tab_swap.rs @@ -10,7 +10,7 @@ pub struct TabSwap; impl Actor for TabSwap { type Options = ArrowOpt; - const NAME: &'static str = "tab_swap"; + const NAME: &str = "tab_swap"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tabs = cx.tabs_mut(); diff --git a/yazi-actor/src/mgr/tab_switch.rs b/yazi-actor/src/mgr/tab_switch.rs index cae33984..96602496 100644 --- a/yazi-actor/src/mgr/tab_switch.rs +++ b/yazi-actor/src/mgr/tab_switch.rs @@ -10,7 +10,7 @@ pub struct TabSwitch; impl Actor for TabSwitch { type Options = TabSwitchOpt; - const NAME: &'static str = "tab_switch"; + const NAME: &str = "tab_switch"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tabs = cx.tabs_mut(); diff --git a/yazi-actor/src/mgr/toggle.rs b/yazi-actor/src/mgr/toggle.rs index ee66fa8c..c0c8dce0 100644 --- a/yazi-actor/src/mgr/toggle.rs +++ b/yazi-actor/src/mgr/toggle.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{render_and, succ}; -use yazi_parser::tab::ToggleOpt; +use yazi_parser::mgr::ToggleOpt; use yazi_proxy::AppProxy; use yazi_shared::event::Data; @@ -11,7 +11,7 @@ pub struct Toggle; impl Actor for Toggle { type Options = ToggleOpt; - const NAME: &'static str = "toggle"; + const NAME: &str = "toggle"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/toggle_all.rs b/yazi-actor/src/mgr/toggle_all.rs index 20d42192..f79252c5 100644 --- a/yazi-actor/src/mgr/toggle_all.rs +++ b/yazi-actor/src/mgr/toggle_all.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{render, succ}; -use yazi_parser::tab::ToggleAllOpt; +use yazi_parser::mgr::ToggleAllOpt; use yazi_proxy::AppProxy; use yazi_shared::event::Data; @@ -11,7 +11,7 @@ pub struct ToggleAll; impl Actor for ToggleAll { type Options = ToggleAllOpt; - const NAME: &'static str = "toggle_all"; + const NAME: &str = "toggle_all"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { use yazi_shared::Either::*; diff --git a/yazi-actor/src/mgr/unyank.rs b/yazi-actor/src/mgr/unyank.rs index 1b6b47e9..4a896798 100644 --- a/yazi-actor/src/mgr/unyank.rs +++ b/yazi-actor/src/mgr/unyank.rs @@ -10,7 +10,7 @@ pub struct Unyank; impl Actor for Unyank { type Options = VoidOpt; - const NAME: &'static str = "unyank"; + const NAME: &str = "unyank"; fn act(cx: &mut crate::Ctx, _: Self::Options) -> Result { let repeek = cx.hovered().is_some_and(|f| f.is_dir() && cx.mgr.yanked.contains_in(&f.url)); diff --git a/yazi-actor/src/mgr/update_files.rs b/yazi-actor/src/mgr/update_files.rs index c85b08bd..c3e66c79 100644 --- a/yazi-actor/src/mgr/update_files.rs +++ b/yazi-actor/src/mgr/update_files.rs @@ -12,7 +12,7 @@ pub struct UpdateFiles; impl Actor for UpdateFiles { type Options = UpdateFilesOpt; - const NAME: &'static str = "update_files"; + const NAME: &str = "update_files"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let revision = cx.current().files.revision; diff --git a/yazi-actor/src/mgr/update_mimes.rs b/yazi-actor/src/mgr/update_mimes.rs index c000fe78..73d885bb 100644 --- a/yazi-actor/src/mgr/update_mimes.rs +++ b/yazi-actor/src/mgr/update_mimes.rs @@ -13,7 +13,7 @@ pub struct UpdateMimes; impl Actor for UpdateMimes { type Options = UpdateMimesOpt; - const NAME: &'static str = "update_mimes"; + const NAME: &str = "update_mimes"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let linked = LINKED.read(); diff --git a/yazi-actor/src/mgr/update_paged.rs b/yazi-actor/src/mgr/update_paged.rs index 421cd0aa..3b0fdbb1 100644 --- a/yazi-actor/src/mgr/update_paged.rs +++ b/yazi-actor/src/mgr/update_paged.rs @@ -10,7 +10,7 @@ pub struct UpdatePaged; impl Actor for UpdatePaged { type Options = UpdatePagedOpt; - const NAME: &'static str = "update_paged"; + const NAME: &str = "update_paged"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if opt.only_if.is_some_and(|u| u != *cx.cwd()) { diff --git a/yazi-actor/src/mgr/update_peeked.rs b/yazi-actor/src/mgr/update_peeked.rs index 10d7a6d7..6d3a5867 100644 --- a/yazi-actor/src/mgr/update_peeked.rs +++ b/yazi-actor/src/mgr/update_peeked.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{render, succ}; -use yazi_parser::tab::UpdatePeekedOpt; +use yazi_parser::mgr::UpdatePeekedOpt; use yazi_shared::event::Data; use crate::Actor; @@ -10,7 +10,7 @@ pub struct UpdatePeeked; impl Actor for UpdatePeeked { type Options = UpdatePeekedOpt; - const NAME: &'static str = "update_peeked"; + const NAME: &str = "update_peeked"; fn act(cx: &mut crate::Ctx, opt: Self::Options) -> Result { let Some(hovered) = cx.hovered().map(|h| &h.url) else { diff --git a/yazi-actor/src/mgr/update_spotted.rs b/yazi-actor/src/mgr/update_spotted.rs index 87589658..ad393ab5 100644 --- a/yazi-actor/src/mgr/update_spotted.rs +++ b/yazi-actor/src/mgr/update_spotted.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::{render, succ}; -use yazi_parser::tab::UpdateSpottedOpt; +use yazi_parser::mgr::UpdateSpottedOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -10,7 +10,7 @@ pub struct UpdateSpotted; impl Actor for UpdateSpotted { type Options = UpdateSpottedOpt; - const NAME: &'static str = "update_spotted"; + const NAME: &str = "update_spotted"; fn act(cx: &mut Ctx, mut opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/update_tasks.rs b/yazi-actor/src/mgr/update_tasks.rs index 79a7b551..6ea016d5 100644 --- a/yazi-actor/src/mgr/update_tasks.rs +++ b/yazi-actor/src/mgr/update_tasks.rs @@ -10,7 +10,7 @@ pub struct UpdateTasks; impl Actor for UpdateTasks { type Options = UpdateTasksOpt; - const NAME: &'static str = "update_tasks"; + const NAME: &str = "update_tasks"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { cx.mgr.watcher.push_files(opt.urls); diff --git a/yazi-actor/src/mgr/update_yanked.rs b/yazi-actor/src/mgr/update_yanked.rs index d3ad773d..8f45e326 100644 --- a/yazi-actor/src/mgr/update_yanked.rs +++ b/yazi-actor/src/mgr/update_yanked.rs @@ -11,7 +11,7 @@ pub struct UpdateYanked; impl Actor for UpdateYanked { type Options = UpdateYankedOpt<'static>; - const NAME: &'static str = "update_yanked"; + const NAME: &str = "update_yanked"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if opt.urls.is_empty() && cx.mgr.yanked.is_empty() { diff --git a/yazi-actor/src/mgr/visual_mode.rs b/yazi-actor/src/mgr/visual_mode.rs index e2879013..c71c8f62 100644 --- a/yazi-actor/src/mgr/visual_mode.rs +++ b/yazi-actor/src/mgr/visual_mode.rs @@ -3,7 +3,7 @@ use std::collections::BTreeSet; use anyhow::Result; use yazi_core::tab::Mode; use yazi_macro::{render, succ}; -use yazi_parser::tab::VisualModeOpt; +use yazi_parser::mgr::VisualModeOpt; use yazi_shared::event::Data; use crate::{Actor, Ctx}; @@ -13,7 +13,7 @@ pub struct VisualMode; impl Actor for VisualMode { type Options = VisualModeOpt; - const NAME: &'static str = "visual_mode"; + const NAME: &str = "visual_mode"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tab = cx.tab_mut(); diff --git a/yazi-actor/src/mgr/watch.rs b/yazi-actor/src/mgr/watch.rs index bf9c67d4..a25591a6 100644 --- a/yazi-actor/src/mgr/watch.rs +++ b/yazi-actor/src/mgr/watch.rs @@ -12,7 +12,7 @@ pub struct Watch; impl Actor for Watch { type Options = VoidOpt; - const NAME: &'static str = "watch"; + const NAME: &str = "watch"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let it = iter::once(cx.core.mgr.tabs.active().cwd()) diff --git a/yazi-actor/src/mgr/yank.rs b/yazi-actor/src/mgr/yank.rs index 256e5907..2a96ec7f 100644 --- a/yazi-actor/src/mgr/yank.rs +++ b/yazi-actor/src/mgr/yank.rs @@ -11,7 +11,7 @@ pub struct Yank; impl Actor for Yank { type Options = YankOpt; - const NAME: &'static str = "yank"; + const NAME: &str = "yank"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:escape_visual, cx)?; diff --git a/yazi-actor/src/pick/arrow.rs b/yazi-actor/src/pick/arrow.rs index 8d807d7a..af3934a9 100644 --- a/yazi-actor/src/pick/arrow.rs +++ b/yazi-actor/src/pick/arrow.rs @@ -11,7 +11,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { succ!(render!(cx.pick.scroll(opt.step))); diff --git a/yazi-actor/src/pick/close.rs b/yazi-actor/src/pick/close.rs index 3c0e69c0..5028d66e 100644 --- a/yazi-actor/src/pick/close.rs +++ b/yazi-actor/src/pick/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = CloseOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let pick = &mut cx.pick; diff --git a/yazi-actor/src/pick/show.rs b/yazi-actor/src/pick/show.rs index 31a90846..ab653e81 100644 --- a/yazi-actor/src/pick/show.rs +++ b/yazi-actor/src/pick/show.rs @@ -10,7 +10,7 @@ pub struct Show; impl Actor for Show { type Options = ShowOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(pick:close, cx)?; diff --git a/yazi-actor/src/spot/arrow.rs b/yazi-actor/src/spot/arrow.rs index 4aaed7bf..2384a96e 100644 --- a/yazi-actor/src/spot/arrow.rs +++ b/yazi-actor/src/spot/arrow.rs @@ -10,7 +10,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let spot = &mut cx.tab_mut().spot; diff --git a/yazi-actor/src/spot/close.rs b/yazi-actor/src/spot/close.rs index e9a094de..a14a18d4 100644 --- a/yazi-actor/src/spot/close.rs +++ b/yazi-actor/src/spot/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = VoidOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { succ!(cx.tab_mut().spot.reset()); diff --git a/yazi-actor/src/spot/copy.rs b/yazi-actor/src/spot/copy.rs index d5ed965e..0cbf26a2 100644 --- a/yazi-actor/src/spot/copy.rs +++ b/yazi-actor/src/spot/copy.rs @@ -11,7 +11,7 @@ pub struct Copy; impl Actor for Copy { type Options = CopyOpt; - const NAME: &'static str = "copy"; + const NAME: &str = "copy"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let spot = &cx.tab().spot; diff --git a/yazi-actor/src/spot/swipe.rs b/yazi-actor/src/spot/swipe.rs index 754d7d3a..d2801424 100644 --- a/yazi-actor/src/spot/swipe.rs +++ b/yazi-actor/src/spot/swipe.rs @@ -10,7 +10,7 @@ pub struct Swipe; impl Actor for Swipe { type Options = ArrowOpt; - const NAME: &'static str = "swipe"; + const NAME: &str = "swipe"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { act!(mgr:arrow, cx, opt)?; diff --git a/yazi-actor/src/tasks/arrow.rs b/yazi-actor/src/tasks/arrow.rs index 922ef794..0f44dce2 100644 --- a/yazi-actor/src/tasks/arrow.rs +++ b/yazi-actor/src/tasks/arrow.rs @@ -11,7 +11,7 @@ pub struct Arrow; impl Actor for Arrow { type Options = ArrowOpt; - const NAME: &'static str = "arrow"; + const NAME: &str = "arrow"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { let tasks = &mut cx.tasks; diff --git a/yazi-actor/src/tasks/cancel.rs b/yazi-actor/src/tasks/cancel.rs index 24a62fe7..b52a2d12 100644 --- a/yazi-actor/src/tasks/cancel.rs +++ b/yazi-actor/src/tasks/cancel.rs @@ -10,7 +10,7 @@ pub struct Cancel; impl Actor for Cancel { type Options = VoidOpt; - const NAME: &'static str = "cancel"; + const NAME: &str = "cancel"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tasks = &mut cx.tasks; diff --git a/yazi-actor/src/tasks/close.rs b/yazi-actor/src/tasks/close.rs index 688c2e3b..34862c37 100644 --- a/yazi-actor/src/tasks/close.rs +++ b/yazi-actor/src/tasks/close.rs @@ -10,7 +10,7 @@ pub struct Close; impl Actor for Close { type Options = VoidOpt; - const NAME: &'static str = "close"; + const NAME: &str = "close"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tasks = &mut cx.tasks; diff --git a/yazi-actor/src/tasks/inspect.rs b/yazi-actor/src/tasks/inspect.rs index 94c087ec..154d2ca5 100644 --- a/yazi-actor/src/tasks/inspect.rs +++ b/yazi-actor/src/tasks/inspect.rs @@ -17,7 +17,7 @@ pub struct Inspect; impl Actor for Inspect { type Options = VoidOpt; - const NAME: &'static str = "inspect"; + const NAME: &str = "inspect"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let ongoing = cx.tasks.ongoing().clone(); diff --git a/yazi-actor/src/tasks/open_with.rs b/yazi-actor/src/tasks/open_with.rs index 9540f2c1..08384c43 100644 --- a/yazi-actor/src/tasks/open_with.rs +++ b/yazi-actor/src/tasks/open_with.rs @@ -10,7 +10,7 @@ pub struct OpenWith; impl Actor for OpenWith { type Options = OpenWithOpt; - const NAME: &'static str = "open_with"; + const NAME: &str = "open_with"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { succ!(cx.tasks.process_from_opener( diff --git a/yazi-actor/src/tasks/process_exec.rs b/yazi-actor/src/tasks/process_exec.rs index d1339d09..bdb3586b 100644 --- a/yazi-actor/src/tasks/process_exec.rs +++ b/yazi-actor/src/tasks/process_exec.rs @@ -10,7 +10,7 @@ pub struct ProcessExec; impl Actor for ProcessExec { type Options = ProcessExecOpt; - const NAME: &'static str = "process_exec"; + const NAME: &str = "process_exec"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { succ!(cx.tasks.scheduler.process_open(opt)); diff --git a/yazi-actor/src/tasks/show.rs b/yazi-actor/src/tasks/show.rs index 09e7250c..7561d431 100644 --- a/yazi-actor/src/tasks/show.rs +++ b/yazi-actor/src/tasks/show.rs @@ -10,7 +10,7 @@ pub struct Show; impl Actor for Show { type Options = VoidOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, _: Self::Options) -> Result { let tasks = &mut cx.tasks; diff --git a/yazi-actor/src/which/callback.rs b/yazi-actor/src/which/callback.rs index 3df4957e..508f24af 100644 --- a/yazi-actor/src/which/callback.rs +++ b/yazi-actor/src/which/callback.rs @@ -10,7 +10,7 @@ pub struct Callback; impl Actor for Callback { type Options = CallbackOpt; - const NAME: &'static str = "callback"; + const NAME: &str = "callback"; fn act(_: &mut Ctx, opt: Self::Options) -> Result { opt.tx.try_send(opt.idx)?; diff --git a/yazi-actor/src/which/show.rs b/yazi-actor/src/which/show.rs index cd39a0d4..0bbdede9 100644 --- a/yazi-actor/src/which/show.rs +++ b/yazi-actor/src/which/show.rs @@ -10,7 +10,7 @@ pub struct Show; impl Actor for Show { type Options = ShowOpt; - const NAME: &'static str = "show"; + const NAME: &str = "show"; fn act(cx: &mut Ctx, opt: Self::Options) -> Result { if opt.cands.is_empty() { diff --git a/yazi-binding/src/lib.rs b/yazi-binding/src/lib.rs index 0271786a..ff8a8cc1 100644 --- a/yazi-binding/src/lib.rs +++ b/yazi-binding/src/lib.rs @@ -4,4 +4,4 @@ mod macros; yazi_macro::mod_pub!(elements); -yazi_macro::mod_flat!(cha color composer error file icon id iter permit runtime stage style url urn utils); +yazi_macro::mod_flat!(cha color composer error file icon id iter permit runtime source stage style url urn utils); diff --git a/yazi-binding/src/source.rs b/yazi-binding/src/source.rs new file mode 100644 index 00000000..7b6fe2b4 --- /dev/null +++ b/yazi-binding/src/source.rs @@ -0,0 +1,7 @@ +use mlua::{IntoLua, Lua, Value}; + +pub struct Source(pub yazi_shared::Source); + +impl IntoLua for Source { + fn into_lua(self, lua: &Lua) -> mlua::Result { self.0.bits().into_lua(lua) } +} diff --git a/yazi-core/src/spot/spot.rs b/yazi-core/src/spot/spot.rs index d65c6a5f..8cc980c6 100644 --- a/yazi-core/src/spot/spot.rs +++ b/yazi-core/src/spot/spot.rs @@ -2,7 +2,7 @@ use tokio_util::sync::CancellationToken; use yazi_config::YAZI; use yazi_fs::File; use yazi_macro::render; -use yazi_parser::tab::SpotLock; +use yazi_parser::mgr::SpotLock; use yazi_plugin::isolate; use yazi_shared::{SStr, url::Url}; diff --git a/yazi-core/src/tab/preview.rs b/yazi-core/src/tab/preview.rs index ddf4952c..c498ec4b 100644 --- a/yazi-core/src/tab/preview.rs +++ b/yazi-core/src/tab/preview.rs @@ -7,7 +7,7 @@ use yazi_adapter::ADAPTOR; use yazi_config::{LAYOUT, YAZI}; use yazi_fs::{File, Files, FilesOp, cha::Cha}; use yazi_macro::render; -use yazi_parser::tab::PreviewLock; +use yazi_parser::mgr::PreviewLock; use yazi_plugin::{external::Highlighter, isolate}; use yazi_shared::{MIME_DIR, SStr, url::Url}; diff --git a/yazi-dds/src/body/before_default.rs b/yazi-dds/src/body/before_default.rs new file mode 100644 index 00000000..b8f09812 --- /dev/null +++ b/yazi-dds/src/body/before_default.rs @@ -0,0 +1,72 @@ +use anyhow::bail; + +use crate::body::Body; + +macro_rules! unsupported { + [ $( $layer:ident : $name:ident $(<$lt:lifetime>)? $(,)? )+ ] => { + $( + paste::paste! { + unsupported!(yazi_parser::$layer::[<$name:camel Opt>] $(<$lt>)?); + } + )+ + }; + [ $( $path:path $(,)? )+ ] => { + $( + impl TryFrom<&$path> for Body<'static> { + type Error = anyhow::Error; + + fn try_from(_: &$path) -> Result { + bail!("unsupported"); + } + } + )+ + }; +} + +unsupported!( + mgr:cd + mgr:close + mgr:copy + mgr:create + mgr:escape + mgr:filter + mgr:find + mgr:find_arrow + mgr:find_do + mgr:forward + mgr:hardlink + mgr:hidden + mgr:linemode + mgr:link + mgr:open + mgr:open_do + mgr:paste + mgr:peek + mgr:remove + mgr:rename + mgr:reveal + mgr:search + mgr:seek + mgr:shell + mgr:spot + mgr:tab_close + mgr:tab_create + mgr:tab_switch + mgr:toggle + mgr:toggle_all + mgr:update_files + mgr:update_mimes + mgr:update_paged + mgr:update_peeked + mgr:update_spotted + mgr:update_tasks + mgr:update_yanked<'_> + mgr:visual_mode + mgr:yank +); + +unsupported!( + yazi_parser::ArrowOpt + yazi_parser::VoidOpt + yazi_shared::event::CmdCow +); diff --git a/yazi-dds/src/body/before_quit.rs b/yazi-dds/src/body/before_quit.rs index a1998bbf..244997db 100644 --- a/yazi-dds/src/body/before_quit.rs +++ b/yazi-dds/src/body/before_quit.rs @@ -1,7 +1,36 @@ +use mlua::{IntoLua, Lua, Value}; +use serde::{Deserialize, Serialize}; +use yazi_parser::mgr::QuitOpt; use yazi_shared::Source; -pub struct BeforeQuit { - // FIXME - // pub opts: BeforeQuitOpt, +use crate::{body::Body, local_or_err}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct BeforeQuitBody { + pub opts: QuitOpt, pub source: Source, } + +impl IntoLua for BeforeQuitBody { + fn into_lua(self, lua: &Lua) -> mlua::Result { + lua + .create_table_from([ + ("opts", self.opts.into_lua(lua)?), + ("source", yazi_binding::Source(self.source).into_lua(lua)?), + ])? + .into_lua(lua) + } +} + +impl TryFrom<&QuitOpt> for Body<'static> { + type Error = anyhow::Error; + + fn try_from(value: &QuitOpt) -> Result { + local_or_err!("before-quit"); + + Ok(Body::BeforeQuit(BeforeQuitBody { + opts: value.clone(), + source: Source::default(), // FIXME + })) + } +} diff --git a/yazi-dds/src/body/body.rs b/yazi-dds/src/body/body.rs index 9ab81362..08340153 100644 --- a/yazi-dds/src/body/body.rs +++ b/yazi-dds/src/body/body.rs @@ -3,7 +3,7 @@ use mlua::{ExternalResult, IntoLua, Lua, Value}; use serde::Serialize; use yazi_shared::Id; -use super::{BodyBulk, BodyBye, BodyCd, BodyCustom, BodyDelete, BodyHey, BodyHi, BodyHover, BodyLoad, BodyMount, BodyMove, BodyRename, BodyTab, BodyTrash, BodyYank}; +use super::{BeforeQuitBody, BodyBulk, BodyBye, BodyCd, BodyCustom, BodyDelete, BodyHey, BodyHi, BodyHover, BodyLoad, BodyMount, BodyMove, BodyRename, BodyTab, BodyTrash, BodyYank}; use crate::Payload; #[derive(Debug, Serialize)] @@ -23,6 +23,7 @@ pub enum Body<'a> { Trash(BodyTrash<'a>), Delete(BodyDelete<'a>), Mount(BodyMount), + BeforeQuit(BeforeQuitBody), Custom(BodyCustom), } @@ -43,6 +44,7 @@ impl Body<'static> { "trash" => Self::Trash(serde_json::from_str(body)?), "delete" => Self::Delete(serde_json::from_str(body)?), "mount" => Self::Mount(serde_json::from_str(body)?), + "before-quit" => Self::BeforeQuit(serde_json::from_str(body)?), _ => BodyCustom::from_str(kind, body)?, }) } @@ -69,6 +71,7 @@ impl Body<'static> { | "trash" | "delete" | "mount" + | "before-quit" ) { bail!("Cannot construct system event"); } @@ -103,6 +106,7 @@ impl<'a> Body<'a> { Self::Trash(_) => "trash", Self::Delete(_) => "delete", Self::Mount(_) => "mount", + Self::BeforeQuit(_) => "before-quit", Self::Custom(b) => b.kind.as_str(), } } @@ -133,6 +137,7 @@ impl IntoLua for Body<'static> { Self::Trash(b) => b.into_lua(lua), Self::Delete(b) => b.into_lua(lua), Self::Mount(b) => b.into_lua(lua), + Self::BeforeQuit(b) => b.into_lua(lua), Self::Custom(b) => b.into_lua(lua), } } diff --git a/yazi-dds/src/body/mod.rs b/yazi-dds/src/body/mod.rs index 99d8f0b2..62f7926b 100644 --- a/yazi-dds/src/body/mod.rs +++ b/yazi-dds/src/body/mod.rs @@ -1,5 +1,5 @@ #![allow(clippy::module_inception)] yazi_macro::mod_flat!( - before_quit body bulk bye cd custom delete hey hi hover load mount r#move rename tab trash yank + before_default before_quit body bulk bye cd custom delete hey hi hover load mount r#move rename tab trash yank ); diff --git a/yazi-dds/src/lib.rs b/yazi-dds/src/lib.rs index bd04acc7..9a50040d 100644 --- a/yazi-dds/src/lib.rs +++ b/yazi-dds/src/lib.rs @@ -1,5 +1,7 @@ #![allow(clippy::option_map_unit_fn)] +mod macros; + yazi_macro::mod_pub!(body); yazi_macro::mod_flat!(client payload pubsub pump sendable server state stream); diff --git a/yazi-dds/src/macros.rs b/yazi-dds/src/macros.rs new file mode 100644 index 00000000..4ee8d03e --- /dev/null +++ b/yazi-dds/src/macros.rs @@ -0,0 +1,8 @@ +#[macro_export] +macro_rules! local_or_err { + ($name:literal) => { + if !$crate::LOCAL.read().contains_key($name) { + anyhow::bail!("No local event handler found"); + } + }; +} diff --git a/yazi-dds/src/payload.rs b/yazi-dds/src/payload.rs index 0286ccff..0408190d 100644 --- a/yazi-dds/src/payload.rs +++ b/yazi-dds/src/payload.rs @@ -93,6 +93,7 @@ impl Display for Payload<'_> { Body::Trash(b) => serde_json::to_string(b), Body::Delete(b) => serde_json::to_string(b), Body::Mount(b) => serde_json::to_string(b), + Body::BeforeQuit(b) => serde_json::to_string(b), Body::Custom(b) => serde_json::to_string(b), }; diff --git a/yazi-fm/src/app/commands/accept_payload.rs b/yazi-fm/src/app/commands/accept_payload.rs index cc82f48f..9d76154c 100644 --- a/yazi-fm/src/app/commands/accept_payload.rs +++ b/yazi-fm/src/app/commands/accept_payload.rs @@ -1,8 +1,9 @@ use anyhow::{Result, bail}; -use mlua::IntoLua; +use mlua::{IntoLua, Value}; use tracing::error; use yazi_binding::runtime_mut; -use yazi_dds::{LOCAL, Payload, REMOTE}; +use yazi_core::Core; +use yazi_dds::{LOCAL, Payload, REMOTE, body::Body}; use yazi_macro::succ; use yazi_plugin::LUA; use yazi_shared::event::{CmdCow, Data}; @@ -10,7 +11,7 @@ use yazi_shared::event::{CmdCow, Data}; use crate::{app::App, lives::Lives}; impl App { - pub(crate) fn accept_payload(&mut self, mut c: CmdCow) -> Result { + pub(crate) fn accept_payload(&self, mut c: CmdCow) -> Result { let Some(payload) = c.take_any2::("payload").transpose()? else { bail!("'payload' is required for accept_payload"); }; @@ -37,4 +38,32 @@ impl App { Ok(()) })?); } + + // FIXME: find a better name + pub(crate) fn accept_payload2(core: &Core, body: Body<'static>) -> Result { + let kind = body.kind(); + let Some(handlers) = LOCAL.read().get(kind).filter(|&m| !m.is_empty()).cloned() else { + succ!(false) + }; + + let kind = kind.to_owned(); + succ!(Lives::scope(core, || { + let body = body.into_lua(&LUA)?; + for (id, cb) in handlers { + runtime_mut!(LUA)?.push(&id); + let result = cb.call::(body.clone()); + runtime_mut!(LUA)?.pop(); + + match result { + Ok(Value::Boolean(true)) => return Ok(true), + Ok(Value::Nil | Value::Boolean(false)) => {} + Ok(v) => { + error!("Unexpected return type from `{kind}` event handler in `{id}` plugin: {v:?}") + } + Err(e) => error!("Failed to run `{kind}` event handler in `{id}` plugin: {e}"), + } + } + Ok(false) + })?); + } } diff --git a/yazi-fm/src/app/commands/bootstrap.rs b/yazi-fm/src/app/commands/bootstrap.rs index 7cd3e9f5..5fb23763 100644 --- a/yazi-fm/src/app/commands/bootstrap.rs +++ b/yazi-fm/src/app/commands/bootstrap.rs @@ -2,7 +2,7 @@ use anyhow::Result; use yazi_actor::Ctx; use yazi_boot::BOOT; use yazi_macro::{act, succ}; -use yazi_parser::{VoidOpt, tab::CdSource}; +use yazi_parser::{VoidOpt, mgr::CdSource}; use yazi_shared::{event::Data, url::Url}; use crate::app::App; diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 86f339c2..0f698c14 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -1,5 +1,6 @@ use anyhow::Result; -use yazi_actor::Ctx; +use yazi_actor::{Actor, Ctx}; +use yazi_dds::body::Body; use yazi_macro::{act, succ}; use yazi_shared::{Layer, event::{CmdCow, Data}}; use yazi_widgets::input::InputMode; @@ -56,10 +57,16 @@ impl<'a> Executor<'a> { fn mgr(&mut self, cmd: CmdCow) -> Result { let cx = &mut Ctx::new(&mut self.app.core, &cmd)?; + // FIXME: move the DDS part to `yazi-actor` macro_rules! on { ($name:ident) => { if cmd.name == stringify!($name) { - return act!(mgr:$name, cx, cmd); + let opt = ::Options::try_from(cmd)?; + return if let Ok(body) = Body::try_from(&opt) && App::accept_payload2(cx.core, body)? == true { + succ!() + } else { + act!(mgr:$name, cx, opt) + }; } }; } diff --git a/yazi-macro/src/actor.rs b/yazi-macro/src/actor.rs index 157ecf47..b9b8fcc3 100644 --- a/yazi-macro/src/actor.rs +++ b/yazi-macro/src/actor.rs @@ -3,12 +3,12 @@ macro_rules! act { ($layer:ident : $name:ident, $cx:expr, $cmd:expr) => {{ #[allow(unused_imports)] use ::yazi_actor::Actor; - paste::paste! { ::yazi_actor::$layer::[<$name:camel>]::act($cx, $cmd.try_into()?) } + ::act($cx, $cmd.try_into()?) }}; ($layer:ident : $name:ident, $cx:expr) => {{ #[allow(unused_imports)] use yazi_actor::Actor; - paste::paste! { yazi_actor::$layer::[<$name:camel>]::act($cx, Default::default()) } + ::act($cx, Default::default()) }}; ($name:ident, $cx:expr, $cmd:expr) => { $cx.$name($cmd.try_into()?) @@ -16,4 +16,7 @@ macro_rules! act { ($name:ident, $cx:expr) => { $cx.$name(Default::default()) }; + ($layer:ident : $name:ident) => { + paste::paste! { yazi_actor::$layer::[<$name:camel>] } + }; } diff --git a/yazi-parser/src/lib.rs b/yazi-parser/src/lib.rs index fdf785c7..691c03ff 100644 --- a/yazi-parser/src/lib.rs +++ b/yazi-parser/src/lib.rs @@ -1,3 +1,3 @@ -yazi_macro::mod_pub!(app cmp confirm help input mgr notify pick spot tab tasks which); +yazi_macro::mod_pub!(app cmp confirm help input mgr notify pick spot tasks which); yazi_macro::mod_flat!(arrow step void); diff --git a/yazi-parser/src/tab/back.rs b/yazi-parser/src/mgr/back.rs similarity index 100% rename from yazi-parser/src/tab/back.rs rename to yazi-parser/src/mgr/back.rs diff --git a/yazi-parser/src/tab/cd.rs b/yazi-parser/src/mgr/cd.rs similarity index 100% rename from yazi-parser/src/tab/cd.rs rename to yazi-parser/src/mgr/cd.rs diff --git a/yazi-parser/src/tab/copy.rs b/yazi-parser/src/mgr/copy.rs similarity index 100% rename from yazi-parser/src/tab/copy.rs rename to yazi-parser/src/mgr/copy.rs diff --git a/yazi-parser/src/tab/enter.rs b/yazi-parser/src/mgr/enter.rs similarity index 100% rename from yazi-parser/src/tab/enter.rs rename to yazi-parser/src/mgr/enter.rs diff --git a/yazi-parser/src/tab/escape.rs b/yazi-parser/src/mgr/escape.rs similarity index 100% rename from yazi-parser/src/tab/escape.rs rename to yazi-parser/src/mgr/escape.rs diff --git a/yazi-parser/src/tab/filter.rs b/yazi-parser/src/mgr/filter.rs similarity index 100% rename from yazi-parser/src/tab/filter.rs rename to yazi-parser/src/mgr/filter.rs diff --git a/yazi-parser/src/tab/find.rs b/yazi-parser/src/mgr/find.rs similarity index 100% rename from yazi-parser/src/tab/find.rs rename to yazi-parser/src/mgr/find.rs diff --git a/yazi-parser/src/tab/find_arrow.rs b/yazi-parser/src/mgr/find_arrow.rs similarity index 100% rename from yazi-parser/src/tab/find_arrow.rs rename to yazi-parser/src/mgr/find_arrow.rs diff --git a/yazi-parser/src/tab/find_do.rs b/yazi-parser/src/mgr/find_do.rs similarity index 100% rename from yazi-parser/src/tab/find_do.rs rename to yazi-parser/src/mgr/find_do.rs diff --git a/yazi-parser/src/tab/forward.rs b/yazi-parser/src/mgr/forward.rs similarity index 100% rename from yazi-parser/src/tab/forward.rs rename to yazi-parser/src/mgr/forward.rs diff --git a/yazi-parser/src/tab/hover.rs b/yazi-parser/src/mgr/hover.rs similarity index 100% rename from yazi-parser/src/tab/hover.rs rename to yazi-parser/src/mgr/hover.rs diff --git a/yazi-parser/src/mgr/mod.rs b/yazi-parser/src/mgr/mod.rs index 21ee4539..e7055cdb 100644 --- a/yazi-parser/src/mgr/mod.rs +++ b/yazi-parser/src/mgr/mod.rs @@ -1,8 +1,19 @@ yazi_macro::mod_flat!( + back + cd close + copy create + enter + escape + filter + find + find_arrow + find_do + forward hardlink hidden + hover linemode link open @@ -11,16 +22,23 @@ yazi_macro::mod_flat!( quit remove rename + reveal search seek + shell spot tab_close tab_create tab_switch + toggle + toggle_all update_files update_mimes update_paged + update_peeked + update_spotted update_tasks update_yanked + visual_mode yank ); diff --git a/yazi-parser/src/mgr/quit.rs b/yazi-parser/src/mgr/quit.rs index 4aeebe6d..3e5d5c22 100644 --- a/yazi-parser/src/mgr/quit.rs +++ b/yazi-parser/src/mgr/quit.rs @@ -2,7 +2,7 @@ use mlua::{IntoLua, Lua, LuaSerdeExt, Value}; use serde::{Deserialize, Serialize}; use yazi_shared::event::{CmdCow, Data, EventQuit}; -#[derive(Default, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, Serialize, Deserialize)] pub struct QuitOpt { pub code: i32, pub no_cwd_file: bool, diff --git a/yazi-parser/src/tab/reveal.rs b/yazi-parser/src/mgr/reveal.rs similarity index 96% rename from yazi-parser/src/tab/reveal.rs rename to yazi-parser/src/mgr/reveal.rs index c4d8d468..7f1e6e0a 100644 --- a/yazi-parser/src/tab/reveal.rs +++ b/yazi-parser/src/mgr/reveal.rs @@ -1,7 +1,7 @@ use yazi_fs::expand_path; use yazi_shared::{event::CmdCow, url::Url}; -use crate::tab::CdSource; +use crate::mgr::CdSource; pub struct RevealOpt { pub target: Url, diff --git a/yazi-parser/src/tab/shell.rs b/yazi-parser/src/mgr/shell.rs similarity index 100% rename from yazi-parser/src/tab/shell.rs rename to yazi-parser/src/mgr/shell.rs diff --git a/yazi-parser/src/tab/toggle.rs b/yazi-parser/src/mgr/toggle.rs similarity index 100% rename from yazi-parser/src/tab/toggle.rs rename to yazi-parser/src/mgr/toggle.rs diff --git a/yazi-parser/src/tab/toggle_all.rs b/yazi-parser/src/mgr/toggle_all.rs similarity index 100% rename from yazi-parser/src/tab/toggle_all.rs rename to yazi-parser/src/mgr/toggle_all.rs diff --git a/yazi-parser/src/tab/update_peeked.rs b/yazi-parser/src/mgr/update_peeked.rs similarity index 100% rename from yazi-parser/src/tab/update_peeked.rs rename to yazi-parser/src/mgr/update_peeked.rs diff --git a/yazi-parser/src/tab/update_spotted.rs b/yazi-parser/src/mgr/update_spotted.rs similarity index 100% rename from yazi-parser/src/tab/update_spotted.rs rename to yazi-parser/src/mgr/update_spotted.rs diff --git a/yazi-parser/src/tab/visual_mode.rs b/yazi-parser/src/mgr/visual_mode.rs similarity index 100% rename from yazi-parser/src/tab/visual_mode.rs rename to yazi-parser/src/mgr/visual_mode.rs diff --git a/yazi-parser/src/tab/hidden.rs b/yazi-parser/src/tab/hidden.rs deleted file mode 100644 index 8b137891..00000000 --- a/yazi-parser/src/tab/hidden.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yazi-parser/src/tab/mod.rs b/yazi-parser/src/tab/mod.rs deleted file mode 100644 index cec1d11b..00000000 --- a/yazi-parser/src/tab/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -yazi_macro::mod_flat!( - back - cd - copy - enter - escape - filter - find - find_arrow - find_do - forward - hidden - hover - reveal - search - shell - sort - toggle - toggle_all - update_peeked - update_spotted - visual_mode -); diff --git a/yazi-parser/src/tab/search.rs b/yazi-parser/src/tab/search.rs deleted file mode 100644 index 8b137891..00000000 --- a/yazi-parser/src/tab/search.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yazi-parser/src/tab/sort.rs b/yazi-parser/src/tab/sort.rs deleted file mode 100644 index 8b137891..00000000 --- a/yazi-parser/src/tab/sort.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/yazi-plugin/src/utils/preview.rs b/yazi-plugin/src/utils/preview.rs index df78a65f..40c0987d 100644 --- a/yazi-plugin/src/utils/preview.rs +++ b/yazi-plugin/src/utils/preview.rs @@ -1,7 +1,7 @@ use mlua::{AnyUserData, ExternalError, Function, IntoLuaMulti, Lua, Table, Value}; use yazi_binding::{Error, elements::{Area, Renderable, Text}}; use yazi_config::YAZI; -use yazi_parser::tab::{PreviewLock, UpdatePeekedOpt}; +use yazi_parser::mgr::{PreviewLock, UpdatePeekedOpt}; use yazi_proxy::MgrProxy; use yazi_shared::errors::PeekError; diff --git a/yazi-plugin/src/utils/spot.rs b/yazi-plugin/src/utils/spot.rs index d2c16281..a8b99bdd 100644 --- a/yazi-plugin/src/utils/spot.rs +++ b/yazi-plugin/src/utils/spot.rs @@ -1,7 +1,7 @@ use mlua::{AnyUserData, Function, Lua, Table}; use yazi_binding::elements::{Edge, Renderable}; use yazi_config::THEME; -use yazi_parser::tab::{SpotLock, UpdateSpottedOpt}; +use yazi_parser::mgr::{SpotLock, UpdateSpottedOpt}; use yazi_proxy::MgrProxy; use super::Utils; diff --git a/yazi-proxy/src/mgr.rs b/yazi-proxy/src/mgr.rs index c163dcbf..0e4ca16a 100644 --- a/yazi-proxy/src/mgr.rs +++ b/yazi-proxy/src/mgr.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use yazi_macro::emit; -use yazi_parser::{mgr::{OpenDoOpt, SearchOpt}, tab::{FilterOpt, FindDoOpt, UpdatePeekedOpt, UpdateSpottedOpt}}; +use yazi_parser::mgr::{FilterOpt, FindDoOpt, OpenDoOpt, SearchOpt, UpdatePeekedOpt, UpdateSpottedOpt}; use yazi_shared::{SStr, event::Cmd, url::Url}; pub struct MgrProxy; diff --git a/yazi-shared/src/source.rs b/yazi-shared/src/source.rs index c6782f6e..86853a58 100644 --- a/yazi-shared/src/source.rs +++ b/yazi-shared/src/source.rs @@ -1,7 +1,8 @@ use bitflags::bitflags; +use serde::{Deserialize, Serialize}; bitflags! { - #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] pub struct Source: u8 { const KEY = 0b00000001; const EMIT = 0b00000010; diff --git a/yazi-widgets/src/input/commands/forward.rs b/yazi-widgets/src/input/commands/forward.rs index 002cc3e5..2505aeb6 100644 --- a/yazi-widgets/src/input/commands/forward.rs +++ b/yazi-widgets/src/input/commands/forward.rs @@ -1,6 +1,6 @@ use anyhow::Result; use yazi_macro::act; -use yazi_parser::tab::ForwardOpt; +use yazi_parser::mgr::ForwardOpt; use yazi_shared::{CharKind, event::Data}; use crate::input::{Input, op::InputOp};