diff --git a/yazi-config/src/keymap/keymap.rs b/yazi-config/src/keymap/keymap.rs index 4639c057..4fd94d91 100644 --- a/yazi-config/src/keymap/keymap.rs +++ b/yazi-config/src/keymap/keymap.rs @@ -10,7 +10,7 @@ use crate::{Preset, keymap::Key}; #[derive(Debug)] pub struct Keymap { - pub manager: Vec, + pub mgr: Vec, pub tasks: Vec, pub spot: Vec, pub pick: Vec, @@ -25,7 +25,7 @@ impl Keymap { pub fn get(&self, layer: Layer) -> &[Chord] { match layer { Layer::App => unreachable!(), - Layer::Manager => &self.manager, + Layer::Mgr => &self.mgr, Layer::Tasks => &self.tasks, Layer::Spot => &self.spot, Layer::Pick => &self.pick, @@ -53,7 +53,8 @@ impl<'de> Deserialize<'de> for Keymap { { #[derive(Deserialize)] struct Shadow { - manager: Inner, + #[serde(rename = "manager")] + mgr: Inner, // TODO: remove serde(rename) tasks: Inner, spot: Inner, pick: Inner, @@ -92,7 +93,7 @@ impl<'de> Deserialize<'de> for Keymap { let shadow = Shadow::deserialize(deserializer)?; Ok(Self { #[rustfmt::skip] - manager: mix(shadow.manager.prepend_keymap, shadow.manager.keymap, shadow.manager.append_keymap), + mgr: mix(shadow.mgr.prepend_keymap, shadow.mgr.keymap, shadow.mgr.append_keymap), #[rustfmt::skip] tasks: mix(shadow.tasks.prepend_keymap, shadow.tasks.keymap, shadow.tasks.append_keymap), #[rustfmt::skip] diff --git a/yazi-config/src/lib.rs b/yazi-config/src/lib.rs index 6294d067..ff25f37e 100644 --- a/yazi-config/src/lib.rs +++ b/yazi-config/src/lib.rs @@ -1,6 +1,6 @@ #![allow(clippy::module_inception)] -yazi_macro::mod_pub!(keymap manager open plugin popup preview tasks theme which); +yazi_macro::mod_pub!(keymap mgr open plugin popup preview tasks theme which); yazi_macro::mod_flat!(layout pattern preset priority); @@ -9,7 +9,7 @@ use std::str::FromStr; use yazi_shared::{RoCell, SyncCell}; pub static KEYMAP: RoCell = RoCell::new(); -pub static MANAGER: RoCell = RoCell::new(); +pub static MGR: RoCell = RoCell::new(); pub static OPEN: RoCell = RoCell::new(); pub static PLUGIN: RoCell = RoCell::new(); pub static PREVIEW: RoCell = RoCell::new(); @@ -29,7 +29,7 @@ pub fn init() -> anyhow::Result<()> { } // TODO: remove this - for c in KEYMAP.manager.iter().flat_map(|c| c.run.iter()) { + for c in KEYMAP.mgr.iter().flat_map(|c| c.run.iter()) { if c.name == "arrow" && c.first_str().unwrap_or_default().parse::().is_ok_and(|n| n <= -999 || n >= 999) { @@ -50,10 +50,10 @@ pub fn init_flavor(light: bool) -> anyhow::Result<()> { } let mut theme: theme::Theme = <_>::from_str(&flavor_toml.unwrap())?; - theme.manager.syntect_theme = theme + theme.mgr.syntect_theme = theme .flavor .syntect_path(light) - .unwrap_or_else(|| yazi_fs::expand_path(&theme.manager.syntect_theme)); + .unwrap_or_else(|| yazi_fs::expand_path(&theme.mgr.syntect_theme)); THEME.init(theme); Ok(()) @@ -68,7 +68,7 @@ fn try_init(merge: bool) -> anyhow::Result<()> { }; let keymap = <_>::from_str(&keymap_toml)?; - let manager = <_>::from_str(&yazi_toml)?; + let mgr = <_>::from_str(&yazi_toml)?; let open = <_>::from_str(&yazi_toml)?; let plugin = <_>::from_str(&yazi_toml)?; let preview = <_>::from_str(&yazi_toml)?; @@ -79,7 +79,7 @@ fn try_init(merge: bool) -> anyhow::Result<()> { let which = <_>::from_str(&yazi_toml)?; KEYMAP.init(keymap); - MANAGER.init(manager); + MGR.init(mgr); OPEN.init(open); PLUGIN.init(plugin); PREVIEW.init(preview); diff --git a/yazi-config/src/manager/mod.rs b/yazi-config/src/manager/mod.rs deleted file mode 100644 index 75c2a5ed..00000000 --- a/yazi-config/src/manager/mod.rs +++ /dev/null @@ -1 +0,0 @@ -yazi_macro::mod_flat!(manager mouse ratio); diff --git a/yazi-config/src/manager/manager.rs b/yazi-config/src/mgr/mgr.rs similarity index 79% rename from yazi-config/src/manager/manager.rs rename to yazi-config/src/mgr/mgr.rs index 923b7dc1..d1932d4d 100644 --- a/yazi-config/src/manager/manager.rs +++ b/yazi-config/src/mgr/mgr.rs @@ -5,11 +5,11 @@ use serde::{Deserialize, Serialize}; use validator::Validate; use yazi_fs::SortBy; -use super::{ManagerRatio, MouseEvents}; +use super::{MgrRatio, MouseEvents}; #[derive(Debug, Deserialize, Serialize, Validate)] -pub struct Manager { - pub ratio: ManagerRatio, +pub struct Mgr { + pub ratio: MgrRatio, // Sorting pub sort_by: SortBy, @@ -28,19 +28,20 @@ pub struct Manager { pub title_format: String, } -impl FromStr for Manager { +impl FromStr for Mgr { type Err = anyhow::Error; fn from_str(s: &str) -> Result { #[derive(Deserialize)] struct Outer { - manager: Manager, + #[serde(rename = "manager")] + mgr: Mgr, // TODO: remove serde(rename) } let outer = toml::from_str::(s) .context("Failed to parse the [manager] section in your yazi.toml")?; - outer.manager.validate()?; + outer.mgr.validate()?; - Ok(outer.manager) + Ok(outer.mgr) } } diff --git a/yazi-config/src/mgr/mod.rs b/yazi-config/src/mgr/mod.rs new file mode 100644 index 00000000..92e09e50 --- /dev/null +++ b/yazi-config/src/mgr/mod.rs @@ -0,0 +1 @@ +yazi_macro::mod_flat!(mgr mouse ratio); diff --git a/yazi-config/src/manager/mouse.rs b/yazi-config/src/mgr/mouse.rs similarity index 100% rename from yazi-config/src/manager/mouse.rs rename to yazi-config/src/mgr/mouse.rs diff --git a/yazi-config/src/manager/ratio.rs b/yazi-config/src/mgr/ratio.rs similarity index 90% rename from yazi-config/src/manager/ratio.rs rename to yazi-config/src/mgr/ratio.rs index c264cb92..e28391e1 100644 --- a/yazi-config/src/manager/ratio.rs +++ b/yazi-config/src/mgr/ratio.rs @@ -3,14 +3,14 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)] #[serde(try_from = "Vec")] -pub struct ManagerRatio { +pub struct MgrRatio { pub parent: u16, pub current: u16, pub preview: u16, pub all: u16, } -impl TryFrom> for ManagerRatio { +impl TryFrom> for MgrRatio { type Error = anyhow::Error; fn try_from(ratio: Vec) -> Result { diff --git a/yazi-config/src/theme/theme.rs b/yazi-config/src/theme/theme.rs index a0faa38b..dd3806cb 100644 --- a/yazi-config/src/theme/theme.rs +++ b/yazi-config/src/theme/theme.rs @@ -10,7 +10,8 @@ use super::{Filetype, Flavor, Icons}; #[derive(Deserialize, Serialize)] pub struct Theme { pub flavor: Flavor, - pub manager: Manager, + #[serde(rename = "manager")] + pub mgr: Mgr, // TODO: Remove `serde(rename)` pub mode: Mode, pub status: Status, pub which: Which, @@ -35,7 +36,7 @@ impl FromStr for Theme { fn from_str(s: &str) -> Result { let theme: Self = toml::from_str(s).context("Failed to parse your theme.toml")?; - theme.manager.validate()?; + theme.mgr.validate()?; theme.which.validate()?; Ok(theme) @@ -43,7 +44,7 @@ impl FromStr for Theme { } #[derive(Deserialize, Serialize, Validate)] -pub struct Manager { +pub struct Mgr { cwd: Style, // Hovered diff --git a/yazi-core/src/confirm/commands/arrow.rs b/yazi-core/src/confirm/commands/arrow.rs index bdde389b..5af73ac7 100644 --- a/yazi-core/src/confirm/commands/arrow.rs +++ b/yazi-core/src/confirm/commands/arrow.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::{CmdCow, Data}; -use crate::{confirm::Confirm, manager::Manager}; +use crate::{confirm::Confirm, mgr::Mgr}; struct Opt { step: isize, @@ -13,9 +13,9 @@ impl From for Opt { impl Confirm { #[yazi_codegen::command] - pub fn arrow(&mut self, opt: Opt, manager: &Manager) { + pub fn arrow(&mut self, opt: Opt, mgr: &Mgr) { if opt.step > 0 { - self.next(opt.step as usize, manager.area(self.position).width) + self.next(opt.step as usize, mgr.area(self.position).width) } else { self.prev(opt.step.unsigned_abs()) } diff --git a/yazi-core/src/lib.rs b/yazi-core/src/lib.rs index 6c2d14eb..e9499104 100644 --- a/yazi-core/src/lib.rs +++ b/yazi-core/src/lib.rs @@ -6,9 +6,9 @@ clippy::unit_arg )] -yazi_macro::mod_pub!(completion confirm help input manager notify pick spot tab tasks which); +yazi_macro::mod_pub!(completion confirm help input mgr notify pick spot tab tasks which); pub fn init() { - manager::WATCHED.with(<_>::default); - manager::LINKED.with(<_>::default); + mgr::WATCHED.with(<_>::default); + mgr::LINKED.with(<_>::default); } diff --git a/yazi-core/src/manager/mod.rs b/yazi-core/src/manager/mod.rs deleted file mode 100644 index 249f4dbb..00000000 --- a/yazi-core/src/manager/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -yazi_macro::mod_pub!(commands); - -yazi_macro::mod_flat!(linked manager mimetype tabs watcher yanked); diff --git a/yazi-core/src/manager/commands/bulk_rename.rs b/yazi-core/src/mgr/commands/bulk_rename.rs similarity index 98% rename from yazi-core/src/manager/commands/bulk_rename.rs rename to yazi-core/src/mgr/commands/bulk_rename.rs index 0ddc75f9..fe53ba50 100644 --- a/yazi-core/src/manager/commands/bulk_rename.rs +++ b/yazi-core/src/mgr/commands/bulk_rename.rs @@ -9,9 +9,9 @@ use yazi_fs::{File, FilesOp, max_common_root, maybe_exists, paths_to_same_file}; use yazi_proxy::{AppProxy, HIDER, TasksProxy, WATCHER}; use yazi_shared::{terminal_clear, url::Url}; -use crate::manager::Manager; +use crate::mgr::Mgr; -impl Manager { +impl Mgr { pub(super) fn bulk_rename(&self) { let Some(opener) = OPEN.block_opener("bulk-rename.txt", "text/plain") else { return AppProxy::notify_warn("Bulk rename", "No text opener found"); @@ -170,7 +170,7 @@ mod tests { #[test] fn test_sort() { fn cmp(input: &[(&str, &str)], expected: &[(&str, &str)]) { - let sorted = Manager::prioritized_paths( + let sorted = Mgr::prioritized_paths( input.iter().map(|&(o, _)| o.into()).collect(), input.iter().map(|&(_, n)| n.into()).collect(), ); diff --git a/yazi-core/src/manager/commands/close.rs b/yazi-core/src/mgr/commands/close.rs similarity index 86% rename from yazi-core/src/manager/commands/close.rs rename to yazi-core/src/mgr/commands/close.rs index 568b66ea..a71f9d9f 100644 --- a/yazi-core/src/manager/commands/close.rs +++ b/yazi-core/src/mgr/commands/close.rs @@ -1,6 +1,6 @@ use yazi_shared::event::CmdCow; -use crate::{manager::{Manager, commands::quit}, tasks::Tasks}; +use crate::{mgr::{Mgr, commands::quit}, tasks::Tasks}; #[derive(Default)] struct Opt { @@ -13,7 +13,7 @@ impl From for quit::Opt { fn from(value: Opt) -> Self { Self { no_cwd_file: value.no_cwd_file } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn close(&mut self, opt: Opt, tasks: &Tasks) { if self.tabs.len() > 1 { diff --git a/yazi-core/src/manager/commands/create.rs b/yazi-core/src/mgr/commands/create.rs similarity index 97% rename from yazi-core/src/manager/commands/create.rs rename to yazi-core/src/mgr/commands/create.rs index 9160a688..7058892c 100644 --- a/yazi-core/src/manager/commands/create.rs +++ b/yazi-core/src/mgr/commands/create.rs @@ -7,7 +7,7 @@ use yazi_fs::{File, FilesOp, maybe_exists, ok_or_not_found, realname}; use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER}; use yazi_shared::{event::CmdCow, url::{Url, UrnBuf}}; -use crate::manager::Manager; +use crate::mgr::Mgr; struct Opt { dir: bool, @@ -18,7 +18,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn create(&self, opt: Opt) { let cwd = self.cwd().to_owned(); diff --git a/yazi-core/src/manager/commands/hardlink.rs b/yazi-core/src/mgr/commands/hardlink.rs similarity index 86% rename from yazi-core/src/manager/commands/hardlink.rs rename to yazi-core/src/mgr/commands/hardlink.rs index 1990d9e9..892262d0 100644 --- a/yazi-core/src/manager/commands/hardlink.rs +++ b/yazi-core/src/mgr/commands/hardlink.rs @@ -1,6 +1,6 @@ use yazi_shared::event::CmdCow; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; struct Opt { force: bool, @@ -11,7 +11,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn hardlink(&mut self, opt: Opt, tasks: &Tasks) { if self.yanked.cut { diff --git a/yazi-core/src/manager/commands/hover.rs b/yazi-core/src/mgr/commands/hover.rs similarity index 97% rename from yazi-core/src/manager/commands/hover.rs rename to yazi-core/src/mgr/commands/hover.rs index 9679c119..25c418b5 100644 --- a/yazi-core/src/manager/commands/hover.rs +++ b/yazi-core/src/mgr/commands/hover.rs @@ -4,7 +4,7 @@ use yazi_dds::Pubsub; use yazi_macro::render; use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}}; -use crate::manager::Manager; +use crate::mgr::Mgr; struct Opt { url: Option, @@ -20,7 +20,7 @@ impl From> for Opt { fn from(url: Option) -> Self { Self { url, tab: None } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn hover(&mut self, opt: Opt) { if let Some(u) = opt.url { diff --git a/yazi-core/src/manager/commands/link.rs b/yazi-core/src/mgr/commands/link.rs similarity index 86% rename from yazi-core/src/manager/commands/link.rs rename to yazi-core/src/mgr/commands/link.rs index ae357f30..a7ca7490 100644 --- a/yazi-core/src/manager/commands/link.rs +++ b/yazi-core/src/mgr/commands/link.rs @@ -1,6 +1,6 @@ use yazi_shared::event::CmdCow; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; struct Opt { relative: bool, @@ -11,7 +11,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn link(&mut self, opt: Opt, tasks: &Tasks) { if self.yanked.cut { diff --git a/yazi-core/src/manager/commands/mod.rs b/yazi-core/src/mgr/commands/mod.rs similarity index 100% rename from yazi-core/src/manager/commands/mod.rs rename to yazi-core/src/mgr/commands/mod.rs diff --git a/yazi-core/src/manager/commands/open.rs b/yazi-core/src/mgr/commands/open.rs similarity index 93% rename from yazi-core/src/manager/commands/open.rs rename to yazi-core/src/mgr/commands/open.rs index eabecb75..0caee557 100644 --- a/yazi-core/src/manager/commands/open.rs +++ b/yazi-core/src/mgr/commands/open.rs @@ -6,10 +6,10 @@ use yazi_config::{OPEN, PLUGIN, popup::PickCfg}; use yazi_fs::File; use yazi_macro::emit; use yazi_plugin::isolate; -use yazi_proxy::{ManagerProxy, TasksProxy, options::OpenDoOpt}; +use yazi_proxy::{MgrProxy, TasksProxy, options::OpenDoOpt}; use yazi_shared::{MIME_DIR, event::{CmdCow, EventQuit}, url::Url}; -use crate::{manager::Manager, tab::Folder, tasks::Tasks}; +use crate::{mgr::Mgr, tab::Folder, tasks::Tasks}; #[derive(Clone, Copy)] struct Opt { @@ -23,7 +23,7 @@ impl From for Opt { } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn open(&mut self, opt: Opt, tasks: &Tasks) { if !self.active_mut().try_escape_visual() { @@ -70,12 +70,7 @@ impl Manager { } } - ManagerProxy::open_do(OpenDoOpt { - cwd, - hovered, - targets: done, - interactive: opt.interactive, - }); + MgrProxy::open_do(OpenDoOpt { cwd, hovered, targets: done, interactive: opt.interactive }); }); } diff --git a/yazi-core/src/manager/commands/paste.rs b/yazi-core/src/mgr/commands/paste.rs similarity index 90% rename from yazi-core/src/manager/commands/paste.rs rename to yazi-core/src/mgr/commands/paste.rs index 526b3b94..fcc814cb 100644 --- a/yazi-core/src/manager/commands/paste.rs +++ b/yazi-core/src/mgr/commands/paste.rs @@ -1,6 +1,6 @@ use yazi_shared::event::CmdCow; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; struct Opt { force: bool, @@ -11,7 +11,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn paste(&mut self, opt: Opt, tasks: &Tasks) { let (src, dest) = (self.yanked.iter().collect::>(), self.cwd()); diff --git a/yazi-core/src/manager/commands/peek.rs b/yazi-core/src/mgr/commands/peek.rs similarity index 97% rename from yazi-core/src/manager/commands/peek.rs rename to yazi-core/src/mgr/commands/peek.rs index 3dcaf333..307579d5 100644 --- a/yazi-core/src/manager/commands/peek.rs +++ b/yazi-core/src/mgr/commands/peek.rs @@ -1,7 +1,7 @@ use yazi_proxy::HIDER; use yazi_shared::{event::{CmdCow, Data}, url::Url}; -use crate::manager::Manager; +use crate::mgr::Mgr; #[derive(Debug, Default)] struct Opt { @@ -25,7 +25,7 @@ impl From for Opt { fn from(force: bool) -> Self { Self { force, ..Default::default() } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn peek(&mut self, opt: Opt) { let Some(hovered) = self.hovered().cloned() else { diff --git a/yazi-core/src/manager/commands/quit.rs b/yazi-core/src/mgr/commands/quit.rs similarity index 95% rename from yazi-core/src/manager/commands/quit.rs rename to yazi-core/src/mgr/commands/quit.rs index caf3811b..343ed732 100644 --- a/yazi-core/src/manager/commands/quit.rs +++ b/yazi-core/src/mgr/commands/quit.rs @@ -6,7 +6,7 @@ use yazi_macro::emit; use yazi_proxy::ConfirmProxy; use yazi_shared::event::{CmdCow, EventQuit}; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; #[derive(Default)] pub(super) struct Opt { @@ -16,7 +16,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn quit(&self, opt: Opt, tasks: &Tasks) { let opt = EventQuit { no_cwd_file: opt.no_cwd_file, ..Default::default() }; diff --git a/yazi-core/src/manager/commands/refresh.rs b/yazi-core/src/mgr/commands/refresh.rs similarity index 80% rename from yazi-core/src/manager/commands/refresh.rs rename to yazi-core/src/mgr/commands/refresh.rs index 1fa6ba48..45ceeae0 100644 --- a/yazi-core/src/manager/commands/refresh.rs +++ b/yazi-core/src/mgr/commands/refresh.rs @@ -1,15 +1,15 @@ use std::path::MAIN_SEPARATOR; use crossterm::{execute, terminal::SetTitle}; -use yazi_config::MANAGER; +use yazi_config::MGR; use yazi_fs::CWD; use yazi_shared::event::CmdCow; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; -impl Manager { +impl Mgr { pub fn refresh(&mut self, _: CmdCow, tasks: &Tasks) { - if CWD.set(self.cwd()) && !MANAGER.title_format.is_empty() { + if CWD.set(self.cwd()) && !MGR.title_format.is_empty() { execute!(std::io::stderr(), SetTitle(self.title())).ok(); } @@ -35,6 +35,6 @@ impl Manager { format!("{}", self.cwd().display()) }; - MANAGER.title_format.replace("{cwd}", &cwd) + MGR.title_format.replace("{cwd}", &cwd) } } diff --git a/yazi-core/src/manager/commands/remove.rs b/yazi-core/src/mgr/commands/remove.rs similarity index 89% rename from yazi-core/src/manager/commands/remove.rs rename to yazi-core/src/mgr/commands/remove.rs index e9d65e7b..35f373c9 100644 --- a/yazi-core/src/manager/commands/remove.rs +++ b/yazi-core/src/mgr/commands/remove.rs @@ -1,8 +1,8 @@ use yazi_config::popup::ConfirmCfg; -use yazi_proxy::{ConfirmProxy, ManagerProxy}; +use yazi_proxy::{ConfirmProxy, MgrProxy}; use yazi_shared::{event::CmdCow, url::Url}; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; struct Opt { force: bool, @@ -22,7 +22,7 @@ impl From for Opt { } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn remove(&mut self, mut opt: Opt, tasks: &Tasks) { if !self.active_mut().try_escape_visual() { @@ -49,7 +49,7 @@ impl Manager { }); if result.await { - ManagerProxy::remove_do(opt.targets, opt.permanently); + MgrProxy::remove_do(opt.targets, opt.permanently); } }); } diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/mgr/commands/rename.rs similarity index 98% rename from yazi-core/src/manager/commands/rename.rs rename to yazi-core/src/mgr/commands/rename.rs index 3021adfc..a78ff5cf 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/mgr/commands/rename.rs @@ -8,7 +8,7 @@ use yazi_fs::{File, FilesOp, maybe_exists, ok_or_not_found, paths_to_same_file, use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER}; use yazi_shared::{Id, event::CmdCow, url::{Url, UrnBuf}}; -use crate::manager::Manager; +use crate::mgr::Mgr; struct Opt { hovered: bool, @@ -28,7 +28,7 @@ impl From for Opt { } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn rename(&mut self, opt: Opt) { if !self.active_mut().try_escape_visual() { diff --git a/yazi-core/src/manager/commands/seek.rs b/yazi-core/src/mgr/commands/seek.rs similarity index 94% rename from yazi-core/src/manager/commands/seek.rs rename to yazi-core/src/mgr/commands/seek.rs index e5f41248..146de4bf 100644 --- a/yazi-core/src/manager/commands/seek.rs +++ b/yazi-core/src/mgr/commands/seek.rs @@ -2,7 +2,7 @@ use yazi_config::PLUGIN; use yazi_plugin::isolate; use yazi_shared::event::{CmdCow, Data}; -use crate::manager::Manager; +use crate::mgr::Mgr; #[derive(Debug)] struct Opt { @@ -13,7 +13,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn seek(&mut self, opt: Opt) { let Some(hovered) = self.hovered() else { diff --git a/yazi-core/src/manager/commands/spot.rs b/yazi-core/src/mgr/commands/spot.rs similarity index 94% rename from yazi-core/src/manager/commands/spot.rs rename to yazi-core/src/mgr/commands/spot.rs index 2e2645cc..8105e186 100644 --- a/yazi-core/src/manager/commands/spot.rs +++ b/yazi-core/src/mgr/commands/spot.rs @@ -1,6 +1,6 @@ use yazi_shared::event::{CmdCow, Data}; -use crate::manager::Manager; +use crate::mgr::Mgr; struct Opt { skip: Option, @@ -10,7 +10,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").and_then(Data::as_usize) } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn spot(&mut self, opt: Opt) { let Some(hovered) = self.hovered().cloned() else { diff --git a/yazi-core/src/manager/commands/suspend.rs b/yazi-core/src/mgr/commands/suspend.rs similarity index 76% rename from yazi-core/src/manager/commands/suspend.rs rename to yazi-core/src/mgr/commands/suspend.rs index a5993901..c623686b 100644 --- a/yazi-core/src/manager/commands/suspend.rs +++ b/yazi-core/src/mgr/commands/suspend.rs @@ -1,8 +1,8 @@ use yazi_shared::event::CmdCow; -use crate::manager::Manager; +use crate::mgr::Mgr; -impl Manager { +impl Mgr { pub fn suspend(&mut self, _: CmdCow) { #[cfg(unix)] unsafe { diff --git a/yazi-core/src/manager/commands/tab_close.rs b/yazi-core/src/mgr/commands/tab_close.rs similarity index 95% rename from yazi-core/src/manager/commands/tab_close.rs rename to yazi-core/src/mgr/commands/tab_close.rs index 80a6d693..0f699b61 100644 --- a/yazi-core/src/manager/commands/tab_close.rs +++ b/yazi-core/src/mgr/commands/tab_close.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::{CmdCow, Data}; -use crate::manager::Tabs; +use crate::mgr::Tabs; struct Opt { idx: usize, diff --git a/yazi-core/src/manager/commands/tab_create.rs b/yazi-core/src/mgr/commands/tab_create.rs similarity index 96% rename from yazi-core/src/manager/commands/tab_create.rs rename to yazi-core/src/mgr/commands/tab_create.rs index 2330fc44..7047f934 100644 --- a/yazi-core/src/manager/commands/tab_create.rs +++ b/yazi-core/src/mgr/commands/tab_create.rs @@ -3,7 +3,7 @@ use yazi_macro::render; use yazi_proxy::AppProxy; use yazi_shared::{event::CmdCow, url::Url}; -use crate::{manager::Tabs, tab::Tab}; +use crate::{mgr::Tabs, tab::Tab}; const MAX_TABS: usize = 9; diff --git a/yazi-core/src/manager/commands/tab_swap.rs b/yazi-core/src/mgr/commands/tab_swap.rs similarity index 94% rename from yazi-core/src/manager/commands/tab_swap.rs rename to yazi-core/src/mgr/commands/tab_swap.rs index 932916a9..33888ec2 100644 --- a/yazi-core/src/manager/commands/tab_swap.rs +++ b/yazi-core/src/mgr/commands/tab_swap.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::{CmdCow, Data}; -use crate::manager::Tabs; +use crate::mgr::Tabs; struct Opt { step: isize, diff --git a/yazi-core/src/manager/commands/tab_switch.rs b/yazi-core/src/mgr/commands/tab_switch.rs similarity index 95% rename from yazi-core/src/manager/commands/tab_switch.rs rename to yazi-core/src/mgr/commands/tab_switch.rs index 09326fc8..9bb6c78c 100644 --- a/yazi-core/src/manager/commands/tab_switch.rs +++ b/yazi-core/src/mgr/commands/tab_switch.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::{CmdCow, Data}; -use crate::manager::Tabs; +use crate::mgr::Tabs; struct Opt { step: isize, diff --git a/yazi-core/src/manager/commands/unyank.rs b/yazi-core/src/mgr/commands/unyank.rs similarity index 91% rename from yazi-core/src/manager/commands/unyank.rs rename to yazi-core/src/mgr/commands/unyank.rs index 07333434..054a17bb 100644 --- a/yazi-core/src/manager/commands/unyank.rs +++ b/yazi-core/src/mgr/commands/unyank.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::CmdCow; -use crate::manager::Manager; +use crate::mgr::Mgr; struct Opt; @@ -12,7 +12,7 @@ impl From<()> for Opt { fn from(_: ()) -> Self { Self } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn unyank(&mut self, _: Opt) { let repeek = self.hovered().is_some_and(|f| f.is_dir() && self.yanked.contains_in(&f.url)); diff --git a/yazi-core/src/manager/commands/update_files.rs b/yazi-core/src/mgr/commands/update_files.rs similarity index 90% rename from yazi-core/src/manager/commands/update_files.rs rename to yazi-core/src/mgr/commands/update_files.rs index 0be74d12..8fe74bbd 100644 --- a/yazi-core/src/manager/commands/update_files.rs +++ b/yazi-core/src/mgr/commands/update_files.rs @@ -2,10 +2,10 @@ use std::borrow::Cow; use yazi_fs::FilesOp; use yazi_macro::render; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::event::CmdCow; -use crate::{manager::{LINKED, Manager}, tab::{Folder, Tab}, tasks::Tasks}; +use crate::{mgr::{LINKED, Mgr}, tab::{Folder, Tab}, tasks::Tasks}; pub struct Opt { op: FilesOp, @@ -19,7 +19,7 @@ impl TryFrom for Opt { } } -impl Manager { +impl Mgr { pub fn update_files(&mut self, opt: impl TryInto, tasks: &Tasks) { let Ok(opt) = opt.try_into() else { return; @@ -79,8 +79,8 @@ impl Manager { return; } - ManagerProxy::hover(None, tab.id); // Re-hover in next loop - ManagerProxy::update_paged(); // Update for paged files in next loop + MgrProxy::hover(None, tab.id); // Re-hover in next loop + MgrProxy::update_paged(); // Update for paged files in next loop if calc { tasks.prework_sorted(&tab.current.files); } @@ -96,7 +96,7 @@ impl Manager { } if !foreign { - ManagerProxy::peek(true); + MgrProxy::peek(true); } } diff --git a/yazi-core/src/manager/commands/update_mimes.rs b/yazi-core/src/mgr/commands/update_mimes.rs similarity index 95% rename from yazi-core/src/manager/commands/update_mimes.rs rename to yazi-core/src/mgr/commands/update_mimes.rs index f3180a44..31103342 100644 --- a/yazi-core/src/manager/commands/update_mimes.rs +++ b/yazi-core/src/mgr/commands/update_mimes.rs @@ -4,7 +4,7 @@ use tracing::error; use yazi_macro::render; use yazi_shared::{event::CmdCow, url::Url}; -use crate::{manager::{LINKED, Manager}, tasks::Tasks}; +use crate::{mgr::{LINKED, Mgr}, tasks::Tasks}; pub struct Opt { updates: HashMap, String>, @@ -18,7 +18,7 @@ impl TryFrom for Opt { } } -impl Manager { +impl Mgr { pub fn update_mimes(&mut self, opt: impl TryInto, tasks: &Tasks) { let Ok(opt) = opt.try_into() else { return error!("invalid arguments for update_mimes"); diff --git a/yazi-core/src/manager/commands/update_paged.rs b/yazi-core/src/mgr/commands/update_paged.rs similarity index 92% rename from yazi-core/src/manager/commands/update_paged.rs rename to yazi-core/src/mgr/commands/update_paged.rs index b679c9d6..4f0346dc 100644 --- a/yazi-core/src/manager/commands/update_paged.rs +++ b/yazi-core/src/mgr/commands/update_paged.rs @@ -1,6 +1,6 @@ use yazi_shared::{event::{CmdCow, Data}, url::Url}; -use crate::{manager::Manager, tasks::Tasks}; +use crate::{mgr::Mgr, tasks::Tasks}; #[derive(Default)] pub struct Opt { @@ -18,7 +18,7 @@ impl From<()> for Opt { fn from(_: ()) -> Self { Self::default() } } -impl Manager { +impl Mgr { pub fn update_paged(&mut self, opt: impl TryInto, tasks: &Tasks) { let Ok(opt) = opt.try_into() else { return; diff --git a/yazi-core/src/manager/commands/update_tasks.rs b/yazi-core/src/mgr/commands/update_tasks.rs similarity index 90% rename from yazi-core/src/manager/commands/update_tasks.rs rename to yazi-core/src/mgr/commands/update_tasks.rs index 9bc48598..e32e4757 100644 --- a/yazi-core/src/manager/commands/update_tasks.rs +++ b/yazi-core/src/mgr/commands/update_tasks.rs @@ -1,6 +1,6 @@ use yazi_shared::{event::CmdCow, url::Url}; -use crate::manager::Manager; +use crate::mgr::Mgr; pub struct Opt { urls: Vec, @@ -14,7 +14,7 @@ impl TryFrom for Opt { } } -impl Manager { +impl Mgr { pub fn update_tasks(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { return; diff --git a/yazi-core/src/manager/commands/update_yanked.rs b/yazi-core/src/mgr/commands/update_yanked.rs similarity index 92% rename from yazi-core/src/manager/commands/update_yanked.rs rename to yazi-core/src/mgr/commands/update_yanked.rs index ca2fcde9..09488d29 100644 --- a/yazi-core/src/manager/commands/update_yanked.rs +++ b/yazi-core/src/mgr/commands/update_yanked.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use yazi_macro::render; use yazi_shared::{event::CmdCow, url::Url}; -use crate::manager::{Manager, Yanked}; +use crate::mgr::{Mgr, Yanked}; #[derive(Default)] pub struct Opt { @@ -23,7 +23,7 @@ impl TryFrom for Opt { } } -impl Manager { +impl Mgr { pub fn update_yanked(&mut self, opt: impl TryInto) { let Ok(opt) = opt.try_into() else { return }; diff --git a/yazi-core/src/manager/commands/yank.rs b/yazi-core/src/mgr/commands/yank.rs similarity index 89% rename from yazi-core/src/manager/commands/yank.rs rename to yazi-core/src/mgr/commands/yank.rs index f9dc2b01..de5af15e 100644 --- a/yazi-core/src/manager/commands/yank.rs +++ b/yazi-core/src/mgr/commands/yank.rs @@ -1,7 +1,7 @@ use yazi_macro::render; use yazi_shared::event::CmdCow; -use crate::manager::{Manager, Yanked}; +use crate::mgr::{Mgr, Yanked}; struct Opt { cut: bool, @@ -11,7 +11,7 @@ impl From for Opt { fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } } } -impl Manager { +impl Mgr { #[yazi_codegen::command] pub fn yank(&mut self, opt: Opt) { if !self.active_mut().try_escape_visual() { diff --git a/yazi-core/src/manager/linked.rs b/yazi-core/src/mgr/linked.rs similarity index 100% rename from yazi-core/src/manager/linked.rs rename to yazi-core/src/mgr/linked.rs diff --git a/yazi-core/src/manager/manager.rs b/yazi-core/src/mgr/mgr.rs similarity index 97% rename from yazi-core/src/manager/manager.rs rename to yazi-core/src/mgr/mgr.rs index da5b7179..bd415165 100644 --- a/yazi-core/src/manager/manager.rs +++ b/yazi-core/src/mgr/mgr.rs @@ -7,7 +7,7 @@ use yazi_shared::{Id, url::Url}; use super::{Mimetype, Tabs, Watcher, Yanked}; use crate::tab::{Folder, Tab}; -pub struct Manager { +pub struct Mgr { pub tabs: Tabs, pub yanked: Yanked, @@ -15,7 +15,7 @@ pub struct Manager { pub mimetype: Mimetype, } -impl Manager { +impl Mgr { pub fn make() -> Self { Self { tabs: Tabs::make(), @@ -37,7 +37,7 @@ impl Manager { pub fn shutdown(&mut self) { self.tabs.iter_mut().for_each(|t| t.shutdown()); } } -impl Manager { +impl Mgr { #[inline] pub fn cwd(&self) -> &Url { self.active().cwd() } diff --git a/yazi-core/src/manager/mimetype.rs b/yazi-core/src/mgr/mimetype.rs similarity index 100% rename from yazi-core/src/manager/mimetype.rs rename to yazi-core/src/mgr/mimetype.rs diff --git a/yazi-core/src/mgr/mod.rs b/yazi-core/src/mgr/mod.rs new file mode 100644 index 00000000..87fbda62 --- /dev/null +++ b/yazi-core/src/mgr/mod.rs @@ -0,0 +1,3 @@ +yazi_macro::mod_pub!(commands); + +yazi_macro::mod_flat!(linked mgr mimetype tabs watcher yanked); diff --git a/yazi-core/src/manager/tabs.rs b/yazi-core/src/mgr/tabs.rs similarity index 96% rename from yazi-core/src/manager/tabs.rs rename to yazi-core/src/mgr/tabs.rs index 0a32ff18..5e9e4875 100644 --- a/yazi-core/src/manager/tabs.rs +++ b/yazi-core/src/mgr/tabs.rs @@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut}; use yazi_boot::BOOT; use yazi_dds::Pubsub; use yazi_fs::File; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::{Id, url::Url}; use crate::tab::{Folder, Tab}; @@ -44,8 +44,8 @@ impl Tabs { } self.cursor = idx; - ManagerProxy::refresh(); - ManagerProxy::peek(true); + MgrProxy::refresh(); + MgrProxy::peek(true); Pubsub::pub_from_tab(self.active().id); } } diff --git a/yazi-core/src/manager/watcher.rs b/yazi-core/src/mgr/watcher.rs similarity index 100% rename from yazi-core/src/manager/watcher.rs rename to yazi-core/src/mgr/watcher.rs diff --git a/yazi-core/src/manager/yanked.rs b/yazi-core/src/mgr/yanked.rs similarity index 100% rename from yazi-core/src/manager/yanked.rs rename to yazi-core/src/mgr/yanked.rs diff --git a/yazi-core/src/spot/commands/arrow.rs b/yazi-core/src/spot/commands/arrow.rs index be704ade..0223d4b8 100644 --- a/yazi-core/src/spot/commands/arrow.rs +++ b/yazi-core/src/spot/commands/arrow.rs @@ -1,5 +1,5 @@ use yazi_macro::render; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::event::{CmdCow, Data}; use crate::spot::Spot; @@ -19,7 +19,7 @@ impl Spot { let Some(old) = lock.selected() else { let new = self.skip.saturating_add_signed(opt.step); - return ManagerProxy::spot(Some(new)); + return MgrProxy::spot(Some(new)); }; lock.select(Some(old.saturating_add_signed(opt.step))); diff --git a/yazi-core/src/spot/commands/swipe.rs b/yazi-core/src/spot/commands/swipe.rs index f956cb38..2e9069f5 100644 --- a/yazi-core/src/spot/commands/swipe.rs +++ b/yazi-core/src/spot/commands/swipe.rs @@ -1,4 +1,4 @@ -use yazi_proxy::{ManagerProxy, TabProxy}; +use yazi_proxy::{MgrProxy, TabProxy}; use yazi_shared::event::{CmdCow, Data}; use crate::spot::Spot; @@ -15,6 +15,6 @@ impl Spot { #[yazi_codegen::command] pub fn swipe(&mut self, opt: Opt) { TabProxy::arrow(opt.step); - ManagerProxy::spot(None); + MgrProxy::spot(None); } } diff --git a/yazi-core/src/tab/commands/arrow.rs b/yazi-core/src/tab/commands/arrow.rs index 0a855a78..e11b52a4 100644 --- a/yazi-core/src/tab/commands/arrow.rs +++ b/yazi-core/src/tab/commands/arrow.rs @@ -1,6 +1,6 @@ use yazi_fs::Step; use yazi_macro::render; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::event::CmdCow; use crate::tab::Tab; @@ -48,7 +48,7 @@ See #2294 for more details: https://github.com/sxyazi/yazi/pull/2294", } } - ManagerProxy::hover(None, self.id); + MgrProxy::hover(None, self.id); render!(); } } diff --git a/yazi-core/src/tab/commands/cd.rs b/yazi-core/src/tab/commands/cd.rs index bec41bb5..6268244c 100644 --- a/yazi-core/src/tab/commands/cd.rs +++ b/yazi-core/src/tab/commands/cd.rs @@ -6,7 +6,7 @@ use yazi_config::popup::InputCfg; use yazi_dds::Pubsub; use yazi_fs::expand_path; use yazi_macro::render; -use yazi_proxy::{CompletionProxy, InputProxy, ManagerProxy, TabProxy}; +use yazi_proxy::{CompletionProxy, InputProxy, MgrProxy, TabProxy}; use yazi_shared::{Debounce, errors::InputError, event::CmdCow, url::Url}; use crate::tab::Tab; @@ -72,7 +72,7 @@ impl Tab { } Pubsub::pub_from_cd(self.id, self.cwd()); - ManagerProxy::refresh(); + MgrProxy::refresh(); render!(); } diff --git a/yazi-core/src/tab/commands/escape.rs b/yazi-core/src/tab/commands/escape.rs index c84672e1..e8b30569 100644 --- a/yazi-core/src/tab/commands/escape.rs +++ b/yazi-core/src/tab/commands/escape.rs @@ -1,6 +1,6 @@ use bitflags::bitflags; use yazi_macro::{render, render_and}; -use yazi_proxy::{AppProxy, ManagerProxy}; +use yazi_proxy::{AppProxy, MgrProxy}; use yazi_shared::event::CmdCow; use crate::tab::Tab; @@ -87,7 +87,7 @@ impl Tab { self.selected.clear(); if self.hovered().is_some_and(|h| h.is_dir()) { - ManagerProxy::peek(true); + MgrProxy::peek(true); } render_and!(true) } diff --git a/yazi-core/src/tab/commands/filter.rs b/yazi-core/src/tab/commands/filter.rs index 9fa2027b..3768a48c 100644 --- a/yazi-core/src/tab/commands/filter.rs +++ b/yazi-core/src/tab/commands/filter.rs @@ -45,7 +45,7 @@ impl Tab { .with_bool("smart", opt.case == FilterCase::Smart) .with_bool("insensitive", opt.case == FilterCase::Insensitive) .with_bool("done", done), - Layer::Manager + Layer::Mgr )); } }); diff --git a/yazi-core/src/tab/commands/filter_do.rs b/yazi-core/src/tab/commands/filter_do.rs index d8065776..ae651002 100644 --- a/yazi-core/src/tab/commands/filter_do.rs +++ b/yazi-core/src/tab/commands/filter_do.rs @@ -1,6 +1,6 @@ use yazi_fs::Filter; use yazi_macro::render; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use super::filter::Opt; use crate::tab::Tab; @@ -17,7 +17,7 @@ impl Tab { }; if opt.done { - ManagerProxy::update_paged(); // Update for paged files in next loop + MgrProxy::update_paged(); // Update for paged files in next loop } let hovered = self.hovered().map(|f| f.urn_owned()); @@ -27,7 +27,7 @@ impl Tab { self.current.repos(hovered.as_ref()); if self.hovered().map(|f| f.urn()) != hovered.as_ref().map(|u| u.as_urn()) { - ManagerProxy::hover(None, self.id); + MgrProxy::hover(None, self.id); } render!(); diff --git a/yazi-core/src/tab/commands/find.rs b/yazi-core/src/tab/commands/find.rs index 2c6d82e8..b247699d 100644 --- a/yazi-core/src/tab/commands/find.rs +++ b/yazi-core/src/tab/commands/find.rs @@ -37,7 +37,7 @@ impl Tab { .with_bool("previous", opt.prev) .with_bool("smart", opt.case == FilterCase::Smart) .with_bool("insensitive", opt.case == FilterCase::Insensitive), - Layer::Manager + Layer::Mgr )); } }); diff --git a/yazi-core/src/tab/commands/hidden.rs b/yazi-core/src/tab/commands/hidden.rs index ea9630c2..2ed6ed13 100644 --- a/yazi-core/src/tab/commands/hidden.rs +++ b/yazi-core/src/tab/commands/hidden.rs @@ -1,4 +1,4 @@ -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::event::CmdCow; use crate::tab::Tab; @@ -15,10 +15,10 @@ impl Tab { self.apply_files_attrs(); if hovered.as_ref() != self.hovered().map(|f| &f.url) { - ManagerProxy::hover(hovered, self.id); + MgrProxy::hover(hovered, self.id); } else if self.hovered().is_some_and(|f| f.is_dir()) { - ManagerProxy::peek(true); + MgrProxy::peek(true); } - ManagerProxy::update_paged(); + MgrProxy::update_paged(); } } diff --git a/yazi-core/src/tab/commands/reveal.rs b/yazi-core/src/tab/commands/reveal.rs index a49d2199..4c702940 100644 --- a/yazi-core/src/tab/commands/reveal.rs +++ b/yazi-core/src/tab/commands/reveal.rs @@ -1,5 +1,5 @@ use yazi_fs::{File, FilesOp, expand_path}; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::{event::CmdCow, url::Url}; use crate::tab::Tab; @@ -31,6 +31,6 @@ impl Tab { self.cd(parent.clone()); FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]).emit(); - ManagerProxy::hover(Some(opt.target), self.id); + MgrProxy::hover(Some(opt.target), self.id); } } diff --git a/yazi-core/src/tab/commands/search.rs b/yazi-core/src/tab/commands/search.rs index c09d3f76..d93f5dea 100644 --- a/yazi-core/src/tab/commands/search.rs +++ b/yazi-core/src/tab/commands/search.rs @@ -7,7 +7,7 @@ use tracing::error; use yazi_config::popup::InputCfg; use yazi_fs::{Cha, FilesOp}; use yazi_plugin::external; -use yazi_proxy::{AppProxy, InputProxy, ManagerProxy, TabProxy, options::{SearchOpt, SearchOptVia}}; +use yazi_proxy::{AppProxy, InputProxy, MgrProxy, TabProxy, options::{SearchOpt, SearchOptVia}}; use crate::tab::Tab; @@ -91,7 +91,7 @@ impl Tab { if self.cwd().is_search() { let rep = self.history.remove_or(&self.cwd().to_regular()); drop(mem::replace(&mut self.current, rep)); - ManagerProxy::refresh(); + MgrProxy::refresh(); } } } diff --git a/yazi-core/src/tab/commands/sort.rs b/yazi-core/src/tab/commands/sort.rs index 15c1aa07..6f5ddce2 100644 --- a/yazi-core/src/tab/commands/sort.rs +++ b/yazi-core/src/tab/commands/sort.rs @@ -1,7 +1,7 @@ use std::str::FromStr; use yazi_fs::SortBy; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::event::CmdCow; use crate::{tab::Tab, tasks::Tasks}; @@ -20,8 +20,8 @@ impl Tab { self.apply_files_attrs(); - ManagerProxy::hover(None, self.id); - ManagerProxy::update_paged(); + MgrProxy::hover(None, self.id); + MgrProxy::update_paged(); tasks.prework_sorted(&self.current.files); } diff --git a/yazi-core/src/tab/folder.rs b/yazi-core/src/tab/folder.rs index c7745169..b7aa287a 100644 --- a/yazi-core/src/tab/folder.rs +++ b/yazi-core/src/tab/folder.rs @@ -1,9 +1,9 @@ use std::mem; -use yazi_config::{LAYOUT, MANAGER}; +use yazi_config::{LAYOUT, MGR}; use yazi_dds::Pubsub; use yazi_fs::{Cha, File, Files, FilesOp, FolderStage, Step}; -use yazi_proxy::ManagerProxy; +use yazi_proxy::MgrProxy; use yazi_shared::{Id, url::{Url, Urn, UrnBuf}}; pub struct Folder { @@ -24,7 +24,7 @@ impl Default for Folder { Self { url: Default::default(), cha: Default::default(), - files: Files::new(MANAGER.show_hidden), + files: Files::new(MGR.show_hidden), stage: Default::default(), offset: Default::default(), cursor: Default::default(), @@ -131,7 +131,7 @@ impl Folder { let new = self.cursor / limit; if mem::replace(&mut self.page, new) != new || force { - ManagerProxy::update_paged_by(new, &self.url); + MgrProxy::update_paged_by(new, &self.url); } } @@ -140,7 +140,7 @@ impl Folder { let len = self.files.len(); let limit = LAYOUT.get().current.height as usize; - let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize); + let scrolloff = (limit / 2).min(MGR.scrolloff as usize); self.cursor = step.add(self.cursor, limit).min(len.saturating_sub(1)); self.offset = if self.cursor < (self.offset + limit).min(len).saturating_sub(scrolloff) { @@ -157,7 +157,7 @@ impl Folder { let max = self.files.len().saturating_sub(1); let limit = LAYOUT.get().current.height as usize; - let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize); + let scrolloff = (limit / 2).min(MGR.scrolloff as usize); self.cursor = step.add(self.cursor, limit).min(max); self.offset = if self.cursor < self.offset + scrolloff { @@ -174,7 +174,7 @@ impl Folder { let len = self.files.len(); let limit = LAYOUT.get().current.height as usize; - let scrolloff = (limit / 2).min(MANAGER.scrolloff as usize); + let scrolloff = (limit / 2).min(MGR.scrolloff as usize); self.offset = if self.cursor < (self.offset + limit).min(len).saturating_sub(scrolloff) { len.saturating_sub(limit).min(self.offset) diff --git a/yazi-core/src/tab/preference.rs b/yazi-core/src/tab/preference.rs index 828d65a3..d5e3241c 100644 --- a/yazi-core/src/tab/preference.rs +++ b/yazi-core/src/tab/preference.rs @@ -1,4 +1,4 @@ -use yazi_config::MANAGER; +use yazi_config::MGR; use yazi_fs::{FilesSorter, SortBy}; #[derive(Clone, PartialEq)] @@ -19,15 +19,15 @@ impl Default for Preference { fn default() -> Self { Self { // Sorting - sort_by: MANAGER.sort_by, - sort_sensitive: MANAGER.sort_sensitive, - sort_reverse: MANAGER.sort_reverse, - sort_dir_first: MANAGER.sort_dir_first, - sort_translit: MANAGER.sort_translit, + sort_by: MGR.sort_by, + sort_sensitive: MGR.sort_sensitive, + sort_reverse: MGR.sort_reverse, + sort_dir_first: MGR.sort_dir_first, + sort_translit: MGR.sort_translit, // Display - linemode: MANAGER.linemode.to_owned(), - show_hidden: MANAGER.show_hidden, + linemode: MGR.linemode.to_owned(), + show_hidden: MGR.show_hidden, } } } diff --git a/yazi-core/src/tasks/preload.rs b/yazi-core/src/tasks/preload.rs index f5bf79d5..e39d4519 100644 --- a/yazi-core/src/tasks/preload.rs +++ b/yazi-core/src/tasks/preload.rs @@ -2,7 +2,7 @@ use yazi_config::{PLUGIN, plugin::MAX_PREWORKERS}; use yazi_fs::{File, Files, SortBy}; use super::Tasks; -use crate::manager::Mimetype; +use crate::mgr::Mimetype; impl Tasks { pub fn fetch_paged(&self, paged: &[File], mimetype: &Mimetype) { diff --git a/yazi-fm/src/app/commands/mouse.rs b/yazi-fm/src/app/commands/mouse.rs index 4ef4dabc..56836898 100644 --- a/yazi-fm/src/app/commands/mouse.rs +++ b/yazi-fm/src/app/commands/mouse.rs @@ -1,7 +1,7 @@ use crossterm::event::{MouseEvent, MouseEventKind}; use mlua::{ObjectLike, Table}; use tracing::error; -use yazi_config::MANAGER; +use yazi_config::MGR; use yazi_plugin::LUA; use crate::{app::App, lives::Lives}; @@ -24,7 +24,7 @@ impl App { let area = yazi_plugin::elements::Rect::from(size); let root = LUA.globals().raw_get::("Root")?.call_method::
("new", area)?; - if matches!(event.kind, MouseEventKind::Down(_) if MANAGER.mouse_events.draggable()) { + if matches!(event.kind, MouseEventKind::Down(_) if MGR.mouse_events.draggable()) { root.raw_set("_drag_start", event)?; } diff --git a/yazi-fm/src/app/commands/quit.rs b/yazi-fm/src/app/commands/quit.rs index 9d5224c8..9b725a50 100644 --- a/yazi-fm/src/app/commands/quit.rs +++ b/yazi-fm/src/app/commands/quit.rs @@ -8,7 +8,7 @@ use crate::{Term, app::App}; impl App { pub(crate) fn quit(&mut self, opt: EventQuit) -> ! { self.cx.tasks.shutdown(); - self.cx.manager.shutdown(); + self.cx.mgr.shutdown(); futures::executor::block_on(yazi_dds::shutdown()); futures::executor::block_on(yazi_dds::STATE.drain()).ok(); @@ -24,7 +24,7 @@ impl App { fn cwd_to_file(&self) { if let Some(p) = &ARGS.cwd_file { - let cwd = self.cx.manager.cwd().as_os_str(); + let cwd = self.cx.mgr.cwd().as_os_str(); std::fs::write(p, cwd.as_encoded_bytes()).ok(); } } diff --git a/yazi-fm/src/app/commands/render.rs b/yazi-fm/src/app/commands/render.rs index cfd30c30..1361a4ae 100644 --- a/yazi-fm/src/app/commands/render.rs +++ b/yazi-fm/src/app/commands/render.rs @@ -36,7 +36,7 @@ impl App { // Reload preview if collision is resolved if collision && !COLLISION.load(Ordering::Relaxed) { - self.cx.manager.peek(true); + self.cx.mgr.peek(true); } } diff --git a/yazi-fm/src/app/commands/resize.rs b/yazi-fm/src/app/commands/resize.rs index cb96e81d..34ba34f6 100644 --- a/yazi-fm/src/app/commands/resize.rs +++ b/yazi-fm/src/app/commands/resize.rs @@ -19,7 +19,7 @@ impl App { self.reflow(()); self.cx.current_mut().sync_page(true); - self.cx.manager.hover(None); - self.cx.manager.parent_mut().map(|f| f.arrow(0)); + self.cx.mgr.hover(None); + self.cx.mgr.parent_mut().map(|f| f.arrow(0)); } } diff --git a/yazi-fm/src/completion/completion.rs b/yazi-fm/src/completion/completion.rs index c6b191cf..5b1890d3 100644 --- a/yazi-fm/src/completion/completion.rs +++ b/yazi-fm/src/completion/completion.rs @@ -40,7 +40,7 @@ impl Widget for Completion<'_> { }) .collect(); - let input_area = self.cx.manager.area(self.cx.input.position); + let input_area = self.cx.mgr.area(self.cx.input.position); let mut area = Position::sticky(Dimension::available(), input_area, Offset { x: 1, y: 0, diff --git a/yazi-fm/src/confirm/confirm.rs b/yazi-fm/src/confirm/confirm.rs index 1b195fc1..7ea09bc5 100644 --- a/yazi-fm/src/confirm/confirm.rs +++ b/yazi-fm/src/confirm/confirm.rs @@ -14,7 +14,7 @@ impl<'a> Confirm<'a> { impl Widget for Confirm<'_> { fn render(self, _: Rect, buf: &mut Buffer) { let confirm = &self.cx.confirm; - let area = self.cx.manager.area(confirm.position); + let area = self.cx.mgr.area(confirm.position); yazi_plugin::elements::Clear::default().render(area, buf); diff --git a/yazi-fm/src/context.rs b/yazi-fm/src/context.rs index f68997a6..f2683816 100644 --- a/yazi-fm/src/context.rs +++ b/yazi-fm/src/context.rs @@ -1,9 +1,9 @@ use ratatui::layout::Rect; -use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, manager::Manager, notify::Notify, pick::Pick, tab::{Folder, Tab}, tasks::Tasks, which::Which}; +use yazi_core::{completion::Completion, confirm::Confirm, help::Help, input::Input, mgr::Mgr, notify::Notify, pick::Pick, tab::{Folder, Tab}, tasks::Tasks, which::Which}; use yazi_shared::Layer; pub struct Ctx { - pub manager: Manager, + pub mgr: Mgr, pub tasks: Tasks, pub pick: Pick, pub input: Input, @@ -17,7 +17,7 @@ pub struct Ctx { impl Ctx { pub fn make() -> Self { Self { - manager: Manager::make(), + mgr: Mgr::make(), tasks: Tasks::serve(), pick: Default::default(), input: Default::default(), @@ -32,7 +32,7 @@ impl Ctx { #[inline] pub fn cursor(&self) -> Option<(u16, u16)> { if self.input.visible { - let Rect { x, y, .. } = self.manager.area(self.input.position); + let Rect { x, y, .. } = self.mgr.area(self.input.position); return Some((x + 1 + self.input.cursor(), y + 1)); } if let Some((x, y)) = self.help.cursor() { @@ -60,21 +60,21 @@ impl Ctx { } else if self.tasks.visible { Layer::Tasks } else { - Layer::Manager + Layer::Mgr } } } impl Ctx { #[inline] - pub fn active(&self) -> &Tab { self.manager.active() } + pub fn active(&self) -> &Tab { self.mgr.active() } #[inline] - pub fn active_mut(&mut self) -> &mut Tab { self.manager.active_mut() } + pub fn active_mut(&mut self) -> &mut Tab { self.mgr.active_mut() } #[inline] - pub fn current(&self) -> &Folder { self.manager.current() } + pub fn current(&self) -> &Folder { self.mgr.current() } #[inline] - pub fn current_mut(&mut self) -> &mut Folder { self.manager.current_mut() } + pub fn current_mut(&mut self) -> &mut Folder { self.mgr.current_mut() } } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index 769a4409..758711a5 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -15,7 +15,7 @@ impl<'a> Executor<'a> { pub(super) fn execute(&mut self, cmd: CmdCow, layer: Layer) { match layer { Layer::App => self.app(cmd), - Layer::Manager => self.manager(cmd), + Layer::Mgr => self.mgr(cmd), Layer::Tasks => self.tasks(cmd), Layer::Spot => self.spot(cmd), Layer::Pick => self.pick(cmd), @@ -47,44 +47,44 @@ impl<'a> Executor<'a> { on!(resume); } - fn manager(&mut self, cmd: CmdCow) { + fn mgr(&mut self, cmd: CmdCow) { macro_rules! on { - (MANAGER, $name:ident $(,$args:expr)*) => { + (MGR, $name:ident $(,$args:expr)*) => { if cmd.name == stringify!($name) { - return self.app.cx.manager.$name(cmd, $($args),*); + return self.app.cx.mgr.$name(cmd, $($args),*); } }; (ACTIVE, $name:ident $(,$args:expr)*) => { if cmd.name == stringify!($name) { return if let Some(tab) = cmd.get("tab") { let Some(id) = tab.as_id() else { return }; - let Some(tab) = self.app.cx.manager.tabs.find_mut(id) else { return }; + let Some(tab) = self.app.cx.mgr.tabs.find_mut(id) else { return }; tab.$name(cmd, $($args),*) } else { - self.app.cx.manager.active_mut().$name(cmd, $($args),*) + self.app.cx.mgr.active_mut().$name(cmd, $($args),*) }; } }; (TABS, $name:ident) => { if cmd.name == concat!("tab_", stringify!($name)) { - return self.app.cx.manager.tabs.$name(cmd); + return self.app.cx.mgr.tabs.$name(cmd); } }; } - on!(MANAGER, update_tasks); - on!(MANAGER, update_files, &self.app.cx.tasks); - on!(MANAGER, update_mimes, &self.app.cx.tasks); - on!(MANAGER, update_paged, &self.app.cx.tasks); - on!(MANAGER, update_yanked); - on!(MANAGER, hover); - on!(MANAGER, peek); - on!(MANAGER, seek); - on!(MANAGER, spot); - on!(MANAGER, refresh, &self.app.cx.tasks); - on!(MANAGER, quit, &self.app.cx.tasks); - on!(MANAGER, close, &self.app.cx.tasks); - on!(MANAGER, suspend); + on!(MGR, update_tasks); + on!(MGR, update_files, &self.app.cx.tasks); + on!(MGR, update_mimes, &self.app.cx.tasks); + on!(MGR, update_paged, &self.app.cx.tasks); + on!(MGR, update_yanked); + on!(MGR, hover); + on!(MGR, peek); + on!(MGR, seek); + on!(MGR, spot); + on!(MGR, refresh, &self.app.cx.tasks); + on!(MGR, quit, &self.app.cx.tasks); + on!(MGR, close, &self.app.cx.tasks); + on!(MGR, suspend); on!(ACTIVE, escape); on!(ACTIVE, update_peeked); on!(ACTIVE, update_spotted); @@ -104,17 +104,17 @@ impl<'a> Executor<'a> { on!(ACTIVE, visual_mode); // Operation - on!(MANAGER, open, &self.app.cx.tasks); - on!(MANAGER, open_do, &self.app.cx.tasks); - on!(MANAGER, yank); - on!(MANAGER, unyank); - on!(MANAGER, paste, &self.app.cx.tasks); - on!(MANAGER, link, &self.app.cx.tasks); - on!(MANAGER, hardlink, &self.app.cx.tasks); - on!(MANAGER, remove, &self.app.cx.tasks); - on!(MANAGER, remove_do, &self.app.cx.tasks); - on!(MANAGER, create); - on!(MANAGER, rename); + on!(MGR, open, &self.app.cx.tasks); + on!(MGR, open_do, &self.app.cx.tasks); + on!(MGR, yank); + on!(MGR, unyank); + on!(MGR, paste, &self.app.cx.tasks); + on!(MGR, link, &self.app.cx.tasks); + on!(MGR, hardlink, &self.app.cx.tasks); + on!(MGR, remove, &self.app.cx.tasks); + on!(MGR, remove_do, &self.app.cx.tasks); + on!(MGR, create); + on!(MGR, rename); on!(ACTIVE, copy); on!(ACTIVE, shell); on!(ACTIVE, hidden); @@ -144,7 +144,7 @@ impl<'a> Executor<'a> { // Tasks "tasks_show" => self.app.cx.tasks.toggle(()), // Help - "help" => self.app.cx.help.toggle(Layer::Manager), + "help" => self.app.cx.help.toggle(Layer::Mgr), // Plugin "plugin" => self.app.plugin(cmd), _ => {} @@ -293,7 +293,7 @@ impl<'a> Executor<'a> { }; } - on!(arrow, &self.app.cx.manager); + on!(arrow, &self.app.cx.mgr); on!(show); on!(close); } diff --git a/yazi-fm/src/input/input.rs b/yazi-fm/src/input/input.rs index 1174e7ab..cb27e8f3 100644 --- a/yazi-fm/src/input/input.rs +++ b/yazi-fm/src/input/input.rs @@ -34,7 +34,7 @@ impl<'a> Input<'a> { impl Widget for Input<'_> { fn render(self, win: Rect, buf: &mut Buffer) { let input = &self.cx.input; - let area = self.cx.manager.area(input.position); + let area = self.cx.mgr.area(input.position); yazi_plugin::elements::Clear::default().render(area, buf); Paragraph::new(self.highlighted_value().unwrap_or_else(|_| Line::from(input.value()))) diff --git a/yazi-fm/src/lives/context.rs b/yazi-fm/src/lives/context.rs index 59c6e462..0c13d2a9 100644 --- a/yazi-fm/src/lives/context.rs +++ b/yazi-fm/src/lives/context.rs @@ -26,9 +26,9 @@ impl UserData for Ctx { methods.add_meta_method(MetaMethod::Index, |lua, me, key: mlua::String| { match key.as_bytes().as_ref() { b"active" => super::Tab::make(me.active())?, - b"tabs" => super::Tabs::make(&me.manager.tabs)?, + b"tabs" => super::Tabs::make(&me.mgr.tabs)?, b"tasks" => super::Tasks::make(&me.tasks)?, - b"yanked" => super::Yanked::make(&me.manager.yanked)?, + b"yanked" => super::Yanked::make(&me.mgr.yanked)?, b"layer" => return yazi_plugin::bindings::Layer::from(me.layer()).into_lua(lua), _ => return Ok(Value::Nil), } diff --git a/yazi-fm/src/lives/file.rs b/yazi-fm/src/lives/file.rs index 0dcdef66..a99039e6 100644 --- a/yazi-fm/src/lives/file.rs +++ b/yazi-fm/src/lives/file.rs @@ -55,7 +55,7 @@ impl UserData for File { }); methods.add_method("mime", |lua, me, ()| { lua.named_registry_value::("cx")?.borrow_scoped(|cx: &Ctx| { - cx.manager.mimetype.by_url(&me.url).map(|s| lua.create_string(s)).transpose() + cx.mgr.mimetype.by_url(&me.url).map(|s| lua.create_string(s)).transpose() })? }); methods.add_method("prefix", |lua, me, ()| { @@ -69,16 +69,16 @@ impl UserData for File { }); methods.add_method("style", |lua, me, ()| { lua.named_registry_value::("cx")?.borrow_scoped(|cx: &Ctx| { - let mime = cx.manager.mimetype.by_file(me).unwrap_or_default(); + let mime = cx.mgr.mimetype.by_file(me).unwrap_or_default(); THEME.filetypes.iter().find(|&x| x.matches(me, mime)).map(|x| Style::from(x.style)) }) }); methods.add_method("is_hovered", |_, me, ()| Ok(me.idx == me.folder().cursor)); methods.add_method("is_yanked", |lua, me, ()| { lua.named_registry_value::("cx")?.borrow_scoped(|cx: &Ctx| { - if !cx.manager.yanked.contains(&me.url) { + if !cx.mgr.yanked.contains(&me.url) { 0u8 - } else if cx.manager.yanked.cut { + } else if cx.mgr.yanked.cut { 2u8 } else { 1u8 diff --git a/yazi-fm/src/lives/tabs.rs b/yazi-fm/src/lives/tabs.rs index dc3a2b66..4bbf576e 100644 --- a/yazi-fm/src/lives/tabs.rs +++ b/yazi-fm/src/lives/tabs.rs @@ -5,18 +5,18 @@ use mlua::{AnyUserData, MetaMethod, UserData, UserDataFields, UserDataMethods}; use super::{Lives, Tab}; pub(super) struct Tabs { - inner: *const yazi_core::manager::Tabs, + inner: *const yazi_core::mgr::Tabs, } impl Deref for Tabs { - type Target = yazi_core::manager::Tabs; + type Target = yazi_core::mgr::Tabs; fn deref(&self) -> &Self::Target { unsafe { &*self.inner } } } impl Tabs { #[inline] - pub(super) fn make(inner: &yazi_core::manager::Tabs) -> mlua::Result { + pub(super) fn make(inner: &yazi_core::mgr::Tabs) -> mlua::Result { Lives::scoped_userdata(Self { inner }) } } diff --git a/yazi-fm/src/lives/yanked.rs b/yazi-fm/src/lives/yanked.rs index b5bd1f9c..ab37d779 100644 --- a/yazi-fm/src/lives/yanked.rs +++ b/yazi-fm/src/lives/yanked.rs @@ -6,23 +6,23 @@ use yazi_plugin::url::Url; use super::{Iter, Lives}; pub(super) struct Yanked { - inner: *const yazi_core::manager::Yanked, + inner: *const yazi_core::mgr::Yanked, } impl Deref for Yanked { - type Target = yazi_core::manager::Yanked; + type Target = yazi_core::mgr::Yanked; fn deref(&self) -> &Self::Target { self.inner() } } impl Yanked { #[inline] - pub(super) fn make(inner: &yazi_core::manager::Yanked) -> mlua::Result { + pub(super) fn make(inner: &yazi_core::mgr::Yanked) -> mlua::Result { Lives::scoped_userdata(Self { inner }) } #[inline] - fn inner(&self) -> &'static yazi_core::manager::Yanked { unsafe { &*self.inner } } + fn inner(&self) -> &'static yazi_core::mgr::Yanked { unsafe { &*self.inner } } } impl UserData for Yanked { diff --git a/yazi-fm/src/main.rs b/yazi-fm/src/main.rs index 7e18e7ce..7cdd0f4a 100644 --- a/yazi-fm/src/main.rs +++ b/yazi-fm/src/main.rs @@ -4,7 +4,7 @@ #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; -yazi_macro::mod_pub!(app completion confirm help input lives manager notify pick spot tasks which); +yazi_macro::mod_pub!(app completion confirm help input lives mgr notify pick spot tasks which); yazi_macro::mod_flat!(context executor logs panic root router signals term); diff --git a/yazi-fm/src/manager/mod.rs b/yazi-fm/src/mgr/mod.rs similarity index 100% rename from yazi-fm/src/manager/mod.rs rename to yazi-fm/src/mgr/mod.rs diff --git a/yazi-fm/src/manager/modal.rs b/yazi-fm/src/mgr/modal.rs similarity index 96% rename from yazi-fm/src/manager/modal.rs rename to yazi-fm/src/mgr/modal.rs index 4ad52d0e..cfc32451 100644 --- a/yazi-fm/src/manager/modal.rs +++ b/yazi-fm/src/mgr/modal.rs @@ -20,7 +20,7 @@ impl Widget for Modal<'_> { let area = yazi_plugin::elements::Rect::from(area); let root = LUA.globals().raw_get::
("Modal")?.call_method::
("new", area)?; - render_once(root.call_method("children_redraw", ())?, buf, |p| self.cx.manager.area(p)); + render_once(root.call_method("children_redraw", ())?, buf, |p| self.cx.mgr.area(p)); Ok::<_, mlua::Error>(()) }; if let Err(e) = f() { diff --git a/yazi-fm/src/manager/preview.rs b/yazi-fm/src/mgr/preview.rs similarity index 89% rename from yazi-fm/src/manager/preview.rs rename to yazi-fm/src/mgr/preview.rs index b1ae5fcf..b5ce2666 100644 --- a/yazi-fm/src/manager/preview.rs +++ b/yazi-fm/src/mgr/preview.rs @@ -23,7 +23,7 @@ impl Widget for Preview<'_> { } for w in &lock.data { - w.clone().render(buf, |p| self.cx.manager.area(p)); + w.clone().render(buf, |p| self.cx.mgr.area(p)); } } } diff --git a/yazi-fm/src/pick/pick.rs b/yazi-fm/src/pick/pick.rs index 58947271..eda7e188 100644 --- a/yazi-fm/src/pick/pick.rs +++ b/yazi-fm/src/pick/pick.rs @@ -14,7 +14,7 @@ impl<'a> Pick<'a> { impl Widget for Pick<'_> { fn render(self, _: Rect, buf: &mut Buffer) { let pick = &self.cx.pick; - let area = self.cx.manager.area(pick.position); + let area = self.cx.mgr.area(pick.position); let items: Vec<_> = pick .window() diff --git a/yazi-fm/src/root.rs b/yazi-fm/src/root.rs index d997db9c..67d1aa5a 100644 --- a/yazi-fm/src/root.rs +++ b/yazi-fm/src/root.rs @@ -3,7 +3,7 @@ use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget}; use tracing::error; use yazi_plugin::{LUA, elements::render_once}; -use super::{completion, confirm, help, input, manager, pick, spot, tasks, which}; +use super::{completion, confirm, help, input, mgr, pick, spot, tasks, which}; use crate::Ctx; pub(super) struct Root<'a> { @@ -26,15 +26,15 @@ impl Widget for Root<'_> { let area = yazi_plugin::elements::Rect::from(area); let root = LUA.globals().raw_get::
("Root")?.call_method::
("new", area)?; - render_once(root.call_method("redraw", ())?, buf, |p| self.cx.manager.area(p)); + render_once(root.call_method("redraw", ())?, buf, |p| self.cx.mgr.area(p)); Ok::<_, mlua::Error>(()) }; if let Err(e) = f() { error!("Failed to redraw the `Root` component:\n{e}"); } - manager::Preview::new(self.cx).render(area, buf); - manager::Modal::new(self.cx).render(area, buf); + mgr::Preview::new(self.cx).render(area, buf); + mgr::Modal::new(self.cx).render(area, buf); if self.cx.tasks.visible { tasks::Tasks::new(self.cx).render(area, buf); diff --git a/yazi-fm/src/router.rs b/yazi-fm/src/router.rs index e337e97d..7a900537 100644 --- a/yazi-fm/src/router.rs +++ b/yazi-fm/src/router.rs @@ -27,7 +27,7 @@ impl<'a> Router<'a> { use Layer as L; match layer { L::App => unreachable!(), - L::Manager | L::Tasks | L::Spot | L::Pick | L::Input | L::Confirm | L::Help => { + L::Mgr | L::Tasks | L::Spot | L::Pick | L::Input | L::Confirm | L::Help => { self.matches(layer, key) } L::Completion => self.matches(L::Completion, key) || self.matches(L::Input, key), diff --git a/yazi-fm/src/signals.rs b/yazi-fm/src/signals.rs index 02d6b83f..3fc31579 100644 --- a/yazi-fm/src/signals.rs +++ b/yazi-fm/src/signals.rs @@ -2,7 +2,7 @@ use anyhow::Result; use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind}; use futures::StreamExt; use tokio::{select, sync::{mpsc, oneshot}}; -use yazi_config::MANAGER; +use yazi_config::MGR; use yazi_shared::event::Event; pub(super) struct Signals { @@ -62,7 +62,7 @@ impl Signals { Event::Key(key).emit() } CrosstermEvent::Mouse(mouse) => { - if MANAGER.mouse_events.contains(mouse.kind.into()) { + if MGR.mouse_events.contains(mouse.kind.into()) { Event::Mouse(mouse).emit(); } } diff --git a/yazi-fm/src/spot/spot.rs b/yazi-fm/src/spot/spot.rs index 4221c8b0..5cf1b776 100644 --- a/yazi-fm/src/spot/spot.rs +++ b/yazi-fm/src/spot/spot.rs @@ -17,7 +17,7 @@ impl Widget for Spot<'_> { }; for w in &lock.data { - w.clone().render(buf, |p| self.cx.manager.area(p)); + w.clone().render(buf, |p| self.cx.mgr.area(p)); } } } diff --git a/yazi-fm/src/tasks/progress.rs b/yazi-fm/src/tasks/progress.rs index e751ba3d..91a38c84 100644 --- a/yazi-fm/src/tasks/progress.rs +++ b/yazi-fm/src/tasks/progress.rs @@ -21,7 +21,7 @@ impl Widget for Progress<'_> { let progress = LUA.globals().raw_get::
("Progress")?.call_method::
("use", area)?; - render_once(progress.call_method("redraw", ())?, buf, |p| self.cx.manager.area(p)); + render_once(progress.call_method("redraw", ())?, buf, |p| self.cx.mgr.area(p)); Ok::<_, mlua::Error>(()) }; if let Err(e) = f() { diff --git a/yazi-fm/src/term.rs b/yazi-fm/src/term.rs index 7a4f783e..ef5af731 100644 --- a/yazi-fm/src/term.rs +++ b/yazi-fm/src/term.rs @@ -5,7 +5,7 @@ use crossterm::{event::{DisableBracketedPaste, EnableBracketedPaste, KeyboardEnh use cursor::RestoreCursor; use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect}; use yazi_adapter::{Emulator, Mux}; -use yazi_config::{INPUT, MANAGER}; +use yazi_config::{INPUT, MGR}; static CSI_U: AtomicBool = AtomicBool::new(false); static BLINK: AtomicBool = AtomicBool::new(false); @@ -94,7 +94,7 @@ impl Term { execute!(stderr(), PopKeyboardEnhancementFlags).ok(); } - if !MANAGER.title_format.is_empty() { + if !MGR.title_format.is_empty() { execute!(stderr(), SetTitle("")).ok(); } @@ -190,13 +190,13 @@ impl DerefMut for Term { // --- Mouse support mod mouse { use crossterm::event::{DisableMouseCapture, EnableMouseCapture}; - use yazi_config::MANAGER; + use yazi_config::MGR; pub struct SetMouse(pub bool); impl crossterm::Command for SetMouse { fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result { - if MANAGER.mouse_events.is_empty() { + if MGR.mouse_events.is_empty() { Ok(()) } else if self.0 { EnableMouseCapture.write_ansi(f) @@ -207,7 +207,7 @@ mod mouse { #[cfg(windows)] fn execute_winapi(&self) -> std::io::Result<()> { - if MANAGER.mouse_events.is_empty() { + if MGR.mouse_events.is_empty() { Ok(()) } else if self.0 { EnableMouseCapture.execute_winapi() diff --git a/yazi-fs/src/op.rs b/yazi-fs/src/op.rs index 2e142fed..ff5150ff 100644 --- a/yazi-fs/src/op.rs +++ b/yazi-fs/src/op.rs @@ -41,7 +41,7 @@ impl FilesOp { pub fn emit(self) { yazi_shared::event::Event::Call( Cmd::new("update_files").with_any("op", self).into(), - Layer::Manager, + Layer::Mgr, ) .emit(); } diff --git a/yazi-plugin/preset/components/current.lua b/yazi-plugin/preset/components/current.lua index 2a8bdebb..702544f9 100644 --- a/yazi-plugin/preset/components/current.lua +++ b/yazi-plugin/preset/components/current.lua @@ -55,12 +55,12 @@ function Current:click(event, up) return end - ya.manager_emit("arrow", { y + f.offset - f.hovered.idx }) + ya.mgr_emit("arrow", { y + f.offset - f.hovered.idx }) if event.is_right then - ya.manager_emit("open", {}) + ya.mgr_emit("open", {}) end end -function Current:scroll(event, step) ya.manager_emit("arrow", { step }) end +function Current:scroll(event, step) ya.mgr_emit("arrow", { step }) end function Current:touch(event, step) end diff --git a/yazi-plugin/preset/components/entity.lua b/yazi-plugin/preset/components/entity.lua index a5095494..1fff8d52 100644 --- a/yazi-plugin/preset/components/entity.lua +++ b/yazi-plugin/preset/components/entity.lua @@ -42,7 +42,7 @@ function Entity:highlights() if h[1] > last then spans[#spans + 1] = name:sub(last + 1, h[1]) end - spans[#spans + 1] = ui.Span(name:sub(h[1] + 1, h[2])):style(th.manager.find_keyword) + spans[#spans + 1] = ui.Span(name:sub(h[1] + 1, h[2])):style(th.mgr.find_keyword) last = h[2] end if last < #name then @@ -64,11 +64,11 @@ function Entity:found() end local s = string.format("[%d/%s]", found[1] + 1, found[2] >= 100 and "99+" or found[2]) - return ui.Line { " ", ui.Span(s):style(th.manager.find_position) } + return ui.Line { " ", ui.Span(s):style(th.mgr.find_position) } end function Entity:symlink() - if not rt.manager.show_symlink then + if not rt.mgr.show_symlink then return "" end @@ -89,9 +89,9 @@ function Entity:style() if not self._file:is_hovered() then return s elseif self._file:in_preview() then - return s and s:patch(th.manager.preview_hovered) or th.manager.preview_hovered + return s and s:patch(th.mgr.preview_hovered) or th.mgr.preview_hovered else - return s and s:patch(th.manager.hovered) or th.manager.hovered + return s and s:patch(th.mgr.hovered) or th.mgr.hovered end end diff --git a/yazi-plugin/preset/components/header.lua b/yazi-plugin/preset/components/header.lua index d5e6d3d9..63af33fa 100644 --- a/yazi-plugin/preset/components/header.lua +++ b/yazi-plugin/preset/components/header.lua @@ -28,7 +28,7 @@ function Header:cwd() end local s = ya.readable_path(tostring(self._current.cwd)) .. self:flags() - return ui.Span(ya.truncate(s, { max = max, rtl = true })):style(th.manager.cwd) + return ui.Span(ya.truncate(s, { max = max, rtl = true })):style(th.mgr.cwd) end function Header:flags() @@ -55,13 +55,13 @@ function Header:count() local count, style if yanked == 0 then count = #self._tab.selected - style = th.manager.count_selected + style = th.mgr.count_selected elseif cx.yanked.is_cut then count = yanked - style = th.manager.count_cut + style = th.mgr.count_cut else count = yanked - style = th.manager.count_copied + style = th.mgr.count_copied end if count == 0 then @@ -83,13 +83,13 @@ function Header:tabs() local spans = {} for i = 1, tabs do local text = i - if th.manager.tab_width > 2 then - text = ya.truncate(text .. " " .. cx.tabs[i]:name(), { max = th.manager.tab_width }) + if th.mgr.tab_width > 2 then + text = ya.truncate(text .. " " .. cx.tabs[i]:name(), { max = th.mgr.tab_width }) end if i == cx.tabs.idx then - spans[#spans + 1] = ui.Span(" " .. text .. " "):style(th.manager.tab_active) + spans[#spans + 1] = ui.Span(" " .. text .. " "):style(th.mgr.tab_active) else - spans[#spans + 1] = ui.Span(" " .. text .. " "):style(th.manager.tab_inactive) + spans[#spans + 1] = ui.Span(" " .. text .. " "):style(th.mgr.tab_inactive) end end return ui.Line(spans) diff --git a/yazi-plugin/preset/components/marker.lua b/yazi-plugin/preset/components/marker.lua index 569d08ef..28658210 100644 --- a/yazi-plugin/preset/components/marker.lua +++ b/yazi-plugin/preset/components/marker.lua @@ -50,16 +50,16 @@ end function Marker:style(file) local marked = file:is_marked() if marked == 1 then - return th.manager.marker_marked + return th.mgr.marker_marked elseif marked == 0 and file:is_selected() then - return th.manager.marker_selected + return th.mgr.marker_selected end local yanked = file:is_yanked() if yanked == 1 then - return th.manager.marker_copied + return th.mgr.marker_copied elseif yanked == 2 then - return th.manager.marker_cut + return th.mgr.marker_cut end end diff --git a/yazi-plugin/preset/components/parent.lua b/yazi-plugin/preset/components/parent.lua index b257f82c..b2bcc064 100644 --- a/yazi-plugin/preset/components/parent.lua +++ b/yazi-plugin/preset/components/parent.lua @@ -36,9 +36,9 @@ function Parent:click(event, up) local y = event.y - self._area.y + 1 local window = self._folder and self._folder.window or {} if window[y] then - ya.manager_emit("reveal", { window[y].url }) + ya.mgr_emit("reveal", { window[y].url }) else - ya.manager_emit("leave", {}) + ya.mgr_emit("leave", {}) end end diff --git a/yazi-plugin/preset/components/preview.lua b/yazi-plugin/preset/components/preview.lua index 87eaf031..1b6c35aa 100644 --- a/yazi-plugin/preset/components/preview.lua +++ b/yazi-plugin/preset/components/preview.lua @@ -23,12 +23,12 @@ function Preview:click(event, up) local y = event.y - self._area.y + 1 local window = self._folder and self._folder.window or {} if window[y] then - ya.manager_emit("reveal", { window[y].url }) + ya.mgr_emit("reveal", { window[y].url }) else - ya.manager_emit("enter", {}) + ya.mgr_emit("enter", {}) end end -function Preview:scroll(event, step) ya.manager_emit("seek", { step }) end +function Preview:scroll(event, step) ya.mgr_emit("seek", { step }) end function Preview:touch(event, step) end diff --git a/yazi-plugin/preset/components/rail.lua b/yazi-plugin/preset/components/rail.lua index 92a25fc3..fdfdad62 100644 --- a/yazi-plugin/preset/components/rail.lua +++ b/yazi-plugin/preset/components/rail.lua @@ -10,8 +10,8 @@ end function Rail:build() self._base = { - ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):symbol(th.manager.border_symbol):style(th.manager.border_style), - ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):symbol(th.manager.border_symbol):style(th.manager.border_style), + ui.Bar(ui.Bar.RIGHT):area(self._chunks[1]):symbol(th.mgr.border_symbol):style(th.mgr.border_style), + ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):symbol(th.mgr.border_symbol):style(th.mgr.border_style), } self._children = { Marker:new(self._chunks[1], self._tab.parent), diff --git a/yazi-plugin/preset/components/root.lua b/yazi-plugin/preset/components/root.lua index 6d9bbbfa..8792e13f 100644 --- a/yazi-plugin/preset/components/root.lua +++ b/yazi-plugin/preset/components/root.lua @@ -48,7 +48,7 @@ end -- Mouse events function Root:click(event, up) - if tostring(cx.layer) ~= "manager" then + if tostring(cx.layer) ~= "mgr" then return end local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) @@ -56,7 +56,7 @@ function Root:click(event, up) end function Root:scroll(event, step) - if tostring(cx.layer) ~= "manager" then + if tostring(cx.layer) ~= "mgr" then return end local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) @@ -64,7 +64,7 @@ function Root:scroll(event, step) end function Root:touch(event, step) - if tostring(cx.layer) ~= "manager" then + if tostring(cx.layer) ~= "mgr" then return end local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) diff --git a/yazi-plugin/preset/components/tab.lua b/yazi-plugin/preset/components/tab.lua index 3bbd6e5f..575aea02 100644 --- a/yazi-plugin/preset/components/tab.lua +++ b/yazi-plugin/preset/components/tab.lua @@ -10,7 +10,7 @@ function Tab:new(area, tab) end function Tab:layout() - local ratio = rt.manager.ratio + local ratio = rt.mgr.ratio self._chunks = ui.Layout() :direction(ui.Layout.HORIZONTAL) :constraints({ diff --git a/yazi-plugin/preset/plugins/archive.lua b/yazi-plugin/preset/plugins/archive.lua index c5fc0ce8..b895c717 100644 --- a/yazi-plugin/preset/plugins/archive.lua +++ b/yazi-plugin/preset/plugins/archive.lua @@ -33,7 +33,7 @@ function M:peek(job) end if job.skip > 0 and bound < job.skip + limit then - ya.manager_emit("peek", { math.max(0, bound - limit), only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { math.max(0, bound - limit), only_if = job.file.url, upper_bound = true }) else ya.preview_widgets(job, { ui.Text(paths):area(job.area), diff --git a/yazi-plugin/preset/plugins/code.lua b/yazi-plugin/preset/plugins/code.lua index 056ea458..4d777fc4 100644 --- a/yazi-plugin/preset/plugins/code.lua +++ b/yazi-plugin/preset/plugins/code.lua @@ -3,7 +3,7 @@ local M = {} function M:peek(job) local err, bound = ya.preview_code(job) if bound then - ya.manager_emit("peek", { bound, only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { bound, only_if = job.file.url, upper_bound = true }) elseif err and not err:find("cancelled", 1, true) then require("empty").msg(job, err) end @@ -18,7 +18,7 @@ function M:seek(job) local step = math.floor(job.units * job.area.h / 10) step = step == 0 and ya.clamp(-1, job.units, 1) or step - ya.manager_emit("peek", { + ya.mgr_emit("peek", { math.max(0, cx.active.preview.skip + step), only_if = job.file.url, }) diff --git a/yazi-plugin/preset/plugins/dds.lua b/yazi-plugin/preset/plugins/dds.lua index 469a4804..e591afda 100644 --- a/yazi-plugin/preset/plugins/dds.lua +++ b/yazi-plugin/preset/plugins/dds.lua @@ -1,7 +1,7 @@ local M = {} function M:setup() - ps.sub_remote("dds-emit", function(cmd) ya.manager_emit(cmd[1], cmd[2]) end) + ps.sub_remote("dds-emit", function(cmd) ya.mgr_emit(cmd[1], cmd[2]) end) end return M diff --git a/yazi-plugin/preset/plugins/empty.lua b/yazi-plugin/preset/plugins/empty.lua index a0b23b0f..e5b9d9c8 100644 --- a/yazi-plugin/preset/plugins/empty.lua +++ b/yazi-plugin/preset/plugins/empty.lua @@ -41,7 +41,7 @@ function M:peek(job) end if job.skip > 0 and i < job.skip + limit then - ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true }) else ya.preview_widgets(job, { ui.Text(lines):area(job.area) }) end diff --git a/yazi-plugin/preset/plugins/extract.lua b/yazi-plugin/preset/plugins/extract.lua index 329c87d7..e10a937c 100644 --- a/yazi-plugin/preset/plugins/extract.lua +++ b/yazi-plugin/preset/plugins/extract.lua @@ -6,7 +6,7 @@ function M:setup() ps.sub_remote("extract", function(args) local noisy = #args == 1 and ' "" --noisy' or ' ""' for _, arg in ipairs(args) do - ya.manager_emit("plugin", { self._id, ya.quote(arg, true) .. noisy }) + ya.mgr_emit("plugin", { self._id, ya.quote(arg, true) .. noisy }) end end) end diff --git a/yazi-plugin/preset/plugins/folder.lua b/yazi-plugin/preset/plugins/folder.lua index bd544bd4..30a4a1f5 100644 --- a/yazi-plugin/preset/plugins/folder.lua +++ b/yazi-plugin/preset/plugins/folder.lua @@ -8,7 +8,7 @@ function M:peek(job) local bound = math.max(0, #folder.files - job.area.h) if job.skip > bound then - return ya.manager_emit("peek", { bound, only_if = job.file.url, upper_bound = true }) + return ya.mgr_emit("peek", { bound, only_if = job.file.url, upper_bound = true }) end if #folder.files == 0 then @@ -33,7 +33,7 @@ function M:seek(job) if folder and folder.cwd == job.file.url then local step = math.floor(job.units * job.area.h / 10) local bound = math.max(0, #folder.files - job.area.h) - ya.manager_emit("peek", { + ya.mgr_emit("peek", { ya.clamp(0, cx.active.preview.skip + step, bound), only_if = job.file.url, }) diff --git a/yazi-plugin/preset/plugins/fzf.lua b/yazi-plugin/preset/plugins/fzf.lua index 4d99af59..f655a217 100644 --- a/yazi-plugin/preset/plugins/fzf.lua +++ b/yazi-plugin/preset/plugins/fzf.lua @@ -22,7 +22,7 @@ local function entry() local target = output.stdout:gsub("\n$", "") if target ~= "" then - ya.manager_emit(target:find("[/\\]$") and "cd" or "reveal", { target }) + ya.mgr_emit(target:find("[/\\]$") and "cd" or "reveal", { target }) end end diff --git a/yazi-plugin/preset/plugins/json.lua b/yazi-plugin/preset/plugins/json.lua index 3bb6698a..c48761b8 100644 --- a/yazi-plugin/preset/plugins/json.lua +++ b/yazi-plugin/preset/plugins/json.lua @@ -29,7 +29,7 @@ function M:peek(job) child:start_kill() if job.skip > 0 and i < job.skip + limit then - ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true }) else lines = lines:gsub("\t", string.rep(" ", rt.preview.tab_size)) ya.preview_widgets(job, { diff --git a/yazi-plugin/preset/plugins/mime.lua b/yazi-plugin/preset/plugins/mime.lua index 70cfb63a..7f272b5e 100644 --- a/yazi-plugin/preset/plugins/mime.lua +++ b/yazi-plugin/preset/plugins/mime.lua @@ -27,7 +27,7 @@ function M:fetch(job) return end if next(updates) then - ya.manager_emit("update_mimes", { updates = updates }) + ya.mgr_emit("update_mimes", { updates = updates }) updates, last = {}, ya.time() end end diff --git a/yazi-plugin/preset/plugins/pdf.lua b/yazi-plugin/preset/plugins/pdf.lua index 4c9db811..3db127b5 100644 --- a/yazi-plugin/preset/plugins/pdf.lua +++ b/yazi-plugin/preset/plugins/pdf.lua @@ -20,7 +20,7 @@ function M:seek(job) local h = cx.active.current.hovered if h and h.url == job.file.url then local step = ya.clamp(-1, job.units, 1) - ya.manager_emit("peek", { math.max(0, cx.active.preview.skip + step), only_if = job.file.url }) + ya.mgr_emit("peek", { math.max(0, cx.active.preview.skip + step), only_if = job.file.url }) end end @@ -49,7 +49,7 @@ function M:preload(job) elseif not output.status.success then local pages = tonumber(output.stderr:match("the last page %((%d+)%)")) or 0 if job.skip > 0 and pages > 0 then - ya.manager_emit("peek", { math.max(0, pages - 1), only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { math.max(0, pages - 1), only_if = job.file.url, upper_bound = true }) end return true, Err("Failed to convert PDF to image, stderr: %s", output.stderr) end diff --git a/yazi-plugin/preset/plugins/session.lua b/yazi-plugin/preset/plugins/session.lua index c20d94b6..e1037de8 100644 --- a/yazi-plugin/preset/plugins/session.lua +++ b/yazi-plugin/preset/plugins/session.lua @@ -1,6 +1,6 @@ local function setup(_, opts) if opts.sync_yanked then - ps.sub_remote("@yank", function(body) ya.manager_emit("update_yanked", { cut = body.cut, urls = body }) end) + ps.sub_remote("@yank", function(body) ya.mgr_emit("update_yanked", { cut = body.cut, urls = body }) end) end end diff --git a/yazi-plugin/preset/plugins/video.lua b/yazi-plugin/preset/plugins/video.lua index adbda45e..1bc118a4 100644 --- a/yazi-plugin/preset/plugins/video.lua +++ b/yazi-plugin/preset/plugins/video.lua @@ -19,7 +19,7 @@ end function M:seek(job) local h = cx.active.current.hovered if h and h.url == job.file.url then - ya.manager_emit("peek", { + ya.mgr_emit("peek", { math.max(0, cx.active.preview.skip + job.units), only_if = job.file.url, }) @@ -29,7 +29,7 @@ end function M:preload(job) local percent = 5 + job.skip if percent > 95 then - ya.manager_emit("peek", { 90, only_if = job.file.url, upper_bound = true }) + ya.mgr_emit("peek", { 90, only_if = job.file.url, upper_bound = true }) return false end diff --git a/yazi-plugin/preset/plugins/zoxide.lua b/yazi-plugin/preset/plugins/zoxide.lua index 1b49c100..b5b5f0e1 100644 --- a/yazi-plugin/preset/plugins/zoxide.lua +++ b/yazi-plugin/preset/plugins/zoxide.lua @@ -66,7 +66,7 @@ local function setup(_, opts) ps.sub( "cd", function() - ya.manager_emit("shell", { + ya.mgr_emit("shell", { cwd = fs.cwd(), orphan = true, "zoxide add " .. ya.quote(tostring(cx.active.current.cwd)), @@ -113,7 +113,7 @@ local function entry() local target = output.stdout:gsub("\n$", "") if target ~= "" then - ya.manager_emit("cd", { target }) + ya.mgr_emit("cd", { target }) end end diff --git a/yazi-plugin/src/config/runtime.rs b/yazi-plugin/src/config/runtime.rs index eb828017..a3482614 100644 --- a/yazi-plugin/src/config/runtime.rs +++ b/yazi-plugin/src/config/runtime.rs @@ -1,6 +1,6 @@ use mlua::{IntoLua, Lua, LuaSerdeExt, SerializeOptions, Value}; use yazi_boot::ARGS; -use yazi_config::{MANAGER, PREVIEW, THEME}; +use yazi_config::{MGR, PREVIEW, THEME}; use crate::{Composer, url::Url}; @@ -16,7 +16,7 @@ impl<'a> Runtime<'a> { Composer::make(lua, 5, |lua, key| { match key { b"args" => Self::args(lua)?, - b"manager" => Self::manager(lua)?, + b"mgr" => Self::mgr(lua)?, b"plugin" => super::Plugin::compose(lua)?, b"preview" => Self::preview(lua)?, _ => return Ok(Value::Nil), @@ -35,11 +35,11 @@ impl<'a> Runtime<'a> { }) } - fn manager(lua: &Lua) -> mlua::Result { + fn mgr(lua: &Lua) -> mlua::Result { Composer::make(lua, 5, |lua, key| { match key { - b"ratio" => lua.to_value_with(&MANAGER.ratio, OPTS)?, - b"show_symlink" => lua.to_value_with(&MANAGER.show_symlink, OPTS)?, + b"ratio" => lua.to_value_with(&MGR.ratio, OPTS)?, + b"show_symlink" => lua.to_value_with(&MGR.show_symlink, OPTS)?, _ => return Ok(Value::Nil), } .into_lua(lua) @@ -66,7 +66,7 @@ impl<'a> Runtime<'a> { // TODO: remove this pub fn install_manager(self) -> mlua::Result { - self.lua.globals().raw_set("MANAGER", self.lua.to_value_with(&*MANAGER, OPTS)?)?; + self.lua.globals().raw_set("MANAGER", self.lua.to_value_with(&*MGR, OPTS)?)?; Ok(self) } diff --git a/yazi-plugin/src/config/theme.rs b/yazi-plugin/src/config/theme.rs index 6f7a8e5a..b7cb42ad 100644 --- a/yazi-plugin/src/config/theme.rs +++ b/yazi-plugin/src/config/theme.rs @@ -10,7 +10,7 @@ impl Theme { pub fn compose(lua: &Lua) -> mlua::Result { Composer::make(lua, 5, |lua, key| { match key { - b"manager" => lua.to_value_with(&THEME.manager, OPTS)?, + b"mgr" => lua.to_value_with(&THEME.mgr, OPTS)?, b"mode" => lua.to_value_with(&THEME.mode, OPTS)?, b"status" => lua.to_value_with(&THEME.status, OPTS)?, b"spot" => lua.to_value_with(&THEME.spot, OPTS)?, diff --git a/yazi-plugin/src/external/highlighter.rs b/yazi-plugin/src/external/highlighter.rs index d75b22bc..36b10630 100644 --- a/yazi-plugin/src/external/highlighter.rs +++ b/yazi-plugin/src/external/highlighter.rs @@ -20,7 +20,7 @@ impl Highlighter { pub fn init() -> (&'static Theme, &'static SyntaxSet) { let f = || { - let theme = std::fs::File::open(&THEME.manager.syntect_theme) + let theme = std::fs::File::open(&THEME.mgr.syntect_theme) .map_err(LoadingError::Io) .and_then(|f| ThemeSet::load_from_reader(&mut std::io::BufReader::new(f))) .or_else(|_| ThemeSet::load_from_reader(&mut Cursor::new(yazi_prebuild::ansi_theme()))); diff --git a/yazi-plugin/src/utils/call.rs b/yazi-plugin/src/utils/call.rs index c6d8d51b..1bcd4d4f 100644 --- a/yazi-plugin/src/utils/call.rs +++ b/yazi-plugin/src/utils/call.rs @@ -45,9 +45,9 @@ impl Utils { }) } - pub(super) fn manager_emit(lua: &Lua) -> mlua::Result { + pub(super) fn mgr_emit(lua: &Lua) -> mlua::Result { lua.create_function(|_, (name, args): (String, Table)| { - emit!(Call(Cmd { name, args: Sendable::table_to_args(args)? }, Layer::Manager)); + emit!(Call(Cmd { name, args: Sendable::table_to_args(args)? }, Layer::Mgr)); Ok(()) }) } diff --git a/yazi-plugin/src/utils/preview.rs b/yazi-plugin/src/utils/preview.rs index 77837578..407b49bb 100644 --- a/yazi-plugin/src/utils/preview.rs +++ b/yazi-plugin/src/utils/preview.rs @@ -54,7 +54,7 @@ impl Utils { wrap: if PREVIEW.wrap == PreviewWrap::Yes { WRAP } else { WRAP_NO }, })]; - emit!(Call(Cmd::new("update_peeked").with_any("lock", lock), Layer::Manager)); + emit!(Call(Cmd::new("update_peeked").with_any("lock", lock), Layer::Mgr)); (Value::Nil, Value::Nil).into_lua_multi(&lua) }) } @@ -64,7 +64,7 @@ impl Utils { let mut lock = PreviewLock::try_from(t)?; lock.data = widgets.into_iter().map(Renderable::try_from).collect::>()?; - emit!(Call(Cmd::new("update_peeked").with_any("lock", lock), Layer::Manager)); + emit!(Call(Cmd::new("update_peeked").with_any("lock", lock), Layer::Mgr)); Ok(()) }) } diff --git a/yazi-plugin/src/utils/spot.rs b/yazi-plugin/src/utils/spot.rs index 0ee8ece6..23d4bfbb 100644 --- a/yazi-plugin/src/utils/spot.rs +++ b/yazi-plugin/src/utils/spot.rs @@ -80,7 +80,7 @@ impl Utils { }), Renderable::Table(table), ]; - emit!(Call(Cmd::new("update_spotted").with_any("lock", lock), Layer::Manager)); + emit!(Call(Cmd::new("update_spotted").with_any("lock", lock), Layer::Mgr)); Ok(()) }) @@ -91,7 +91,7 @@ impl Utils { let mut lock = SpotLock::try_from(t)?; lock.data = widgets.into_iter().map(Renderable::try_from).collect::>()?; - emit!(Call(Cmd::new("update_spotted").with_any("lock", lock), Layer::Manager)); + emit!(Call(Cmd::new("update_spotted").with_any("lock", lock), Layer::Mgr)); Ok(()) }) } diff --git a/yazi-plugin/src/utils/utils.rs b/yazi-plugin/src/utils/utils.rs index 71c02ffa..4b19dd54 100644 --- a/yazi-plugin/src/utils/utils.rs +++ b/yazi-plugin/src/utils/utils.rs @@ -17,7 +17,8 @@ pub fn compose(lua: &Lua, isolate: bool) -> mlua::Result { b"render" => Utils::render(lua)?, b"redraw_with" => Utils::redraw_with(lua)?, b"app_emit" => Utils::app_emit(lua)?, - b"manager_emit" => Utils::manager_emit(lua)?, + b"mgr_emit" => Utils::mgr_emit(lua)?, + b"manager_emit" => Utils::mgr_emit(lua)?, // TODO: remove this in the future b"input_emit" => Utils::input_emit(lua)?, // Image diff --git a/yazi-proxy/src/lib.rs b/yazi-proxy/src/lib.rs index cbe1f660..03cf4c6c 100644 --- a/yazi-proxy/src/lib.rs +++ b/yazi-proxy/src/lib.rs @@ -2,6 +2,6 @@ mod macros; yazi_macro::mod_pub!(options); -yazi_macro::mod_flat!(app completion confirm input manager pick semaphore tab tasks); +yazi_macro::mod_flat!(app completion confirm input mgr pick semaphore tab tasks); pub fn init() { crate::init_semaphore(); } diff --git a/yazi-proxy/src/manager.rs b/yazi-proxy/src/mgr.rs similarity index 76% rename from yazi-proxy/src/manager.rs rename to yazi-proxy/src/mgr.rs index 0a654e55..fbc3eff0 100644 --- a/yazi-proxy/src/manager.rs +++ b/yazi-proxy/src/mgr.rs @@ -3,60 +3,60 @@ use yazi_shared::{Id, Layer, event::Cmd, url::Url}; use crate::options::OpenDoOpt; -pub struct ManagerProxy; +pub struct MgrProxy; -impl ManagerProxy { +impl MgrProxy { #[inline] pub fn spot(skip: Option) { - emit!(Call(Cmd::new("spot").with_opt("skip", skip), Layer::Manager)); + emit!(Call(Cmd::new("spot").with_opt("skip", skip), Layer::Mgr)); } #[inline] pub fn peek(force: bool) { - emit!(Call(Cmd::new("peek").with_bool("force", force), Layer::Manager)); + emit!(Call(Cmd::new("peek").with_bool("force", force), Layer::Mgr)); } #[inline] pub fn hover(url: Option, tab: Id) { emit!(Call( Cmd::args("hover", &url.map_or_else(Vec::new, |u| vec![u])).with("tab", tab), - Layer::Manager + Layer::Mgr )); } #[inline] pub fn refresh() { - emit!(Call(Cmd::new("refresh"), Layer::Manager)); + emit!(Call(Cmd::new("refresh"), Layer::Mgr)); } #[inline] pub fn open_do(opt: OpenDoOpt) { - emit!(Call(Cmd::new("open_do").with_any("option", opt), Layer::Manager)); + emit!(Call(Cmd::new("open_do").with_any("option", opt), Layer::Mgr)); } #[inline] pub fn remove_do(targets: Vec, permanently: bool) { emit!(Call( Cmd::new("remove_do").with_bool("permanently", permanently).with_any("targets", targets), - Layer::Manager + Layer::Mgr )); } #[inline] pub fn update_tasks(url: &Url) { - emit!(Call(Cmd::new("update_tasks").with_any("urls", vec![url.clone()]), Layer::Manager)); + emit!(Call(Cmd::new("update_tasks").with_any("urls", vec![url.clone()]), Layer::Mgr)); } #[inline] pub fn update_paged() { - emit!(Call(Cmd::new("update_paged"), Layer::Manager)); + emit!(Call(Cmd::new("update_paged"), Layer::Mgr)); } #[inline] pub fn update_paged_by(page: usize, only_if: &Url) { emit!(Call( Cmd::args("update_paged", &[page]).with_any("only-if", only_if.clone()), - Layer::Manager + Layer::Mgr )); } } diff --git a/yazi-proxy/src/tab.rs b/yazi-proxy/src/tab.rs index 9e48fc4b..1d0b71fb 100644 --- a/yazi-proxy/src/tab.rs +++ b/yazi-proxy/src/tab.rs @@ -8,17 +8,17 @@ pub struct TabProxy; impl TabProxy { #[inline] pub fn cd(target: &Url) { - emit!(Call(Cmd::args("cd", &[target]), Layer::Manager)); + emit!(Call(Cmd::args("cd", &[target]), Layer::Mgr)); } #[inline] pub fn reveal(target: &Url) { - emit!(Call(Cmd::args("reveal", &[target]), Layer::Manager)); + emit!(Call(Cmd::args("reveal", &[target]), Layer::Mgr)); } #[inline] pub fn arrow(step: isize) { - emit!(Call(Cmd::args("arrow", &[step]), Layer::Manager)); + emit!(Call(Cmd::args("arrow", &[step]), Layer::Mgr)); } #[inline] @@ -26,7 +26,7 @@ impl TabProxy { emit!(Call( // TODO: use second positional argument instead of `args` parameter Cmd::args("search_do", &[opt.subject]).with("via", opt.via).with("args", opt.args_raw), - Layer::Manager + Layer::Mgr )); } } diff --git a/yazi-scheduler/src/scheduler.rs b/yazi-scheduler/src/scheduler.rs index c20ea0b6..6584c663 100644 --- a/yazi-scheduler/src/scheduler.rs +++ b/yazi-scheduler/src/scheduler.rs @@ -7,7 +7,7 @@ use tokio::{fs, select, sync::mpsc::{self, UnboundedReceiver}, task::JoinHandle} use yazi_config::{TASKS, plugin::{Fetcher, Preloader}}; use yazi_dds::Pump; use yazi_fs::{must_be_dir, remove_dir_clean, unique_name}; -use yazi_proxy::{ManagerProxy, options::{PluginOpt, ProcessExecOpt}}; +use yazi_proxy::{MgrProxy, options::{PluginOpt, ProcessExecOpt}}; use yazi_shared::{Throttle, url::Url}; use super::{Ongoing, TaskProg, TaskStage}; @@ -164,7 +164,7 @@ impl Scheduler { async move { if !canceled { fs::remove_dir_all(&target).await.ok(); - ManagerProxy::update_tasks(&target); + MgrProxy::update_tasks(&target); Pump::push_delete(target); } ongoing.lock().try_remove(id, TaskStage::Hooked); @@ -192,7 +192,7 @@ impl Scheduler { Box::new(move |canceled: bool| { async move { if !canceled { - ManagerProxy::update_tasks(&target); + MgrProxy::update_tasks(&target); Pump::push_trash(target); } ongoing.lock().try_remove(id, TaskStage::Hooked); diff --git a/yazi-shared/src/layer.rs b/yazi-shared/src/layer.rs index 3a1ca21a..d544a9c9 100644 --- a/yazi-shared/src/layer.rs +++ b/yazi-shared/src/layer.rs @@ -7,7 +7,7 @@ use serde::Deserialize; pub enum Layer { #[default] App, - Manager, + Mgr, Tasks, Spot, Pick, @@ -22,7 +22,7 @@ impl Display for Layer { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(match self { Self::App => "app", - Self::Manager => "manager", + Self::Mgr => "mgr", Self::Tasks => "tasks", Self::Spot => "spot", Self::Pick => "pick",