mirror of
https://github.com/sxyazi/yazi.git
synced 2026-05-13 08:16:40 +00:00
Refactor
This commit is contained in:
parent
0fab877c60
commit
6c226065b7
12 changed files with 34 additions and 19 deletions
|
|
@ -45,7 +45,7 @@ impl Actor for BulkRename {
|
|||
let cwd = cx.cwd().clone();
|
||||
let batcher = cx.core.mgr.batcher.clone();
|
||||
tokio::spawn(async move {
|
||||
let tmp = YAZI.preview.tmpfile("bulk");
|
||||
let tmp = YAZI.preview.tmpfile("bulk-rename");
|
||||
|
||||
Gate::default()
|
||||
.write(true)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# A TOML linter such as https://github.com/tombi-toml/tombi can use this schema to validate your config.
|
||||
# If you encounter any problems, please make an issue at https://github.com/yazi-rs/schemas.
|
||||
# A TOML linter such as Tombi can use this schema to validate your config.
|
||||
# If you encounter any problems, please file an issue at https://github.com/yazi-rs/schemas.
|
||||
|
||||
#:schema https://yazi-rs.github.io/schemas/keymap.json
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
# A TOML linter such as https://github.com/tombi-toml/tombi can use this schema to validate your config.
|
||||
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
|
||||
# A TOML linter such as Tombi can use this schema to validate your config.
|
||||
# If you encounter any problems, please file an issue at https://github.com/yazi-rs/schemas.
|
||||
|
||||
#:schema https://yazi-rs.github.io/schemas/yazi.json
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ impl<'a> Executor<'a> {
|
|||
on!(hardlink);
|
||||
on!(remove);
|
||||
on!(remove_do);
|
||||
on!(bulk_create);
|
||||
on!(create);
|
||||
on!(rename);
|
||||
on!(copy);
|
||||
|
|
@ -133,6 +132,7 @@ impl<'a> Executor<'a> {
|
|||
on!(search_do);
|
||||
on!(bulk_exit);
|
||||
on!(bulk_rename);
|
||||
on!(bulk_create);
|
||||
|
||||
// Filter
|
||||
on!(filter);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,18 @@ impl FilesOp {
|
|||
ticket
|
||||
}
|
||||
|
||||
pub fn create(files: Vec<File>) {
|
||||
let mut parents: HashMap<UrlBuf, Vec<_>> = Default::default();
|
||||
for file in files {
|
||||
if let Some(p) = file.url.parent() {
|
||||
parents.get_or_insert_default(p).push(file);
|
||||
}
|
||||
}
|
||||
for (p, files) in parents {
|
||||
Self::Creating(p, files).emit();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rename(map: HashMap<UrlBuf, File>) {
|
||||
let mut parents: HashMap<UrlBuf, (HashSet<_>, HashMap<_, _>)> = Default::default();
|
||||
for (o, n) in map {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
yazi_macro::mod_pub!(arc_swap cell crossterm mlua ratatui serde strum toml vec);
|
||||
yazi_macro::mod_pub!(arc_swap cell crossterm mlua path ratatui serde strum toml vec);
|
||||
|
||||
yazi_macro::mod_flat!(twox);
|
||||
|
|
|
|||
1
yazi-shim/src/path/mod.rs
Normal file
1
yazi-shim/src/path/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
yazi_macro::mod_flat!(separator);
|
||||
5
yazi-shim/src/path/separator.rs
Normal file
5
yazi-shim/src/path/separator.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#[cfg(windows)]
|
||||
pub const CROSS_SEPARATOR: [char; 2] = ['/', '\\'];
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub const CROSS_SEPARATOR: char = std::path::MAIN_SEPARATOR;
|
||||
|
|
@ -3,16 +3,17 @@ use std::path::MAIN_SEPARATOR_STR;
|
|||
use anyhow::Result;
|
||||
use yazi_macro::{act, render, succ};
|
||||
use yazi_shared::data::Data;
|
||||
use yazi_shim::path::CROSS_SEPARATOR;
|
||||
|
||||
use crate::input::{Input, SEPARATOR, parser::CompleteOpt};
|
||||
use crate::input::{Input, parser::CompleteOpt};
|
||||
|
||||
impl Input {
|
||||
pub fn complete(&mut self, opt: CompleteOpt) -> Result<Data> {
|
||||
let (before, after) = self.partition();
|
||||
let new = if let Some((prefix, _)) = before.rsplit_once(SEPARATOR) {
|
||||
format!("{prefix}/{}{after}", opt.completable()).replace(SEPARATOR, MAIN_SEPARATOR_STR)
|
||||
let new = if let Some((prefix, _)) = before.rsplit_once(CROSS_SEPARATOR) {
|
||||
format!("{prefix}/{}{after}", opt.completable()).replace(CROSS_SEPARATOR, MAIN_SEPARATOR_STR)
|
||||
} else {
|
||||
format!("{}{after}", opt.completable()).replace(SEPARATOR, MAIN_SEPARATOR_STR)
|
||||
format!("{}{after}", opt.completable()).replace(CROSS_SEPARATOR, MAIN_SEPARATOR_STR)
|
||||
};
|
||||
|
||||
let snap = self.snap_mut();
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@ use tokio::sync::mpsc;
|
|||
use yazi_config::YAZI;
|
||||
use yazi_macro::act;
|
||||
use yazi_shared::Ids;
|
||||
use yazi_shim::path::CROSS_SEPARATOR;
|
||||
|
||||
use super::{InputSnap, InputSnaps, mode::InputMode, op::InputOp};
|
||||
use crate::{CLIPBOARD, input::{InputEvent, InputOpt, SEPARATOR}};
|
||||
use crate::{CLIPBOARD, input::{InputEvent, InputOpt}};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Input {
|
||||
|
|
@ -152,7 +153,7 @@ impl Input {
|
|||
let snap = self.snap();
|
||||
let idx = snap.idx(snap.cursor).unwrap();
|
||||
|
||||
if let Some(sep) = snap.value[idx..].find(SEPARATOR).map(|i| idx + i) {
|
||||
if let Some(sep) = snap.value[idx..].find(CROSS_SEPARATOR).map(|i| idx + i) {
|
||||
(&snap.value[..sep], &snap.value[sep + 1..])
|
||||
} else {
|
||||
(&snap.value, "")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
yazi_macro::mod_pub!(actor parser);
|
||||
|
||||
yazi_macro::mod_flat!(event input mode op option separator snap snaps widget);
|
||||
yazi_macro::mod_flat!(event input mode op option snap snaps widget);
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
#[cfg(windows)]
|
||||
pub(super) const SEPARATOR: [char; 2] = ['/', '\\'];
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub(super) const SEPARATOR: char = std::path::MAIN_SEPARATOR;
|
||||
Loading…
Add table
Add a link
Reference in a new issue