refactor: rename rt.manager to rt.mgr, and th.manager to th.mgr (#2397)

This commit is contained in:
三咲雅 · Misaki Masa 2025-02-25 23:12:54 +08:00 committed by GitHub
parent 68e892694d
commit 235f6888d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
120 changed files with 316 additions and 317 deletions

View file

@ -10,7 +10,7 @@ use crate::{Preset, keymap::Key};
#[derive(Debug)] #[derive(Debug)]
pub struct Keymap { pub struct Keymap {
pub manager: Vec<Chord>, pub mgr: Vec<Chord>,
pub tasks: Vec<Chord>, pub tasks: Vec<Chord>,
pub spot: Vec<Chord>, pub spot: Vec<Chord>,
pub pick: Vec<Chord>, pub pick: Vec<Chord>,
@ -25,7 +25,7 @@ impl Keymap {
pub fn get(&self, layer: Layer) -> &[Chord] { pub fn get(&self, layer: Layer) -> &[Chord] {
match layer { match layer {
Layer::App => unreachable!(), Layer::App => unreachable!(),
Layer::Manager => &self.manager, Layer::Mgr => &self.mgr,
Layer::Tasks => &self.tasks, Layer::Tasks => &self.tasks,
Layer::Spot => &self.spot, Layer::Spot => &self.spot,
Layer::Pick => &self.pick, Layer::Pick => &self.pick,
@ -53,7 +53,8 @@ impl<'de> Deserialize<'de> for Keymap {
{ {
#[derive(Deserialize)] #[derive(Deserialize)]
struct Shadow { struct Shadow {
manager: Inner, #[serde(rename = "manager")]
mgr: Inner, // TODO: remove serde(rename)
tasks: Inner, tasks: Inner,
spot: Inner, spot: Inner,
pick: Inner, pick: Inner,
@ -92,7 +93,7 @@ impl<'de> Deserialize<'de> for Keymap {
let shadow = Shadow::deserialize(deserializer)?; let shadow = Shadow::deserialize(deserializer)?;
Ok(Self { Ok(Self {
#[rustfmt::skip] #[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] #[rustfmt::skip]
tasks: mix(shadow.tasks.prepend_keymap, shadow.tasks.keymap, shadow.tasks.append_keymap), tasks: mix(shadow.tasks.prepend_keymap, shadow.tasks.keymap, shadow.tasks.append_keymap),
#[rustfmt::skip] #[rustfmt::skip]

View file

@ -1,6 +1,6 @@
#![allow(clippy::module_inception)] #![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); yazi_macro::mod_flat!(layout pattern preset priority);
@ -9,7 +9,7 @@ use std::str::FromStr;
use yazi_shared::{RoCell, SyncCell}; use yazi_shared::{RoCell, SyncCell};
pub static KEYMAP: RoCell<keymap::Keymap> = RoCell::new(); pub static KEYMAP: RoCell<keymap::Keymap> = RoCell::new();
pub static MANAGER: RoCell<manager::Manager> = RoCell::new(); pub static MGR: RoCell<mgr::Mgr> = RoCell::new();
pub static OPEN: RoCell<open::Open> = RoCell::new(); pub static OPEN: RoCell<open::Open> = RoCell::new();
pub static PLUGIN: RoCell<plugin::Plugin> = RoCell::new(); pub static PLUGIN: RoCell<plugin::Plugin> = RoCell::new();
pub static PREVIEW: RoCell<preview::Preview> = RoCell::new(); pub static PREVIEW: RoCell<preview::Preview> = RoCell::new();
@ -29,7 +29,7 @@ pub fn init() -> anyhow::Result<()> {
} }
// TODO: remove this // 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" if c.name == "arrow"
&& c.first_str().unwrap_or_default().parse::<isize>().is_ok_and(|n| n <= -999 || n >= 999) && c.first_str().unwrap_or_default().parse::<isize>().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())?; let mut theme: theme::Theme = <_>::from_str(&flavor_toml.unwrap())?;
theme.manager.syntect_theme = theme theme.mgr.syntect_theme = theme
.flavor .flavor
.syntect_path(light) .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); THEME.init(theme);
Ok(()) Ok(())
@ -68,7 +68,7 @@ fn try_init(merge: bool) -> anyhow::Result<()> {
}; };
let keymap = <_>::from_str(&keymap_toml)?; 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 open = <_>::from_str(&yazi_toml)?;
let plugin = <_>::from_str(&yazi_toml)?; let plugin = <_>::from_str(&yazi_toml)?;
let preview = <_>::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)?; let which = <_>::from_str(&yazi_toml)?;
KEYMAP.init(keymap); KEYMAP.init(keymap);
MANAGER.init(manager); MGR.init(mgr);
OPEN.init(open); OPEN.init(open);
PLUGIN.init(plugin); PLUGIN.init(plugin);
PREVIEW.init(preview); PREVIEW.init(preview);

View file

@ -1 +0,0 @@
yazi_macro::mod_flat!(manager mouse ratio);

View file

@ -5,11 +5,11 @@ use serde::{Deserialize, Serialize};
use validator::Validate; use validator::Validate;
use yazi_fs::SortBy; use yazi_fs::SortBy;
use super::{ManagerRatio, MouseEvents}; use super::{MgrRatio, MouseEvents};
#[derive(Debug, Deserialize, Serialize, Validate)] #[derive(Debug, Deserialize, Serialize, Validate)]
pub struct Manager { pub struct Mgr {
pub ratio: ManagerRatio, pub ratio: MgrRatio,
// Sorting // Sorting
pub sort_by: SortBy, pub sort_by: SortBy,
@ -28,19 +28,20 @@ pub struct Manager {
pub title_format: String, pub title_format: String,
} }
impl FromStr for Manager { impl FromStr for Mgr {
type Err = anyhow::Error; type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
#[derive(Deserialize)] #[derive(Deserialize)]
struct Outer { struct Outer {
manager: Manager, #[serde(rename = "manager")]
mgr: Mgr, // TODO: remove serde(rename)
} }
let outer = toml::from_str::<Outer>(s) let outer = toml::from_str::<Outer>(s)
.context("Failed to parse the [manager] section in your yazi.toml")?; .context("Failed to parse the [manager] section in your yazi.toml")?;
outer.manager.validate()?; outer.mgr.validate()?;
Ok(outer.manager) Ok(outer.mgr)
} }
} }

View file

@ -0,0 +1 @@
yazi_macro::mod_flat!(mgr mouse ratio);

View file

@ -3,14 +3,14 @@ use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
#[serde(try_from = "Vec<u16>")] #[serde(try_from = "Vec<u16>")]
pub struct ManagerRatio { pub struct MgrRatio {
pub parent: u16, pub parent: u16,
pub current: u16, pub current: u16,
pub preview: u16, pub preview: u16,
pub all: u16, pub all: u16,
} }
impl TryFrom<Vec<u16>> for ManagerRatio { impl TryFrom<Vec<u16>> for MgrRatio {
type Error = anyhow::Error; type Error = anyhow::Error;
fn try_from(ratio: Vec<u16>) -> Result<Self, Self::Error> { fn try_from(ratio: Vec<u16>) -> Result<Self, Self::Error> {

View file

@ -10,7 +10,8 @@ use super::{Filetype, Flavor, Icons};
#[derive(Deserialize, Serialize)] #[derive(Deserialize, Serialize)]
pub struct Theme { pub struct Theme {
pub flavor: Flavor, pub flavor: Flavor,
pub manager: Manager, #[serde(rename = "manager")]
pub mgr: Mgr, // TODO: Remove `serde(rename)`
pub mode: Mode, pub mode: Mode,
pub status: Status, pub status: Status,
pub which: Which, pub which: Which,
@ -35,7 +36,7 @@ impl FromStr for Theme {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let theme: Self = toml::from_str(s).context("Failed to parse your theme.toml")?; let theme: Self = toml::from_str(s).context("Failed to parse your theme.toml")?;
theme.manager.validate()?; theme.mgr.validate()?;
theme.which.validate()?; theme.which.validate()?;
Ok(theme) Ok(theme)
@ -43,7 +44,7 @@ impl FromStr for Theme {
} }
#[derive(Deserialize, Serialize, Validate)] #[derive(Deserialize, Serialize, Validate)]
pub struct Manager { pub struct Mgr {
cwd: Style, cwd: Style,
// Hovered // Hovered

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::{confirm::Confirm, manager::Manager}; use crate::{confirm::Confirm, mgr::Mgr};
struct Opt { struct Opt {
step: isize, step: isize,
@ -13,9 +13,9 @@ impl From<CmdCow> for Opt {
impl Confirm { impl Confirm {
#[yazi_codegen::command] #[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 { 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 { } else {
self.prev(opt.step.unsigned_abs()) self.prev(opt.step.unsigned_abs())
} }

View file

@ -6,9 +6,9 @@
clippy::unit_arg 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() { pub fn init() {
manager::WATCHED.with(<_>::default); mgr::WATCHED.with(<_>::default);
manager::LINKED.with(<_>::default); mgr::LINKED.with(<_>::default);
} }

View file

@ -1,3 +0,0 @@
yazi_macro::mod_pub!(commands);
yazi_macro::mod_flat!(linked manager mimetype tabs watcher yanked);

View file

@ -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_proxy::{AppProxy, HIDER, TasksProxy, WATCHER};
use yazi_shared::{terminal_clear, url::Url}; 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) { pub(super) fn bulk_rename(&self) {
let Some(opener) = OPEN.block_opener("bulk-rename.txt", "text/plain") else { let Some(opener) = OPEN.block_opener("bulk-rename.txt", "text/plain") else {
return AppProxy::notify_warn("Bulk rename", "No text opener found"); return AppProxy::notify_warn("Bulk rename", "No text opener found");
@ -170,7 +170,7 @@ mod tests {
#[test] #[test]
fn test_sort() { fn test_sort() {
fn cmp(input: &[(&str, &str)], expected: &[(&str, &str)]) { 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(|&(o, _)| o.into()).collect(),
input.iter().map(|&(_, n)| n.into()).collect(), input.iter().map(|&(_, n)| n.into()).collect(),
); );

View file

@ -1,6 +1,6 @@
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::{manager::{Manager, commands::quit}, tasks::Tasks}; use crate::{mgr::{Mgr, commands::quit}, tasks::Tasks};
#[derive(Default)] #[derive(Default)]
struct Opt { struct Opt {
@ -13,7 +13,7 @@ impl From<Opt> for quit::Opt {
fn from(value: Opt) -> Self { Self { no_cwd_file: value.no_cwd_file } } fn from(value: Opt) -> Self { Self { no_cwd_file: value.no_cwd_file } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn close(&mut self, opt: Opt, tasks: &Tasks) { pub fn close(&mut self, opt: Opt, tasks: &Tasks) {
if self.tabs.len() > 1 { if self.tabs.len() > 1 {

View file

@ -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_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER};
use yazi_shared::{event::CmdCow, url::{Url, UrnBuf}}; use yazi_shared::{event::CmdCow, url::{Url, UrnBuf}};
use crate::manager::Manager; use crate::mgr::Mgr;
struct Opt { struct Opt {
dir: bool, dir: bool,
@ -18,7 +18,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } } fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn create(&self, opt: Opt) { pub fn create(&self, opt: Opt) {
let cwd = self.cwd().to_owned(); let cwd = self.cwd().to_owned();

View file

@ -1,6 +1,6 @@
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
struct Opt { struct Opt {
force: bool, force: bool,
@ -11,7 +11,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn hardlink(&mut self, opt: Opt, tasks: &Tasks) { pub fn hardlink(&mut self, opt: Opt, tasks: &Tasks) {
if self.yanked.cut { if self.yanked.cut {

View file

@ -4,7 +4,7 @@ use yazi_dds::Pubsub;
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}}; use yazi_shared::{Id, event::{CmdCow, Data}, url::{Url, Urn}};
use crate::manager::Manager; use crate::mgr::Mgr;
struct Opt { struct Opt {
url: Option<Url>, url: Option<Url>,
@ -20,7 +20,7 @@ impl From<Option<Url>> for Opt {
fn from(url: Option<Url>) -> Self { Self { url, tab: None } } fn from(url: Option<Url>) -> Self { Self { url, tab: None } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn hover(&mut self, opt: Opt) { pub fn hover(&mut self, opt: Opt) {
if let Some(u) = opt.url { if let Some(u) = opt.url {

View file

@ -1,6 +1,6 @@
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
struct Opt { struct Opt {
relative: bool, relative: bool,
@ -11,7 +11,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } } fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn link(&mut self, opt: Opt, tasks: &Tasks) { pub fn link(&mut self, opt: Opt, tasks: &Tasks) {
if self.yanked.cut { if self.yanked.cut {

View file

@ -6,10 +6,10 @@ use yazi_config::{OPEN, PLUGIN, popup::PickCfg};
use yazi_fs::File; use yazi_fs::File;
use yazi_macro::emit; use yazi_macro::emit;
use yazi_plugin::isolate; 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 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)] #[derive(Clone, Copy)]
struct Opt { struct Opt {
@ -23,7 +23,7 @@ impl From<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn open(&mut self, opt: Opt, tasks: &Tasks) { pub fn open(&mut self, opt: Opt, tasks: &Tasks) {
if !self.active_mut().try_escape_visual() { if !self.active_mut().try_escape_visual() {
@ -70,12 +70,7 @@ impl Manager {
} }
} }
ManagerProxy::open_do(OpenDoOpt { MgrProxy::open_do(OpenDoOpt { cwd, hovered, targets: done, interactive: opt.interactive });
cwd,
hovered,
targets: done,
interactive: opt.interactive,
});
}); });
} }

View file

@ -1,6 +1,6 @@
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
struct Opt { struct Opt {
force: bool, force: bool,
@ -11,7 +11,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } } fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn paste(&mut self, opt: Opt, tasks: &Tasks) { pub fn paste(&mut self, opt: Opt, tasks: &Tasks) {
let (src, dest) = (self.yanked.iter().collect::<Vec<_>>(), self.cwd()); let (src, dest) = (self.yanked.iter().collect::<Vec<_>>(), self.cwd());

View file

@ -1,7 +1,7 @@
use yazi_proxy::HIDER; use yazi_proxy::HIDER;
use yazi_shared::{event::{CmdCow, Data}, url::Url}; use yazi_shared::{event::{CmdCow, Data}, url::Url};
use crate::manager::Manager; use crate::mgr::Mgr;
#[derive(Debug, Default)] #[derive(Debug, Default)]
struct Opt { struct Opt {
@ -25,7 +25,7 @@ impl From<bool> for Opt {
fn from(force: bool) -> Self { Self { force, ..Default::default() } } fn from(force: bool) -> Self { Self { force, ..Default::default() } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn peek(&mut self, opt: Opt) { pub fn peek(&mut self, opt: Opt) {
let Some(hovered) = self.hovered().cloned() else { let Some(hovered) = self.hovered().cloned() else {

View file

@ -6,7 +6,7 @@ use yazi_macro::emit;
use yazi_proxy::ConfirmProxy; use yazi_proxy::ConfirmProxy;
use yazi_shared::event::{CmdCow, EventQuit}; use yazi_shared::event::{CmdCow, EventQuit};
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
#[derive(Default)] #[derive(Default)]
pub(super) struct Opt { pub(super) struct Opt {
@ -16,7 +16,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } } fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn quit(&self, opt: Opt, tasks: &Tasks) { pub fn quit(&self, opt: Opt, tasks: &Tasks) {
let opt = EventQuit { no_cwd_file: opt.no_cwd_file, ..Default::default() }; let opt = EventQuit { no_cwd_file: opt.no_cwd_file, ..Default::default() };

View file

@ -1,15 +1,15 @@
use std::path::MAIN_SEPARATOR; use std::path::MAIN_SEPARATOR;
use crossterm::{execute, terminal::SetTitle}; use crossterm::{execute, terminal::SetTitle};
use yazi_config::MANAGER; use yazi_config::MGR;
use yazi_fs::CWD; use yazi_fs::CWD;
use yazi_shared::event::CmdCow; 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) { 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(); execute!(std::io::stderr(), SetTitle(self.title())).ok();
} }
@ -35,6 +35,6 @@ impl Manager {
format!("{}", self.cwd().display()) format!("{}", self.cwd().display())
}; };
MANAGER.title_format.replace("{cwd}", &cwd) MGR.title_format.replace("{cwd}", &cwd)
} }
} }

View file

@ -1,8 +1,8 @@
use yazi_config::popup::ConfirmCfg; use yazi_config::popup::ConfirmCfg;
use yazi_proxy::{ConfirmProxy, ManagerProxy}; use yazi_proxy::{ConfirmProxy, MgrProxy};
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
struct Opt { struct Opt {
force: bool, force: bool,
@ -22,7 +22,7 @@ impl From<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn remove(&mut self, mut opt: Opt, tasks: &Tasks) { pub fn remove(&mut self, mut opt: Opt, tasks: &Tasks) {
if !self.active_mut().try_escape_visual() { if !self.active_mut().try_escape_visual() {
@ -49,7 +49,7 @@ impl Manager {
}); });
if result.await { if result.await {
ManagerProxy::remove_do(opt.targets, opt.permanently); MgrProxy::remove_do(opt.targets, opt.permanently);
} }
}); });
} }

View file

@ -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_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER};
use yazi_shared::{Id, event::CmdCow, url::{Url, UrnBuf}}; use yazi_shared::{Id, event::CmdCow, url::{Url, UrnBuf}};
use crate::manager::Manager; use crate::mgr::Mgr;
struct Opt { struct Opt {
hovered: bool, hovered: bool,
@ -28,7 +28,7 @@ impl From<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn rename(&mut self, opt: Opt) { pub fn rename(&mut self, opt: Opt) {
if !self.active_mut().try_escape_visual() { if !self.active_mut().try_escape_visual() {

View file

@ -2,7 +2,7 @@ use yazi_config::PLUGIN;
use yazi_plugin::isolate; use yazi_plugin::isolate;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::manager::Manager; use crate::mgr::Mgr;
#[derive(Debug)] #[derive(Debug)]
struct Opt { struct Opt {
@ -13,7 +13,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } } fn from(c: CmdCow) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn seek(&mut self, opt: Opt) { pub fn seek(&mut self, opt: Opt) {
let Some(hovered) = self.hovered() else { let Some(hovered) = self.hovered() else {

View file

@ -1,6 +1,6 @@
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::manager::Manager; use crate::mgr::Mgr;
struct Opt { struct Opt {
skip: Option<usize>, skip: Option<usize>,
@ -10,7 +10,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").and_then(Data::as_usize) } } fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").and_then(Data::as_usize) } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn spot(&mut self, opt: Opt) { pub fn spot(&mut self, opt: Opt) {
let Some(hovered) = self.hovered().cloned() else { let Some(hovered) = self.hovered().cloned() else {

View file

@ -1,8 +1,8 @@
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::manager::Manager; use crate::mgr::Mgr;
impl Manager { impl Mgr {
pub fn suspend(&mut self, _: CmdCow) { pub fn suspend(&mut self, _: CmdCow) {
#[cfg(unix)] #[cfg(unix)]
unsafe { unsafe {

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::manager::Tabs; use crate::mgr::Tabs;
struct Opt { struct Opt {
idx: usize, idx: usize,

View file

@ -3,7 +3,7 @@ use yazi_macro::render;
use yazi_proxy::AppProxy; use yazi_proxy::AppProxy;
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::{manager::Tabs, tab::Tab}; use crate::{mgr::Tabs, tab::Tab};
const MAX_TABS: usize = 9; const MAX_TABS: usize = 9;

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::manager::Tabs; use crate::mgr::Tabs;
struct Opt { struct Opt {
step: isize, step: isize,

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::manager::Tabs; use crate::mgr::Tabs;
struct Opt { struct Opt {
step: isize, step: isize,

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::manager::Manager; use crate::mgr::Mgr;
struct Opt; struct Opt;
@ -12,7 +12,7 @@ impl From<()> for Opt {
fn from(_: ()) -> Self { Self } fn from(_: ()) -> Self { Self }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn unyank(&mut self, _: Opt) { pub fn unyank(&mut self, _: Opt) {
let repeek = self.hovered().is_some_and(|f| f.is_dir() && self.yanked.contains_in(&f.url)); let repeek = self.hovered().is_some_and(|f| f.is_dir() && self.yanked.contains_in(&f.url));

View file

@ -2,10 +2,10 @@ use std::borrow::Cow;
use yazi_fs::FilesOp; use yazi_fs::FilesOp;
use yazi_macro::render; use yazi_macro::render;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::event::CmdCow; 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 { pub struct Opt {
op: FilesOp, op: FilesOp,
@ -19,7 +19,7 @@ impl TryFrom<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
pub fn update_files(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) { pub fn update_files(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
let Ok(opt) = opt.try_into() else { let Ok(opt) = opt.try_into() else {
return; return;
@ -79,8 +79,8 @@ impl Manager {
return; return;
} }
ManagerProxy::hover(None, tab.id); // Re-hover in next loop MgrProxy::hover(None, tab.id); // Re-hover in next loop
ManagerProxy::update_paged(); // Update for paged files in next loop MgrProxy::update_paged(); // Update for paged files in next loop
if calc { if calc {
tasks.prework_sorted(&tab.current.files); tasks.prework_sorted(&tab.current.files);
} }
@ -96,7 +96,7 @@ impl Manager {
} }
if !foreign { if !foreign {
ManagerProxy::peek(true); MgrProxy::peek(true);
} }
} }

View file

@ -4,7 +4,7 @@ use tracing::error;
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::{manager::{LINKED, Manager}, tasks::Tasks}; use crate::{mgr::{LINKED, Mgr}, tasks::Tasks};
pub struct Opt { pub struct Opt {
updates: HashMap<Cow<'static, str>, String>, updates: HashMap<Cow<'static, str>, String>,
@ -18,7 +18,7 @@ impl TryFrom<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
pub fn update_mimes(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) { pub fn update_mimes(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
let Ok(opt) = opt.try_into() else { let Ok(opt) = opt.try_into() else {
return error!("invalid arguments for update_mimes"); return error!("invalid arguments for update_mimes");

View file

@ -1,6 +1,6 @@
use yazi_shared::{event::{CmdCow, Data}, url::Url}; use yazi_shared::{event::{CmdCow, Data}, url::Url};
use crate::{manager::Manager, tasks::Tasks}; use crate::{mgr::Mgr, tasks::Tasks};
#[derive(Default)] #[derive(Default)]
pub struct Opt { pub struct Opt {
@ -18,7 +18,7 @@ impl From<()> for Opt {
fn from(_: ()) -> Self { Self::default() } fn from(_: ()) -> Self { Self::default() }
} }
impl Manager { impl Mgr {
pub fn update_paged(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) { pub fn update_paged(&mut self, opt: impl TryInto<Opt>, tasks: &Tasks) {
let Ok(opt) = opt.try_into() else { let Ok(opt) = opt.try_into() else {
return; return;

View file

@ -1,6 +1,6 @@
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::manager::Manager; use crate::mgr::Mgr;
pub struct Opt { pub struct Opt {
urls: Vec<Url>, urls: Vec<Url>,
@ -14,7 +14,7 @@ impl TryFrom<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
pub fn update_tasks(&mut self, opt: impl TryInto<Opt>) { pub fn update_tasks(&mut self, opt: impl TryInto<Opt>) {
let Ok(opt) = opt.try_into() else { let Ok(opt) = opt.try_into() else {
return; return;

View file

@ -3,7 +3,7 @@ use std::collections::HashSet;
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::manager::{Manager, Yanked}; use crate::mgr::{Mgr, Yanked};
#[derive(Default)] #[derive(Default)]
pub struct Opt { pub struct Opt {
@ -23,7 +23,7 @@ impl TryFrom<CmdCow> for Opt {
} }
} }
impl Manager { impl Mgr {
pub fn update_yanked(&mut self, opt: impl TryInto<Opt>) { pub fn update_yanked(&mut self, opt: impl TryInto<Opt>) {
let Ok(opt) = opt.try_into() else { return }; let Ok(opt) = opt.try_into() else { return };

View file

@ -1,7 +1,7 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::manager::{Manager, Yanked}; use crate::mgr::{Mgr, Yanked};
struct Opt { struct Opt {
cut: bool, cut: bool,
@ -11,7 +11,7 @@ impl From<CmdCow> for Opt {
fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } } fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } }
} }
impl Manager { impl Mgr {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn yank(&mut self, opt: Opt) { pub fn yank(&mut self, opt: Opt) {
if !self.active_mut().try_escape_visual() { if !self.active_mut().try_escape_visual() {

View file

@ -7,7 +7,7 @@ use yazi_shared::{Id, url::Url};
use super::{Mimetype, Tabs, Watcher, Yanked}; use super::{Mimetype, Tabs, Watcher, Yanked};
use crate::tab::{Folder, Tab}; use crate::tab::{Folder, Tab};
pub struct Manager { pub struct Mgr {
pub tabs: Tabs, pub tabs: Tabs,
pub yanked: Yanked, pub yanked: Yanked,
@ -15,7 +15,7 @@ pub struct Manager {
pub mimetype: Mimetype, pub mimetype: Mimetype,
} }
impl Manager { impl Mgr {
pub fn make() -> Self { pub fn make() -> Self {
Self { Self {
tabs: Tabs::make(), tabs: Tabs::make(),
@ -37,7 +37,7 @@ impl Manager {
pub fn shutdown(&mut self) { self.tabs.iter_mut().for_each(|t| t.shutdown()); } pub fn shutdown(&mut self) { self.tabs.iter_mut().for_each(|t| t.shutdown()); }
} }
impl Manager { impl Mgr {
#[inline] #[inline]
pub fn cwd(&self) -> &Url { self.active().cwd() } pub fn cwd(&self) -> &Url { self.active().cwd() }

3
yazi-core/src/mgr/mod.rs Normal file
View file

@ -0,0 +1,3 @@
yazi_macro::mod_pub!(commands);
yazi_macro::mod_flat!(linked mgr mimetype tabs watcher yanked);

View file

@ -3,7 +3,7 @@ use std::ops::{Deref, DerefMut};
use yazi_boot::BOOT; use yazi_boot::BOOT;
use yazi_dds::Pubsub; use yazi_dds::Pubsub;
use yazi_fs::File; use yazi_fs::File;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::{Id, url::Url}; use yazi_shared::{Id, url::Url};
use crate::tab::{Folder, Tab}; use crate::tab::{Folder, Tab};
@ -44,8 +44,8 @@ impl Tabs {
} }
self.cursor = idx; self.cursor = idx;
ManagerProxy::refresh(); MgrProxy::refresh();
ManagerProxy::peek(true); MgrProxy::peek(true);
Pubsub::pub_from_tab(self.active().id); Pubsub::pub_from_tab(self.active().id);
} }
} }

View file

@ -1,5 +1,5 @@
use yazi_macro::render; use yazi_macro::render;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::spot::Spot; use crate::spot::Spot;
@ -19,7 +19,7 @@ impl Spot {
let Some(old) = lock.selected() else { let Some(old) = lock.selected() else {
let new = self.skip.saturating_add_signed(opt.step); 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))); lock.select(Some(old.saturating_add_signed(opt.step)));

View file

@ -1,4 +1,4 @@
use yazi_proxy::{ManagerProxy, TabProxy}; use yazi_proxy::{MgrProxy, TabProxy};
use yazi_shared::event::{CmdCow, Data}; use yazi_shared::event::{CmdCow, Data};
use crate::spot::Spot; use crate::spot::Spot;
@ -15,6 +15,6 @@ impl Spot {
#[yazi_codegen::command] #[yazi_codegen::command]
pub fn swipe(&mut self, opt: Opt) { pub fn swipe(&mut self, opt: Opt) {
TabProxy::arrow(opt.step); TabProxy::arrow(opt.step);
ManagerProxy::spot(None); MgrProxy::spot(None);
} }
} }

View file

@ -1,6 +1,6 @@
use yazi_fs::Step; use yazi_fs::Step;
use yazi_macro::render; use yazi_macro::render;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::tab::Tab; 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!(); render!();
} }
} }

View file

@ -6,7 +6,7 @@ use yazi_config::popup::InputCfg;
use yazi_dds::Pubsub; use yazi_dds::Pubsub;
use yazi_fs::expand_path; use yazi_fs::expand_path;
use yazi_macro::render; 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 yazi_shared::{Debounce, errors::InputError, event::CmdCow, url::Url};
use crate::tab::Tab; use crate::tab::Tab;
@ -72,7 +72,7 @@ impl Tab {
} }
Pubsub::pub_from_cd(self.id, self.cwd()); Pubsub::pub_from_cd(self.id, self.cwd());
ManagerProxy::refresh(); MgrProxy::refresh();
render!(); render!();
} }

View file

@ -1,6 +1,6 @@
use bitflags::bitflags; use bitflags::bitflags;
use yazi_macro::{render, render_and}; use yazi_macro::{render, render_and};
use yazi_proxy::{AppProxy, ManagerProxy}; use yazi_proxy::{AppProxy, MgrProxy};
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::tab::Tab; use crate::tab::Tab;
@ -87,7 +87,7 @@ impl Tab {
self.selected.clear(); self.selected.clear();
if self.hovered().is_some_and(|h| h.is_dir()) { if self.hovered().is_some_and(|h| h.is_dir()) {
ManagerProxy::peek(true); MgrProxy::peek(true);
} }
render_and!(true) render_and!(true)
} }

View file

@ -45,7 +45,7 @@ impl Tab {
.with_bool("smart", opt.case == FilterCase::Smart) .with_bool("smart", opt.case == FilterCase::Smart)
.with_bool("insensitive", opt.case == FilterCase::Insensitive) .with_bool("insensitive", opt.case == FilterCase::Insensitive)
.with_bool("done", done), .with_bool("done", done),
Layer::Manager Layer::Mgr
)); ));
} }
}); });

View file

@ -1,6 +1,6 @@
use yazi_fs::Filter; use yazi_fs::Filter;
use yazi_macro::render; use yazi_macro::render;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use super::filter::Opt; use super::filter::Opt;
use crate::tab::Tab; use crate::tab::Tab;
@ -17,7 +17,7 @@ impl Tab {
}; };
if opt.done { 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()); let hovered = self.hovered().map(|f| f.urn_owned());
@ -27,7 +27,7 @@ impl Tab {
self.current.repos(hovered.as_ref()); self.current.repos(hovered.as_ref());
if self.hovered().map(|f| f.urn()) != hovered.as_ref().map(|u| u.as_urn()) { 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!(); render!();

View file

@ -37,7 +37,7 @@ impl Tab {
.with_bool("previous", opt.prev) .with_bool("previous", opt.prev)
.with_bool("smart", opt.case == FilterCase::Smart) .with_bool("smart", opt.case == FilterCase::Smart)
.with_bool("insensitive", opt.case == FilterCase::Insensitive), .with_bool("insensitive", opt.case == FilterCase::Insensitive),
Layer::Manager Layer::Mgr
)); ));
} }
}); });

View file

@ -1,4 +1,4 @@
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::tab::Tab; use crate::tab::Tab;
@ -15,10 +15,10 @@ impl Tab {
self.apply_files_attrs(); self.apply_files_attrs();
if hovered.as_ref() != self.hovered().map(|f| &f.url) { 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()) { } else if self.hovered().is_some_and(|f| f.is_dir()) {
ManagerProxy::peek(true); MgrProxy::peek(true);
} }
ManagerProxy::update_paged(); MgrProxy::update_paged();
} }
} }

View file

@ -1,5 +1,5 @@
use yazi_fs::{File, FilesOp, expand_path}; use yazi_fs::{File, FilesOp, expand_path};
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::{event::CmdCow, url::Url}; use yazi_shared::{event::CmdCow, url::Url};
use crate::tab::Tab; use crate::tab::Tab;
@ -31,6 +31,6 @@ impl Tab {
self.cd(parent.clone()); self.cd(parent.clone());
FilesOp::Creating(parent, vec![File::from_dummy(opt.target.clone(), None)]).emit(); 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);
} }
} }

View file

@ -7,7 +7,7 @@ use tracing::error;
use yazi_config::popup::InputCfg; use yazi_config::popup::InputCfg;
use yazi_fs::{Cha, FilesOp}; use yazi_fs::{Cha, FilesOp};
use yazi_plugin::external; 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; use crate::tab::Tab;
@ -91,7 +91,7 @@ impl Tab {
if self.cwd().is_search() { if self.cwd().is_search() {
let rep = self.history.remove_or(&self.cwd().to_regular()); let rep = self.history.remove_or(&self.cwd().to_regular());
drop(mem::replace(&mut self.current, rep)); drop(mem::replace(&mut self.current, rep));
ManagerProxy::refresh(); MgrProxy::refresh();
} }
} }
} }

View file

@ -1,7 +1,7 @@
use std::str::FromStr; use std::str::FromStr;
use yazi_fs::SortBy; use yazi_fs::SortBy;
use yazi_proxy::ManagerProxy; use yazi_proxy::MgrProxy;
use yazi_shared::event::CmdCow; use yazi_shared::event::CmdCow;
use crate::{tab::Tab, tasks::Tasks}; use crate::{tab::Tab, tasks::Tasks};
@ -20,8 +20,8 @@ impl Tab {
self.apply_files_attrs(); self.apply_files_attrs();
ManagerProxy::hover(None, self.id); MgrProxy::hover(None, self.id);
ManagerProxy::update_paged(); MgrProxy::update_paged();
tasks.prework_sorted(&self.current.files); tasks.prework_sorted(&self.current.files);
} }

View file

@ -1,9 +1,9 @@
use std::mem; use std::mem;
use yazi_config::{LAYOUT, MANAGER}; use yazi_config::{LAYOUT, MGR};
use yazi_dds::Pubsub; use yazi_dds::Pubsub;
use yazi_fs::{Cha, File, Files, FilesOp, FolderStage, Step}; 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}}; use yazi_shared::{Id, url::{Url, Urn, UrnBuf}};
pub struct Folder { pub struct Folder {
@ -24,7 +24,7 @@ impl Default for Folder {
Self { Self {
url: Default::default(), url: Default::default(),
cha: Default::default(), cha: Default::default(),
files: Files::new(MANAGER.show_hidden), files: Files::new(MGR.show_hidden),
stage: Default::default(), stage: Default::default(),
offset: Default::default(), offset: Default::default(),
cursor: Default::default(), cursor: Default::default(),
@ -131,7 +131,7 @@ impl Folder {
let new = self.cursor / limit; let new = self.cursor / limit;
if mem::replace(&mut self.page, new) != new || force { 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 len = self.files.len();
let limit = LAYOUT.get().current.height as usize; 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.cursor = step.add(self.cursor, limit).min(len.saturating_sub(1));
self.offset = if self.cursor < (self.offset + limit).min(len).saturating_sub(scrolloff) { 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 max = self.files.len().saturating_sub(1);
let limit = LAYOUT.get().current.height as usize; 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.cursor = step.add(self.cursor, limit).min(max);
self.offset = if self.cursor < self.offset + scrolloff { self.offset = if self.cursor < self.offset + scrolloff {
@ -174,7 +174,7 @@ impl Folder {
let len = self.files.len(); let len = self.files.len();
let limit = LAYOUT.get().current.height as usize; 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) { self.offset = if self.cursor < (self.offset + limit).min(len).saturating_sub(scrolloff) {
len.saturating_sub(limit).min(self.offset) len.saturating_sub(limit).min(self.offset)

View file

@ -1,4 +1,4 @@
use yazi_config::MANAGER; use yazi_config::MGR;
use yazi_fs::{FilesSorter, SortBy}; use yazi_fs::{FilesSorter, SortBy};
#[derive(Clone, PartialEq)] #[derive(Clone, PartialEq)]
@ -19,15 +19,15 @@ impl Default for Preference {
fn default() -> Self { fn default() -> Self {
Self { Self {
// Sorting // Sorting
sort_by: MANAGER.sort_by, sort_by: MGR.sort_by,
sort_sensitive: MANAGER.sort_sensitive, sort_sensitive: MGR.sort_sensitive,
sort_reverse: MANAGER.sort_reverse, sort_reverse: MGR.sort_reverse,
sort_dir_first: MANAGER.sort_dir_first, sort_dir_first: MGR.sort_dir_first,
sort_translit: MANAGER.sort_translit, sort_translit: MGR.sort_translit,
// Display // Display
linemode: MANAGER.linemode.to_owned(), linemode: MGR.linemode.to_owned(),
show_hidden: MANAGER.show_hidden, show_hidden: MGR.show_hidden,
} }
} }
} }

View file

@ -2,7 +2,7 @@ use yazi_config::{PLUGIN, plugin::MAX_PREWORKERS};
use yazi_fs::{File, Files, SortBy}; use yazi_fs::{File, Files, SortBy};
use super::Tasks; use super::Tasks;
use crate::manager::Mimetype; use crate::mgr::Mimetype;
impl Tasks { impl Tasks {
pub fn fetch_paged(&self, paged: &[File], mimetype: &Mimetype) { pub fn fetch_paged(&self, paged: &[File], mimetype: &Mimetype) {

View file

@ -1,7 +1,7 @@
use crossterm::event::{MouseEvent, MouseEventKind}; use crossterm::event::{MouseEvent, MouseEventKind};
use mlua::{ObjectLike, Table}; use mlua::{ObjectLike, Table};
use tracing::error; use tracing::error;
use yazi_config::MANAGER; use yazi_config::MGR;
use yazi_plugin::LUA; use yazi_plugin::LUA;
use crate::{app::App, lives::Lives}; use crate::{app::App, lives::Lives};
@ -24,7 +24,7 @@ impl App {
let area = yazi_plugin::elements::Rect::from(size); let area = yazi_plugin::elements::Rect::from(size);
let root = LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("new", area)?; let root = LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("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)?; root.raw_set("_drag_start", event)?;
} }

View file

@ -8,7 +8,7 @@ use crate::{Term, app::App};
impl App { impl App {
pub(crate) fn quit(&mut self, opt: EventQuit) -> ! { pub(crate) fn quit(&mut self, opt: EventQuit) -> ! {
self.cx.tasks.shutdown(); 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::shutdown());
futures::executor::block_on(yazi_dds::STATE.drain()).ok(); futures::executor::block_on(yazi_dds::STATE.drain()).ok();
@ -24,7 +24,7 @@ impl App {
fn cwd_to_file(&self) { fn cwd_to_file(&self) {
if let Some(p) = &ARGS.cwd_file { 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(); std::fs::write(p, cwd.as_encoded_bytes()).ok();
} }
} }

View file

@ -36,7 +36,7 @@ impl App {
// Reload preview if collision is resolved // Reload preview if collision is resolved
if collision && !COLLISION.load(Ordering::Relaxed) { if collision && !COLLISION.load(Ordering::Relaxed) {
self.cx.manager.peek(true); self.cx.mgr.peek(true);
} }
} }

View file

@ -19,7 +19,7 @@ impl App {
self.reflow(()); self.reflow(());
self.cx.current_mut().sync_page(true); self.cx.current_mut().sync_page(true);
self.cx.manager.hover(None); self.cx.mgr.hover(None);
self.cx.manager.parent_mut().map(|f| f.arrow(0)); self.cx.mgr.parent_mut().map(|f| f.arrow(0));
} }
} }

View file

@ -40,7 +40,7 @@ impl Widget for Completion<'_> {
}) })
.collect(); .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 { let mut area = Position::sticky(Dimension::available(), input_area, Offset {
x: 1, x: 1,
y: 0, y: 0,

View file

@ -14,7 +14,7 @@ impl<'a> Confirm<'a> {
impl Widget for Confirm<'_> { impl Widget for Confirm<'_> {
fn render(self, _: Rect, buf: &mut Buffer) { fn render(self, _: Rect, buf: &mut Buffer) {
let confirm = &self.cx.confirm; 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); yazi_plugin::elements::Clear::default().render(area, buf);

View file

@ -1,9 +1,9 @@
use ratatui::layout::Rect; 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; use yazi_shared::Layer;
pub struct Ctx { pub struct Ctx {
pub manager: Manager, pub mgr: Mgr,
pub tasks: Tasks, pub tasks: Tasks,
pub pick: Pick, pub pick: Pick,
pub input: Input, pub input: Input,
@ -17,7 +17,7 @@ pub struct Ctx {
impl Ctx { impl Ctx {
pub fn make() -> Self { pub fn make() -> Self {
Self { Self {
manager: Manager::make(), mgr: Mgr::make(),
tasks: Tasks::serve(), tasks: Tasks::serve(),
pick: Default::default(), pick: Default::default(),
input: Default::default(), input: Default::default(),
@ -32,7 +32,7 @@ impl Ctx {
#[inline] #[inline]
pub fn cursor(&self) -> Option<(u16, u16)> { pub fn cursor(&self) -> Option<(u16, u16)> {
if self.input.visible { 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)); return Some((x + 1 + self.input.cursor(), y + 1));
} }
if let Some((x, y)) = self.help.cursor() { if let Some((x, y)) = self.help.cursor() {
@ -60,21 +60,21 @@ impl Ctx {
} else if self.tasks.visible { } else if self.tasks.visible {
Layer::Tasks Layer::Tasks
} else { } else {
Layer::Manager Layer::Mgr
} }
} }
} }
impl Ctx { impl Ctx {
#[inline] #[inline]
pub fn active(&self) -> &Tab { self.manager.active() } pub fn active(&self) -> &Tab { self.mgr.active() }
#[inline] #[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] #[inline]
pub fn current(&self) -> &Folder { self.manager.current() } pub fn current(&self) -> &Folder { self.mgr.current() }
#[inline] #[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() }
} }

View file

@ -15,7 +15,7 @@ impl<'a> Executor<'a> {
pub(super) fn execute(&mut self, cmd: CmdCow, layer: Layer) { pub(super) fn execute(&mut self, cmd: CmdCow, layer: Layer) {
match layer { match layer {
Layer::App => self.app(cmd), Layer::App => self.app(cmd),
Layer::Manager => self.manager(cmd), Layer::Mgr => self.mgr(cmd),
Layer::Tasks => self.tasks(cmd), Layer::Tasks => self.tasks(cmd),
Layer::Spot => self.spot(cmd), Layer::Spot => self.spot(cmd),
Layer::Pick => self.pick(cmd), Layer::Pick => self.pick(cmd),
@ -47,44 +47,44 @@ impl<'a> Executor<'a> {
on!(resume); on!(resume);
} }
fn manager(&mut self, cmd: CmdCow) { fn mgr(&mut self, cmd: CmdCow) {
macro_rules! on { macro_rules! on {
(MANAGER, $name:ident $(,$args:expr)*) => { (MGR, $name:ident $(,$args:expr)*) => {
if cmd.name == stringify!($name) { 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)*) => { (ACTIVE, $name:ident $(,$args:expr)*) => {
if cmd.name == stringify!($name) { if cmd.name == stringify!($name) {
return if let Some(tab) = cmd.get("tab") { return if let Some(tab) = cmd.get("tab") {
let Some(id) = tab.as_id() else { return }; 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),*) tab.$name(cmd, $($args),*)
} else { } else {
self.app.cx.manager.active_mut().$name(cmd, $($args),*) self.app.cx.mgr.active_mut().$name(cmd, $($args),*)
}; };
} }
}; };
(TABS, $name:ident) => { (TABS, $name:ident) => {
if cmd.name == concat!("tab_", stringify!($name)) { 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!(MGR, update_tasks);
on!(MANAGER, update_files, &self.app.cx.tasks); on!(MGR, update_files, &self.app.cx.tasks);
on!(MANAGER, update_mimes, &self.app.cx.tasks); on!(MGR, update_mimes, &self.app.cx.tasks);
on!(MANAGER, update_paged, &self.app.cx.tasks); on!(MGR, update_paged, &self.app.cx.tasks);
on!(MANAGER, update_yanked); on!(MGR, update_yanked);
on!(MANAGER, hover); on!(MGR, hover);
on!(MANAGER, peek); on!(MGR, peek);
on!(MANAGER, seek); on!(MGR, seek);
on!(MANAGER, spot); on!(MGR, spot);
on!(MANAGER, refresh, &self.app.cx.tasks); on!(MGR, refresh, &self.app.cx.tasks);
on!(MANAGER, quit, &self.app.cx.tasks); on!(MGR, quit, &self.app.cx.tasks);
on!(MANAGER, close, &self.app.cx.tasks); on!(MGR, close, &self.app.cx.tasks);
on!(MANAGER, suspend); on!(MGR, suspend);
on!(ACTIVE, escape); on!(ACTIVE, escape);
on!(ACTIVE, update_peeked); on!(ACTIVE, update_peeked);
on!(ACTIVE, update_spotted); on!(ACTIVE, update_spotted);
@ -104,17 +104,17 @@ impl<'a> Executor<'a> {
on!(ACTIVE, visual_mode); on!(ACTIVE, visual_mode);
// Operation // Operation
on!(MANAGER, open, &self.app.cx.tasks); on!(MGR, open, &self.app.cx.tasks);
on!(MANAGER, open_do, &self.app.cx.tasks); on!(MGR, open_do, &self.app.cx.tasks);
on!(MANAGER, yank); on!(MGR, yank);
on!(MANAGER, unyank); on!(MGR, unyank);
on!(MANAGER, paste, &self.app.cx.tasks); on!(MGR, paste, &self.app.cx.tasks);
on!(MANAGER, link, &self.app.cx.tasks); on!(MGR, link, &self.app.cx.tasks);
on!(MANAGER, hardlink, &self.app.cx.tasks); on!(MGR, hardlink, &self.app.cx.tasks);
on!(MANAGER, remove, &self.app.cx.tasks); on!(MGR, remove, &self.app.cx.tasks);
on!(MANAGER, remove_do, &self.app.cx.tasks); on!(MGR, remove_do, &self.app.cx.tasks);
on!(MANAGER, create); on!(MGR, create);
on!(MANAGER, rename); on!(MGR, rename);
on!(ACTIVE, copy); on!(ACTIVE, copy);
on!(ACTIVE, shell); on!(ACTIVE, shell);
on!(ACTIVE, hidden); on!(ACTIVE, hidden);
@ -144,7 +144,7 @@ impl<'a> Executor<'a> {
// Tasks // Tasks
"tasks_show" => self.app.cx.tasks.toggle(()), "tasks_show" => self.app.cx.tasks.toggle(()),
// Help // Help
"help" => self.app.cx.help.toggle(Layer::Manager), "help" => self.app.cx.help.toggle(Layer::Mgr),
// Plugin // Plugin
"plugin" => self.app.plugin(cmd), "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!(show);
on!(close); on!(close);
} }

View file

@ -34,7 +34,7 @@ impl<'a> Input<'a> {
impl Widget for Input<'_> { impl Widget for Input<'_> {
fn render(self, win: Rect, buf: &mut Buffer) { fn render(self, win: Rect, buf: &mut Buffer) {
let input = &self.cx.input; 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); yazi_plugin::elements::Clear::default().render(area, buf);
Paragraph::new(self.highlighted_value().unwrap_or_else(|_| Line::from(input.value()))) Paragraph::new(self.highlighted_value().unwrap_or_else(|_| Line::from(input.value())))

View file

@ -26,9 +26,9 @@ impl UserData for Ctx {
methods.add_meta_method(MetaMethod::Index, |lua, me, key: mlua::String| { methods.add_meta_method(MetaMethod::Index, |lua, me, key: mlua::String| {
match key.as_bytes().as_ref() { match key.as_bytes().as_ref() {
b"active" => super::Tab::make(me.active())?, 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"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), b"layer" => return yazi_plugin::bindings::Layer::from(me.layer()).into_lua(lua),
_ => return Ok(Value::Nil), _ => return Ok(Value::Nil),
} }

View file

@ -55,7 +55,7 @@ impl UserData for File {
}); });
methods.add_method("mime", |lua, me, ()| { methods.add_method("mime", |lua, me, ()| {
lua.named_registry_value::<AnyUserData>("cx")?.borrow_scoped(|cx: &Ctx| { lua.named_registry_value::<AnyUserData>("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, ()| { methods.add_method("prefix", |lua, me, ()| {
@ -69,16 +69,16 @@ impl UserData for File {
}); });
methods.add_method("style", |lua, me, ()| { methods.add_method("style", |lua, me, ()| {
lua.named_registry_value::<AnyUserData>("cx")?.borrow_scoped(|cx: &Ctx| { lua.named_registry_value::<AnyUserData>("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)) 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_hovered", |_, me, ()| Ok(me.idx == me.folder().cursor));
methods.add_method("is_yanked", |lua, me, ()| { methods.add_method("is_yanked", |lua, me, ()| {
lua.named_registry_value::<AnyUserData>("cx")?.borrow_scoped(|cx: &Ctx| { lua.named_registry_value::<AnyUserData>("cx")?.borrow_scoped(|cx: &Ctx| {
if !cx.manager.yanked.contains(&me.url) { if !cx.mgr.yanked.contains(&me.url) {
0u8 0u8
} else if cx.manager.yanked.cut { } else if cx.mgr.yanked.cut {
2u8 2u8
} else { } else {
1u8 1u8

View file

@ -5,18 +5,18 @@ use mlua::{AnyUserData, MetaMethod, UserData, UserDataFields, UserDataMethods};
use super::{Lives, Tab}; use super::{Lives, Tab};
pub(super) struct Tabs { pub(super) struct Tabs {
inner: *const yazi_core::manager::Tabs, inner: *const yazi_core::mgr::Tabs,
} }
impl Deref for 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 } } fn deref(&self) -> &Self::Target { unsafe { &*self.inner } }
} }
impl Tabs { impl Tabs {
#[inline] #[inline]
pub(super) fn make(inner: &yazi_core::manager::Tabs) -> mlua::Result<AnyUserData> { pub(super) fn make(inner: &yazi_core::mgr::Tabs) -> mlua::Result<AnyUserData> {
Lives::scoped_userdata(Self { inner }) Lives::scoped_userdata(Self { inner })
} }
} }

View file

@ -6,23 +6,23 @@ use yazi_plugin::url::Url;
use super::{Iter, Lives}; use super::{Iter, Lives};
pub(super) struct Yanked { pub(super) struct Yanked {
inner: *const yazi_core::manager::Yanked, inner: *const yazi_core::mgr::Yanked,
} }
impl Deref for Yanked { impl Deref for Yanked {
type Target = yazi_core::manager::Yanked; type Target = yazi_core::mgr::Yanked;
fn deref(&self) -> &Self::Target { self.inner() } fn deref(&self) -> &Self::Target { self.inner() }
} }
impl Yanked { impl Yanked {
#[inline] #[inline]
pub(super) fn make(inner: &yazi_core::manager::Yanked) -> mlua::Result<AnyUserData> { pub(super) fn make(inner: &yazi_core::mgr::Yanked) -> mlua::Result<AnyUserData> {
Lives::scoped_userdata(Self { inner }) Lives::scoped_userdata(Self { inner })
} }
#[inline] #[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 { impl UserData for Yanked {

View file

@ -4,7 +4,7 @@
#[global_allocator] #[global_allocator]
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; 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); yazi_macro::mod_flat!(context executor logs panic root router signals term);

View file

@ -20,7 +20,7 @@ impl Widget for Modal<'_> {
let area = yazi_plugin::elements::Rect::from(area); let area = yazi_plugin::elements::Rect::from(area);
let root = LUA.globals().raw_get::<Table>("Modal")?.call_method::<Table>("new", area)?; let root = LUA.globals().raw_get::<Table>("Modal")?.call_method::<Table>("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>(()) Ok::<_, mlua::Error>(())
}; };
if let Err(e) = f() { if let Err(e) = f() {

View file

@ -23,7 +23,7 @@ impl Widget for Preview<'_> {
} }
for w in &lock.data { 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));
} }
} }
} }

View file

@ -14,7 +14,7 @@ impl<'a> Pick<'a> {
impl Widget for Pick<'_> { impl Widget for Pick<'_> {
fn render(self, _: Rect, buf: &mut Buffer) { fn render(self, _: Rect, buf: &mut Buffer) {
let pick = &self.cx.pick; 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 let items: Vec<_> = pick
.window() .window()

View file

@ -3,7 +3,7 @@ use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tracing::error; use tracing::error;
use yazi_plugin::{LUA, elements::render_once}; 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; use crate::Ctx;
pub(super) struct Root<'a> { pub(super) struct Root<'a> {
@ -26,15 +26,15 @@ impl Widget for Root<'_> {
let area = yazi_plugin::elements::Rect::from(area); let area = yazi_plugin::elements::Rect::from(area);
let root = LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("new", area)?; let root = LUA.globals().raw_get::<Table>("Root")?.call_method::<Table>("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>(()) Ok::<_, mlua::Error>(())
}; };
if let Err(e) = f() { if let Err(e) = f() {
error!("Failed to redraw the `Root` component:\n{e}"); error!("Failed to redraw the `Root` component:\n{e}");
} }
manager::Preview::new(self.cx).render(area, buf); mgr::Preview::new(self.cx).render(area, buf);
manager::Modal::new(self.cx).render(area, buf); mgr::Modal::new(self.cx).render(area, buf);
if self.cx.tasks.visible { if self.cx.tasks.visible {
tasks::Tasks::new(self.cx).render(area, buf); tasks::Tasks::new(self.cx).render(area, buf);

View file

@ -27,7 +27,7 @@ impl<'a> Router<'a> {
use Layer as L; use Layer as L;
match layer { match layer {
L::App => unreachable!(), 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) self.matches(layer, key)
} }
L::Completion => self.matches(L::Completion, key) || self.matches(L::Input, key), L::Completion => self.matches(L::Completion, key) || self.matches(L::Input, key),

View file

@ -2,7 +2,7 @@ use anyhow::Result;
use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind}; use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEvent, KeyEventKind};
use futures::StreamExt; use futures::StreamExt;
use tokio::{select, sync::{mpsc, oneshot}}; use tokio::{select, sync::{mpsc, oneshot}};
use yazi_config::MANAGER; use yazi_config::MGR;
use yazi_shared::event::Event; use yazi_shared::event::Event;
pub(super) struct Signals { pub(super) struct Signals {
@ -62,7 +62,7 @@ impl Signals {
Event::Key(key).emit() Event::Key(key).emit()
} }
CrosstermEvent::Mouse(mouse) => { CrosstermEvent::Mouse(mouse) => {
if MANAGER.mouse_events.contains(mouse.kind.into()) { if MGR.mouse_events.contains(mouse.kind.into()) {
Event::Mouse(mouse).emit(); Event::Mouse(mouse).emit();
} }
} }

View file

@ -17,7 +17,7 @@ impl Widget for Spot<'_> {
}; };
for w in &lock.data { 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));
} }
} }
} }

View file

@ -21,7 +21,7 @@ impl Widget for Progress<'_> {
let progress = let progress =
LUA.globals().raw_get::<Table>("Progress")?.call_method::<Table>("use", area)?; LUA.globals().raw_get::<Table>("Progress")?.call_method::<Table>("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>(()) Ok::<_, mlua::Error>(())
}; };
if let Err(e) = f() { if let Err(e) = f() {

View file

@ -5,7 +5,7 @@ use crossterm::{event::{DisableBracketedPaste, EnableBracketedPaste, KeyboardEnh
use cursor::RestoreCursor; use cursor::RestoreCursor;
use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect}; use ratatui::{CompletedFrame, Frame, Terminal, backend::CrosstermBackend, buffer::Buffer, layout::Rect};
use yazi_adapter::{Emulator, Mux}; use yazi_adapter::{Emulator, Mux};
use yazi_config::{INPUT, MANAGER}; use yazi_config::{INPUT, MGR};
static CSI_U: AtomicBool = AtomicBool::new(false); static CSI_U: AtomicBool = AtomicBool::new(false);
static BLINK: AtomicBool = AtomicBool::new(false); static BLINK: AtomicBool = AtomicBool::new(false);
@ -94,7 +94,7 @@ impl Term {
execute!(stderr(), PopKeyboardEnhancementFlags).ok(); execute!(stderr(), PopKeyboardEnhancementFlags).ok();
} }
if !MANAGER.title_format.is_empty() { if !MGR.title_format.is_empty() {
execute!(stderr(), SetTitle("")).ok(); execute!(stderr(), SetTitle("")).ok();
} }
@ -190,13 +190,13 @@ impl DerefMut for Term {
// --- Mouse support // --- Mouse support
mod mouse { mod mouse {
use crossterm::event::{DisableMouseCapture, EnableMouseCapture}; use crossterm::event::{DisableMouseCapture, EnableMouseCapture};
use yazi_config::MANAGER; use yazi_config::MGR;
pub struct SetMouse(pub bool); pub struct SetMouse(pub bool);
impl crossterm::Command for SetMouse { impl crossterm::Command for SetMouse {
fn write_ansi(&self, f: &mut impl std::fmt::Write) -> std::fmt::Result { 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(()) Ok(())
} else if self.0 { } else if self.0 {
EnableMouseCapture.write_ansi(f) EnableMouseCapture.write_ansi(f)
@ -207,7 +207,7 @@ mod mouse {
#[cfg(windows)] #[cfg(windows)]
fn execute_winapi(&self) -> std::io::Result<()> { fn execute_winapi(&self) -> std::io::Result<()> {
if MANAGER.mouse_events.is_empty() { if MGR.mouse_events.is_empty() {
Ok(()) Ok(())
} else if self.0 { } else if self.0 {
EnableMouseCapture.execute_winapi() EnableMouseCapture.execute_winapi()

View file

@ -41,7 +41,7 @@ impl FilesOp {
pub fn emit(self) { pub fn emit(self) {
yazi_shared::event::Event::Call( yazi_shared::event::Event::Call(
Cmd::new("update_files").with_any("op", self).into(), Cmd::new("update_files").with_any("op", self).into(),
Layer::Manager, Layer::Mgr,
) )
.emit(); .emit();
} }

View file

@ -55,12 +55,12 @@ function Current:click(event, up)
return return
end 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 if event.is_right then
ya.manager_emit("open", {}) ya.mgr_emit("open", {})
end end
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 function Current:touch(event, step) end

View file

@ -42,7 +42,7 @@ function Entity:highlights()
if h[1] > last then if h[1] > last then
spans[#spans + 1] = name:sub(last + 1, h[1]) spans[#spans + 1] = name:sub(last + 1, h[1])
end 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] last = h[2]
end end
if last < #name then if last < #name then
@ -64,11 +64,11 @@ function Entity:found()
end end
local s = string.format("[%d/%s]", found[1] + 1, found[2] >= 100 and "99+" or found[2]) 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 end
function Entity:symlink() function Entity:symlink()
if not rt.manager.show_symlink then if not rt.mgr.show_symlink then
return "" return ""
end end
@ -89,9 +89,9 @@ function Entity:style()
if not self._file:is_hovered() then if not self._file:is_hovered() then
return s return s
elseif self._file:in_preview() then 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 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
end end

View file

@ -28,7 +28,7 @@ function Header:cwd()
end end
local s = ya.readable_path(tostring(self._current.cwd)) .. self:flags() 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 end
function Header:flags() function Header:flags()
@ -55,13 +55,13 @@ function Header:count()
local count, style local count, style
if yanked == 0 then if yanked == 0 then
count = #self._tab.selected count = #self._tab.selected
style = th.manager.count_selected style = th.mgr.count_selected
elseif cx.yanked.is_cut then elseif cx.yanked.is_cut then
count = yanked count = yanked
style = th.manager.count_cut style = th.mgr.count_cut
else else
count = yanked count = yanked
style = th.manager.count_copied style = th.mgr.count_copied
end end
if count == 0 then if count == 0 then
@ -83,13 +83,13 @@ function Header:tabs()
local spans = {} local spans = {}
for i = 1, tabs do for i = 1, tabs do
local text = i local text = i
if th.manager.tab_width > 2 then if th.mgr.tab_width > 2 then
text = ya.truncate(text .. " " .. cx.tabs[i]:name(), { max = th.manager.tab_width }) text = ya.truncate(text .. " " .. cx.tabs[i]:name(), { max = th.mgr.tab_width })
end end
if i == cx.tabs.idx then 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 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
end end
return ui.Line(spans) return ui.Line(spans)

View file

@ -50,16 +50,16 @@ end
function Marker:style(file) function Marker:style(file)
local marked = file:is_marked() local marked = file:is_marked()
if marked == 1 then if marked == 1 then
return th.manager.marker_marked return th.mgr.marker_marked
elseif marked == 0 and file:is_selected() then elseif marked == 0 and file:is_selected() then
return th.manager.marker_selected return th.mgr.marker_selected
end end
local yanked = file:is_yanked() local yanked = file:is_yanked()
if yanked == 1 then if yanked == 1 then
return th.manager.marker_copied return th.mgr.marker_copied
elseif yanked == 2 then elseif yanked == 2 then
return th.manager.marker_cut return th.mgr.marker_cut
end end
end end

View file

@ -36,9 +36,9 @@ function Parent:click(event, up)
local y = event.y - self._area.y + 1 local y = event.y - self._area.y + 1
local window = self._folder and self._folder.window or {} local window = self._folder and self._folder.window or {}
if window[y] then if window[y] then
ya.manager_emit("reveal", { window[y].url }) ya.mgr_emit("reveal", { window[y].url })
else else
ya.manager_emit("leave", {}) ya.mgr_emit("leave", {})
end end
end end

View file

@ -23,12 +23,12 @@ function Preview:click(event, up)
local y = event.y - self._area.y + 1 local y = event.y - self._area.y + 1
local window = self._folder and self._folder.window or {} local window = self._folder and self._folder.window or {}
if window[y] then if window[y] then
ya.manager_emit("reveal", { window[y].url }) ya.mgr_emit("reveal", { window[y].url })
else else
ya.manager_emit("enter", {}) ya.mgr_emit("enter", {})
end end
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 function Preview:touch(event, step) end

View file

@ -10,8 +10,8 @@ end
function Rail:build() function Rail:build()
self._base = { 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.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.manager.border_symbol):style(th.manager.border_style), ui.Bar(ui.Bar.LEFT):area(self._chunks[3]):symbol(th.mgr.border_symbol):style(th.mgr.border_style),
} }
self._children = { self._children = {
Marker:new(self._chunks[1], self._tab.parent), Marker:new(self._chunks[1], self._tab.parent),

View file

@ -48,7 +48,7 @@ end
-- Mouse events -- Mouse events
function Root:click(event, up) function Root:click(event, up)
if tostring(cx.layer) ~= "manager" then if tostring(cx.layer) ~= "mgr" then
return return
end end
local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) 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 end
function Root:scroll(event, step) function Root:scroll(event, step)
if tostring(cx.layer) ~= "manager" then if tostring(cx.layer) ~= "mgr" then
return return
end end
local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) 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 end
function Root:touch(event, step) function Root:touch(event, step)
if tostring(cx.layer) ~= "manager" then if tostring(cx.layer) ~= "mgr" then
return return
end end
local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow()) local c = ya.child_at(ui.Rect { x = event.x, y = event.y }, self:reflow())

View file

@ -10,7 +10,7 @@ function Tab:new(area, tab)
end end
function Tab:layout() function Tab:layout()
local ratio = rt.manager.ratio local ratio = rt.mgr.ratio
self._chunks = ui.Layout() self._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL) :direction(ui.Layout.HORIZONTAL)
:constraints({ :constraints({

View file

@ -33,7 +33,7 @@ function M:peek(job)
end end
if job.skip > 0 and bound < job.skip + limit then 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 else
ya.preview_widgets(job, { ya.preview_widgets(job, {
ui.Text(paths):area(job.area), ui.Text(paths):area(job.area),

View file

@ -3,7 +3,7 @@ local M = {}
function M:peek(job) function M:peek(job)
local err, bound = ya.preview_code(job) local err, bound = ya.preview_code(job)
if bound then 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 elseif err and not err:find("cancelled", 1, true) then
require("empty").msg(job, err) require("empty").msg(job, err)
end end
@ -18,7 +18,7 @@ function M:seek(job)
local step = math.floor(job.units * job.area.h / 10) local step = math.floor(job.units * job.area.h / 10)
step = step == 0 and ya.clamp(-1, job.units, 1) or step 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), math.max(0, cx.active.preview.skip + step),
only_if = job.file.url, only_if = job.file.url,
}) })

View file

@ -1,7 +1,7 @@
local M = {} local M = {}
function M:setup() 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 end
return M return M

View file

@ -41,7 +41,7 @@ function M:peek(job)
end end
if job.skip > 0 and i < job.skip + limit then 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 else
ya.preview_widgets(job, { ui.Text(lines):area(job.area) }) ya.preview_widgets(job, { ui.Text(lines):area(job.area) })
end end

View file

@ -6,7 +6,7 @@ function M:setup()
ps.sub_remote("extract", function(args) ps.sub_remote("extract", function(args)
local noisy = #args == 1 and ' "" --noisy' or ' ""' local noisy = #args == 1 and ' "" --noisy' or ' ""'
for _, arg in ipairs(args) do 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) end)
end end

Some files were not shown because too many files have changed in this diff Show more