This commit is contained in:
sxyazi 2026-05-11 08:16:38 +08:00
parent 54a2b7bc30
commit 0fab877c60
No known key found for this signature in database
3 changed files with 14 additions and 8 deletions

View file

@ -1,4 +1,4 @@
use std::{io::{Read, Write}, path::Path};
use std::{io::{Read, Write}, path::Path, sync::Arc};
use anyhow::{Result, anyhow, bail};
use scopeguard::defer;
@ -6,8 +6,9 @@ use yazi_binding::Permit;
use yazi_config::{YAZI, opener::OpenerRule};
use yazi_fs::{File, FilesOp, Splatter, provider::{FileBuilder, Provider, local::{Gate, Local}}};
use yazi_macro::{ok_or_not_found, succ};
use yazi_parser::VoidOpt;
use yazi_proxy::{AppProxy, MgrProxy, NotifyProxy, TasksProxy};
use yazi_parser::VoidForm;
use yazi_proxy::{MgrProxy, TasksProxy};
use yazi_scheduler::{AppProxy, NotifyProxy};
use yazi_shared::{data::Data, terminal_clear, url::{AsUrl, UrlBuf, UrlCow, UrlLike}};
use yazi_term::YIELD_TO_SUBPROCESS;
use yazi_tty::TTY;
@ -17,11 +18,11 @@ use yazi_watcher::WATCHER;
use crate::{Actor, Ctx};
pub struct BulkCreate;
impl Actor for BulkCreate {
type Options = VoidOpt;
type Form = VoidForm;
const NAME: &str = "bulk_create";
fn act(cx: &mut Ctx, _: Self::Options) -> Result<Data> {
fn act(cx: &mut Ctx, _: Self::Form) -> Result<Data> {
let Some(opener) = Self::opener() else {
succ!(NotifyProxy::push_warn("Bulk create", "No text opener found"));
};
@ -97,8 +98,11 @@ impl BulkCreate {
Ok(())
}
fn opener() -> Option<&'static OpenerRule> {
YAZI.opener.block(YAZI.open.all(Path::new("bulk-rename.txt"), "text/plain"))
fn opener() -> Option<Arc<OpenerRule>> {
YAZI
.open
.match_dummy(Path::new("bulk-create.txt"), "text/plain")
.and_then(|r| YAZI.opener.block(&r))
}
async fn create_one(new: &UrlBuf, dir: bool) -> Result<UrlBuf> {

View file

@ -76,7 +76,7 @@ keymap = [
{ on = "d", run = "remove", desc = "Trash selected files" },
{ on = "D", run = "remove --permanently", desc = "Permanently delete selected files" },
{ on = "a", run = "create", desc = "Create a file (ends with / for directories)" },
{ on = "A", run = "bulk_create", desc = "Create files from a list with your editor"},
{ on = "A", run = "bulk_create", desc = "Bulk create files" },
{ on = "r", run = "rename --cursor=before_ext", desc = "Rename selected file(s)" },
{ on = ";", run = "shell --interactive", desc = "Run a shell command" },
{ on = ":", run = "shell --block --interactive", desc = "Run a shell command (block until finishes)" },

View file

@ -28,6 +28,7 @@ pub enum Spark<'a> {
// Mgr
Arrow(crate::ArrowForm),
Back(crate::VoidForm),
BulkCreate(crate::VoidForm),
BulkExit(crate::mgr::BulkExitForm),
BulkRename(crate::VoidForm),
Cd(crate::mgr::CdForm),
@ -215,6 +216,7 @@ impl<'a> IntoLua for Spark<'a> {
// Mgr
Self::Arrow(b) => b.into_lua(lua),
Self::Back(b) => b.into_lua(lua),
Self::BulkCreate(b) => b.into_lua(lua),
Self::BulkExit(b) => b.into_lua(lua),
Self::BulkRename(b) => b.into_lua(lua),
Self::Cd(b) => b.into_lua(lua),