mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Rebase
This commit is contained in:
parent
54a2b7bc30
commit
0fab877c60
3 changed files with 14 additions and 8 deletions
|
|
@ -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 anyhow::{Result, anyhow, bail};
|
||||||
use scopeguard::defer;
|
use scopeguard::defer;
|
||||||
|
|
@ -6,8 +6,9 @@ use yazi_binding::Permit;
|
||||||
use yazi_config::{YAZI, opener::OpenerRule};
|
use yazi_config::{YAZI, opener::OpenerRule};
|
||||||
use yazi_fs::{File, FilesOp, Splatter, provider::{FileBuilder, Provider, local::{Gate, Local}}};
|
use yazi_fs::{File, FilesOp, Splatter, provider::{FileBuilder, Provider, local::{Gate, Local}}};
|
||||||
use yazi_macro::{ok_or_not_found, succ};
|
use yazi_macro::{ok_or_not_found, succ};
|
||||||
use yazi_parser::VoidOpt;
|
use yazi_parser::VoidForm;
|
||||||
use yazi_proxy::{AppProxy, MgrProxy, NotifyProxy, TasksProxy};
|
use yazi_proxy::{MgrProxy, TasksProxy};
|
||||||
|
use yazi_scheduler::{AppProxy, NotifyProxy};
|
||||||
use yazi_shared::{data::Data, terminal_clear, url::{AsUrl, UrlBuf, UrlCow, UrlLike}};
|
use yazi_shared::{data::Data, terminal_clear, url::{AsUrl, UrlBuf, UrlCow, UrlLike}};
|
||||||
use yazi_term::YIELD_TO_SUBPROCESS;
|
use yazi_term::YIELD_TO_SUBPROCESS;
|
||||||
use yazi_tty::TTY;
|
use yazi_tty::TTY;
|
||||||
|
|
@ -17,11 +18,11 @@ use yazi_watcher::WATCHER;
|
||||||
use crate::{Actor, Ctx};
|
use crate::{Actor, Ctx};
|
||||||
pub struct BulkCreate;
|
pub struct BulkCreate;
|
||||||
impl Actor for BulkCreate {
|
impl Actor for BulkCreate {
|
||||||
type Options = VoidOpt;
|
type Form = VoidForm;
|
||||||
|
|
||||||
const NAME: &str = "bulk_create";
|
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 {
|
let Some(opener) = Self::opener() else {
|
||||||
succ!(NotifyProxy::push_warn("Bulk create", "No text opener found"));
|
succ!(NotifyProxy::push_warn("Bulk create", "No text opener found"));
|
||||||
};
|
};
|
||||||
|
|
@ -97,8 +98,11 @@ impl BulkCreate {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opener() -> Option<&'static OpenerRule> {
|
fn opener() -> Option<Arc<OpenerRule>> {
|
||||||
YAZI.opener.block(YAZI.open.all(Path::new("bulk-rename.txt"), "text/plain"))
|
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> {
|
async fn create_one(new: &UrlBuf, dir: bool) -> Result<UrlBuf> {
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ keymap = [
|
||||||
{ on = "d", run = "remove", desc = "Trash selected files" },
|
{ on = "d", run = "remove", desc = "Trash selected files" },
|
||||||
{ on = "D", run = "remove --permanently", desc = "Permanently delete 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 = "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 = "r", run = "rename --cursor=before_ext", desc = "Rename selected file(s)" },
|
||||||
{ on = ";", run = "shell --interactive", desc = "Run a shell command" },
|
{ on = ";", run = "shell --interactive", desc = "Run a shell command" },
|
||||||
{ on = ":", run = "shell --block --interactive", desc = "Run a shell command (block until finishes)" },
|
{ on = ":", run = "shell --block --interactive", desc = "Run a shell command (block until finishes)" },
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ pub enum Spark<'a> {
|
||||||
// Mgr
|
// Mgr
|
||||||
Arrow(crate::ArrowForm),
|
Arrow(crate::ArrowForm),
|
||||||
Back(crate::VoidForm),
|
Back(crate::VoidForm),
|
||||||
|
BulkCreate(crate::VoidForm),
|
||||||
BulkExit(crate::mgr::BulkExitForm),
|
BulkExit(crate::mgr::BulkExitForm),
|
||||||
BulkRename(crate::VoidForm),
|
BulkRename(crate::VoidForm),
|
||||||
Cd(crate::mgr::CdForm),
|
Cd(crate::mgr::CdForm),
|
||||||
|
|
@ -215,6 +216,7 @@ impl<'a> IntoLua for Spark<'a> {
|
||||||
// Mgr
|
// Mgr
|
||||||
Self::Arrow(b) => b.into_lua(lua),
|
Self::Arrow(b) => b.into_lua(lua),
|
||||||
Self::Back(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::BulkExit(b) => b.into_lua(lua),
|
||||||
Self::BulkRename(b) => b.into_lua(lua),
|
Self::BulkRename(b) => b.into_lua(lua),
|
||||||
Self::Cd(b) => b.into_lua(lua),
|
Self::Cd(b) => b.into_lua(lua),
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue