mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-22 23:31:05 +00:00
refactor: rename rt.manager to rt.mgr, and th.manager to th.mgr (#2397)
This commit is contained in:
parent
68e892694d
commit
235f6888d4
120 changed files with 316 additions and 317 deletions
|
|
@ -10,7 +10,7 @@ use crate::{Preset, keymap::Key};
|
|||
|
||||
#[derive(Debug)]
|
||||
pub struct Keymap {
|
||||
pub manager: Vec<Chord>,
|
||||
pub mgr: Vec<Chord>,
|
||||
pub tasks: Vec<Chord>,
|
||||
pub spot: Vec<Chord>,
|
||||
pub pick: Vec<Chord>,
|
||||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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<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 PLUGIN: RoCell<plugin::Plugin> = RoCell::new();
|
||||
pub static PREVIEW: RoCell<preview::Preview> = 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::<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())?;
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
yazi_macro::mod_flat!(manager mouse ratio);
|
||||
|
|
@ -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<Self, Self::Err> {
|
||||
#[derive(Deserialize)]
|
||||
struct Outer {
|
||||
manager: Manager,
|
||||
#[serde(rename = "manager")]
|
||||
mgr: Mgr, // TODO: remove serde(rename)
|
||||
}
|
||||
|
||||
let outer = toml::from_str::<Outer>(s)
|
||||
.context("Failed to parse the [manager] section in your yazi.toml")?;
|
||||
outer.manager.validate()?;
|
||||
outer.mgr.validate()?;
|
||||
|
||||
Ok(outer.manager)
|
||||
Ok(outer.mgr)
|
||||
}
|
||||
}
|
||||
1
yazi-config/src/mgr/mod.rs
Normal file
1
yazi-config/src/mgr/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
yazi_macro::mod_flat!(mgr mouse ratio);
|
||||
|
|
@ -3,14 +3,14 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq, Eq)]
|
||||
#[serde(try_from = "Vec<u16>")]
|
||||
pub struct ManagerRatio {
|
||||
pub struct MgrRatio {
|
||||
pub parent: u16,
|
||||
pub current: u16,
|
||||
pub preview: u16,
|
||||
pub all: u16,
|
||||
}
|
||||
|
||||
impl TryFrom<Vec<u16>> for ManagerRatio {
|
||||
impl TryFrom<Vec<u16>> for MgrRatio {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(ratio: Vec<u16>) -> Result<Self, Self::Error> {
|
||||
|
|
@ -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<Self, Self::Err> {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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<CmdCow> 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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
yazi_macro::mod_pub!(commands);
|
||||
|
||||
yazi_macro::mod_flat!(linked manager mimetype tabs watcher yanked);
|
||||
|
|
@ -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(),
|
||||
);
|
||||
|
|
@ -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<Opt> 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 {
|
||||
|
|
@ -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<CmdCow> 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();
|
||||
|
|
@ -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<CmdCow> 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 {
|
||||
|
|
@ -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<Url>,
|
||||
|
|
@ -20,7 +20,7 @@ impl From<Option<Url>> for Opt {
|
|||
fn from(url: Option<Url>) -> 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 {
|
||||
|
|
@ -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<CmdCow> 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 {
|
||||
|
|
@ -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<CmdCow> 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 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -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<CmdCow> 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::<Vec<_>>(), self.cwd());
|
||||
|
|
@ -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<bool> 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 {
|
||||
|
|
@ -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<CmdCow> 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() };
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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<CmdCow> 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -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<CmdCow> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
impl Mgr {
|
||||
#[yazi_codegen::command]
|
||||
pub fn rename(&mut self, opt: Opt) {
|
||||
if !self.active_mut().try_escape_visual() {
|
||||
|
|
@ -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<CmdCow> 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 {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::manager::Manager;
|
||||
use crate::mgr::Mgr;
|
||||
|
||||
struct Opt {
|
||||
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) } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
impl Mgr {
|
||||
#[yazi_codegen::command]
|
||||
pub fn spot(&mut self, opt: Opt) {
|
||||
let Some(hovered) = self.hovered().cloned() else {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -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,
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
@ -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,
|
||||
|
|
@ -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,
|
||||
|
|
@ -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));
|
||||
|
|
@ -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<CmdCow> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
impl Mgr {
|
||||
pub fn update_files(&mut self, opt: impl TryInto<Opt>, 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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<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) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return error!("invalid arguments for update_mimes");
|
||||
|
|
@ -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<Opt>, tasks: &Tasks) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
use crate::manager::Manager;
|
||||
use crate::mgr::Mgr;
|
||||
|
||||
pub struct Opt {
|
||||
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>) {
|
||||
let Ok(opt) = opt.try_into() else {
|
||||
return;
|
||||
|
|
@ -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<CmdCow> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
impl Mgr {
|
||||
pub fn update_yanked(&mut self, opt: impl TryInto<Opt>) {
|
||||
let Ok(opt) = opt.try_into() else { return };
|
||||
|
||||
|
|
@ -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<CmdCow> 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() {
|
||||
|
|
@ -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() }
|
||||
|
||||
3
yazi-core/src/mgr/mod.rs
Normal file
3
yazi-core/src/mgr/mod.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
yazi_macro::mod_pub!(commands);
|
||||
|
||||
yazi_macro::mod_flat!(linked mgr mimetype tabs watcher yanked);
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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)));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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::<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)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())))
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl UserData for File {
|
|||
});
|
||||
methods.add_method("mime", |lua, me, ()| {
|
||||
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, ()| {
|
||||
|
|
@ -69,16 +69,16 @@ impl UserData for File {
|
|||
});
|
||||
methods.add_method("style", |lua, me, ()| {
|
||||
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))
|
||||
})
|
||||
});
|
||||
methods.add_method("is_hovered", |_, me, ()| Ok(me.idx == me.folder().cursor));
|
||||
methods.add_method("is_yanked", |lua, me, ()| {
|
||||
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
|
||||
} else if cx.manager.yanked.cut {
|
||||
} else if cx.mgr.yanked.cut {
|
||||
2u8
|
||||
} else {
|
||||
1u8
|
||||
|
|
|
|||
|
|
@ -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<AnyUserData> {
|
||||
pub(super) fn make(inner: &yazi_core::mgr::Tabs) -> mlua::Result<AnyUserData> {
|
||||
Lives::scoped_userdata(Self { inner })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<AnyUserData> {
|
||||
pub(super) fn make(inner: &yazi_core::mgr::Yanked) -> mlua::Result<AnyUserData> {
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ impl Widget for Modal<'_> {
|
|||
let area = yazi_plugin::elements::Rect::from(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>(())
|
||||
};
|
||||
if let Err(e) = f() {
|
||||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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::<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>(())
|
||||
};
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ impl Widget for Progress<'_> {
|
|||
let progress =
|
||||
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>(())
|
||||
};
|
||||
if let Err(e) = f() {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue