mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-24 00:01:03 +00:00
perf: introduce copy-on-write for event system to eliminate all memory reallocations (#1962)
This commit is contained in:
parent
5e48df5126
commit
37292adfde
122 changed files with 532 additions and 448 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use std::{borrow::Cow, collections::VecDeque, hash::{Hash, Hasher}, sync::OnceLock};
|
||||
use std::{borrow::Cow, hash::{Hash, Hasher}, sync::OnceLock};
|
||||
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
|
|
@ -53,7 +53,4 @@ impl Chord {
|
|||
|| self.run().to_lowercase().contains(&s)
|
||||
|| self.on().to_lowercase().contains(&s)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn to_seq(&self) -> VecDeque<Cmd> { self.run.iter().map(|c| c.shallow_clone()).collect() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{collections::VecDeque, ops::Deref};
|
||||
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use super::Chord;
|
||||
|
||||
|
|
@ -10,14 +10,14 @@ pub enum ChordCow {
|
|||
Borrowed(&'static Chord),
|
||||
}
|
||||
|
||||
impl From<&'static Chord> for ChordCow {
|
||||
fn from(c: &'static Chord) -> Self { Self::Borrowed(c) }
|
||||
}
|
||||
|
||||
impl From<Chord> for ChordCow {
|
||||
fn from(c: Chord) -> Self { Self::Owned(c) }
|
||||
}
|
||||
|
||||
impl From<&'static Chord> for ChordCow {
|
||||
fn from(c: &'static Chord) -> Self { Self::Borrowed(c) }
|
||||
}
|
||||
|
||||
impl Deref for ChordCow {
|
||||
type Target = Chord;
|
||||
|
||||
|
|
@ -34,10 +34,10 @@ impl Default for ChordCow {
|
|||
}
|
||||
|
||||
impl ChordCow {
|
||||
pub fn into_seq(self) -> VecDeque<Cmd> {
|
||||
pub fn into_seq(self) -> VecDeque<CmdCow> {
|
||||
match self {
|
||||
Self::Owned(c) => c.run.into(),
|
||||
Self::Borrowed(c) => c.to_seq(),
|
||||
Self::Owned(c) => c.run.into_iter().map(|c| c.into()).collect(),
|
||||
Self::Borrowed(c) => c.run.iter().map(|c| c.into()).collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Completion {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_proxy::InputProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::{mem, ops::ControlFlow};
|
||||
use std::{borrow::Cow, mem, ops::ControlFlow};
|
||||
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{Cmd, CmdCow, Data};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -9,13 +9,13 @@ const LIMIT: usize = 30;
|
|||
|
||||
struct Opt {
|
||||
cache: Vec<String>,
|
||||
cache_name: String,
|
||||
word: String,
|
||||
cache_name: Cow<'static, str>,
|
||||
word: Cow<'static, str>,
|
||||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
cache: c.take_any("cache").unwrap_or_default(),
|
||||
cache_name: c.take_str("cache-name").unwrap_or_default(),
|
||||
|
|
@ -25,6 +25,10 @@ impl From<Cmd> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self::from(CmdCow::from(c)) }
|
||||
}
|
||||
|
||||
impl Completion {
|
||||
#[yazi_codegen::command]
|
||||
pub fn show(&mut self, opt: Opt) {
|
||||
|
|
@ -33,9 +37,9 @@ impl Completion {
|
|||
}
|
||||
|
||||
if !opt.cache.is_empty() {
|
||||
self.caches.insert(opt.cache_name.to_owned(), opt.cache);
|
||||
self.caches.insert(opt.cache_name.as_ref().to_owned(), opt.cache);
|
||||
}
|
||||
let Some(cache) = self.caches.get(&opt.cache_name) else {
|
||||
let Some(cache) = self.caches.get(opt.cache_name.as_ref()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::{borrow::Cow, mem, path::{MAIN_SEPARATOR, MAIN_SEPARATOR_STR}};
|
|||
|
||||
use tokio::fs;
|
||||
use yazi_macro::{emit, render};
|
||||
use yazi_shared::{Layer, event::{Cmd, Data}};
|
||||
use yazi_shared::{Layer, event::{Cmd, CmdCow, Data}};
|
||||
|
||||
use crate::completion::Completion;
|
||||
|
||||
|
|
@ -13,12 +13,12 @@ const SEPARATOR: [char; 2] = ['/', '\\'];
|
|||
const SEPARATOR: char = std::path::MAIN_SEPARATOR;
|
||||
|
||||
struct Opt {
|
||||
word: String,
|
||||
word: Cow<'static, str>,
|
||||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
word: c.take_first_str().unwrap_or_default(),
|
||||
ticket: c.get("ticket").and_then(Data::as_usize).unwrap_or(0),
|
||||
|
|
@ -40,7 +40,7 @@ impl Completion {
|
|||
|
||||
if self.caches.contains_key(&parent) {
|
||||
return self.show(
|
||||
Cmd::new("show").with("cache-name", parent).with("word", child).with("ticket", opt.ticket),
|
||||
Cmd::default().with("cache-name", parent).with("word", child).with("ticket", opt.ticket),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::{confirm::Confirm, manager::Manager};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Confirm {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::confirm::Confirm;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use tokio::sync::oneshot;
|
||||
use yazi_config::popup::ConfirmCfg;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::confirm::Confirm;
|
||||
|
||||
|
|
@ -10,10 +10,10 @@ pub struct Opt {
|
|||
tx: oneshot::Sender<bool>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { cfg: c.take_any("cfg").ok_or(())?, tx: c.take_any("tx").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::help::Help;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
impl From<isize> for Opt {
|
||||
fn from(step: isize) -> Self { Self { step } }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::help::Help;
|
||||
|
||||
impl Help {
|
||||
pub fn escape(&mut self, _: Cmd) {
|
||||
pub fn escape(&mut self, _: CmdCow) {
|
||||
if self.keyword().is_none() {
|
||||
return self.toggle(self.layer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use yazi_config::popup::{Offset, Origin, Position};
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{help::Help, input::Input};
|
||||
|
||||
impl Help {
|
||||
pub fn filter(&mut self, _: Cmd) {
|
||||
pub fn filter(&mut self, _: CmdCow) {
|
||||
let mut input = Input::default();
|
||||
input.position = Position::new(Origin::BottomLeft, Offset::line());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
under: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { under: c.bool("under") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { under: c.bool("under") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(under: bool) -> Self { Self { under } }
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::{CharKind, event::Cmd};
|
||||
use yazi_shared::{CharKind, event::CmdCow};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
impl Input {
|
||||
pub fn backward(&mut self, _: Cmd) {
|
||||
pub fn backward(&mut self, _: CmdCow) {
|
||||
let snap = self.snap();
|
||||
if snap.cursor == 0 {
|
||||
return self.move_(0);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_proxy::CompletionProxy;
|
||||
use yazi_shared::{errors::InputError, event::Cmd};
|
||||
use yazi_shared::{errors::InputError, event::CmdCow};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::path::MAIN_SEPARATOR_STR;
|
||||
use std::{borrow::Cow, path::MAIN_SEPARATOR_STR};
|
||||
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
|
|
@ -12,12 +12,12 @@ const SEPARATOR: [char; 2] = ['/', '\\'];
|
|||
const SEPARATOR: char = std::path::MAIN_SEPARATOR;
|
||||
|
||||
struct Opt {
|
||||
word: String,
|
||||
word: Cow<'static, str>,
|
||||
ticket: usize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
word: c.take_first_str().unwrap_or_default(),
|
||||
ticket: c.get("ticket").and_then(Data::as_usize).unwrap_or(0),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, op::InputOp};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
insert: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { cut: c.bool("cut"), insert: c.bool("insert") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut"), insert: c.bool("insert") } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_proxy::CompletionProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, InputMode, op::InputOp};
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{CharKind, event::Cmd};
|
||||
use yazi_shared::{CharKind, event::CmdCow};
|
||||
|
||||
use crate::input::{Input, op::InputOp};
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ struct Opt {
|
|||
end_of_word: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { end_of_word: c.bool("end-of-word") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { end_of_word: c.bool("end-of-word") } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, InputMode, op::InputOp};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
append: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { append: c.bool("append") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { append: c.bool("append") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(append: bool) -> Self { Self { append } }
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
use std::ops::RangeBounds;
|
||||
use std::{borrow::Cow, ops::RangeBounds};
|
||||
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{CharKind, event::Cmd};
|
||||
use yazi_shared::{CharKind, event::CmdCow};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
struct Opt {
|
||||
kind: String,
|
||||
kind: Cow<'static, str>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { kind: c.take_first_str().unwrap_or_default() } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self { Self { kind: c.take_first_str().unwrap_or_default() } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
#[yazi_codegen::command]
|
||||
pub fn kill(&mut self, opt: Opt) {
|
||||
let snap = self.snap_mut();
|
||||
match opt.kind.as_str() {
|
||||
match opt.kind.as_ref() {
|
||||
"all" => self.kill_range(..),
|
||||
"bol" => {
|
||||
let end = snap.idx(snap.cursor).unwrap_or(snap.len());
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use unicode_width::UnicodeWidthStr;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::input::{Input, op::InputOp, snap::InputSnap};
|
||||
|
||||
|
|
@ -9,8 +9,8 @@ struct Opt {
|
|||
in_operating: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self {
|
||||
Self {
|
||||
step: c.first().and_then(Data::as_isize).unwrap_or(0),
|
||||
in_operating: c.bool("in-operating"),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_plugin::CLIPBOARD;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, op::InputOp};
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
before: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { before: c.bool("before") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { before: c.bool("before") } }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
impl Input {
|
||||
pub fn redo(&mut self, _: Cmd) {
|
||||
pub fn redo(&mut self, _: CmdCow) {
|
||||
render!(self.snaps.redo());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use tokio::sync::mpsc;
|
||||
use yazi_config::popup::InputCfg;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{errors::InputError, event::Cmd};
|
||||
use yazi_shared::{errors::InputError, event::CmdCow};
|
||||
|
||||
use crate::input::Input;
|
||||
|
||||
|
|
@ -10,10 +10,10 @@ pub struct Opt {
|
|||
tx: mpsc::UnboundedSender<Result<String, InputError>>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { cfg: c.take_any("cfg").ok_or(())?, tx: c.take_any("tx").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use yazi_config::keymap::Key;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, InputMode};
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Input {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, InputMode};
|
||||
|
||||
impl Input {
|
||||
pub fn undo(&mut self, _: Cmd) {
|
||||
pub fn undo(&mut self, _: CmdCow) {
|
||||
if !self.snaps.undo() {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, InputMode, op::InputOp};
|
||||
|
||||
impl Input {
|
||||
#[inline]
|
||||
pub fn visual(&mut self, _: Cmd) {
|
||||
pub fn visual(&mut self, _: CmdCow) {
|
||||
let snap = self.snap_mut();
|
||||
if snap.mode != InputMode::Normal {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::input::{Input, op::InputOp};
|
||||
|
||||
impl Input {
|
||||
pub fn yank(&mut self, _: Cmd) {
|
||||
pub fn yank(&mut self, _: CmdCow) {
|
||||
match self.snap().op {
|
||||
InputOp::None => {
|
||||
self.snap_mut().op = InputOp::Yank(self.snap().cursor);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
impl Manager {
|
||||
pub fn close(&mut self, _: Cmd, tasks: &Tasks) {
|
||||
pub fn close(&mut self, _: CmdCow, tasks: &Tasks) {
|
||||
if self.tabs.len() > 1 {
|
||||
return self.tabs.close(self.tabs.cursor);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
|||
use tokio::fs;
|
||||
use yazi_config::popup::{ConfirmCfg, InputCfg};
|
||||
use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER};
|
||||
use yazi_shared::{event::Cmd, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, realname}};
|
||||
use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, realname}};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -13,8 +13,8 @@ struct Opt {
|
|||
force: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
follow: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::{collections::HashSet, path::PathBuf};
|
|||
|
||||
use yazi_dds::Pubsub;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{Id, event::{Cmd, Data}, fs::{Url, Urn}};
|
||||
use yazi_shared::{Id, event::{CmdCow, Data}, fs::{Url, Urn}};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -11,9 +11,9 @@ struct Opt {
|
|||
tab: Option<Id>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self { url: c.take_first().and_then(Data::into_url), tab: c.get("tab").and_then(Data::as_id) }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self { url: c.take_first_url(), tab: c.get("tab").and_then(Data::as_id) }
|
||||
}
|
||||
}
|
||||
impl From<Option<Url>> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
force: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use yazi_fs::Folder;
|
|||
use yazi_macro::emit;
|
||||
use yazi_plugin::isolate;
|
||||
use yazi_proxy::{ManagerProxy, TasksProxy, options::OpenDoOpt};
|
||||
use yazi_shared::{MIME_DIR, event::{Cmd, EventQuit}, fs::{File, Url}};
|
||||
use yazi_shared::{MIME_DIR, event::{CmdCow, EventQuit}, fs::{File, Url}};
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -17,8 +17,8 @@ struct Opt {
|
|||
hovered: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self {
|
||||
Self { interactive: c.bool("interactive"), hovered: c.bool("hovered") }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
follow: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_proxy::HIDER;
|
||||
use yazi_shared::{event::{Cmd, Data}, fs::Url};
|
||||
use yazi_shared::{event::{CmdCow, Data}, fs::Url};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -11,12 +11,12 @@ struct Opt {
|
|||
upper_bound: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
skip: c.first().and_then(Data::as_usize),
|
||||
force: c.bool("force"),
|
||||
only_if: c.take("only-if").and_then(Data::into_url),
|
||||
only_if: c.take_url("only-if"),
|
||||
upper_bound: c.bool("upper-bound"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use tokio::{select, time};
|
|||
use yazi_config::popup::ConfirmCfg;
|
||||
use yazi_macro::emit;
|
||||
use yazi_proxy::ConfirmProxy;
|
||||
use yazi_shared::event::{Cmd, EventQuit};
|
||||
use yazi_shared::event::{CmdCow, EventQuit};
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -15,8 +15,8 @@ struct Opt {
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self::default() }
|
||||
}
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { no_cwd_file: c.bool("no-cwd-file") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ use std::{env, path::MAIN_SEPARATOR};
|
|||
|
||||
use crossterm::{execute, terminal::SetTitle};
|
||||
use yazi_config::MANAGER;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
impl Manager {
|
||||
pub fn refresh(&mut self, _: Cmd, tasks: &Tasks) {
|
||||
pub fn refresh(&mut self, _: CmdCow, tasks: &Tasks) {
|
||||
env::set_current_dir(self.cwd()).ok();
|
||||
env::set_var("PWD", self.cwd());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_config::popup::ConfirmCfg;
|
||||
use yazi_proxy::{ConfirmProxy, ManagerProxy};
|
||||
use yazi_shared::{event::Cmd, fs::Url};
|
||||
use yazi_shared::{event::CmdCow, fs::Url};
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -11,8 +11,8 @@ struct Opt {
|
|||
targets: Vec<Url>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
force: c.bool("force"),
|
||||
permanently: c.bool("permanently"),
|
||||
|
|
|
|||
|
|
@ -1,23 +1,23 @@
|
|||
use std::collections::{HashMap, HashSet};
|
||||
use std::{borrow::Cow, collections::{HashMap, HashSet}};
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::fs;
|
||||
use yazi_config::popup::{ConfirmCfg, InputCfg};
|
||||
use yazi_dds::Pubsub;
|
||||
use yazi_proxy::{ConfirmProxy, InputProxy, TabProxy, WATCHER};
|
||||
use yazi_shared::{event::Cmd, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, paths_to_same_file, realname}};
|
||||
use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, UrnBuf, maybe_exists, ok_or_not_found, paths_to_same_file, realname}};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
struct Opt {
|
||||
hovered: bool,
|
||||
force: bool,
|
||||
empty: String,
|
||||
cursor: String,
|
||||
empty: Cow<'static, str>,
|
||||
cursor: Cow<'static, str>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
hovered: c.bool("hovered"),
|
||||
force: c.bool("force"),
|
||||
|
|
@ -42,7 +42,7 @@ impl Manager {
|
|||
}
|
||||
|
||||
let name = Self::empty_url_part(&hovered, &opt.empty);
|
||||
let cursor = match opt.cursor.as_str() {
|
||||
let cursor = match opt.cursor.as_ref() {
|
||||
"start" => Some(0),
|
||||
"before_ext" => name
|
||||
.chars()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_config::PLUGIN;
|
||||
use yazi_plugin::isolate;
|
||||
use yazi_shared::{MIME_DIR, event::{Cmd, Data}};
|
||||
use yazi_shared::{MIME_DIR, event::{CmdCow, Data}};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -9,8 +9,8 @@ struct Opt {
|
|||
units: i16,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use yazi_shared::{MIME_DIR, event::{Cmd, Data}};
|
||||
use yazi_shared::{MIME_DIR, event::{CmdCow, Data}};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
skip: Option<usize>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { skip: c.get("skip").and_then(Data::as_usize) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { skip: c.get("skip").and_then(Data::as_usize) } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
impl Manager {
|
||||
pub fn suspend(&mut self, _: Cmd) {
|
||||
pub fn suspend(&mut self, _: CmdCow) {
|
||||
#[cfg(unix)]
|
||||
unsafe {
|
||||
libc::raise(libc::SIGTSTP);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::manager::Tabs;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
idx: usize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { idx: c.first().and_then(Data::as_usize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { idx: c.first().and_then(Data::as_usize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl From<usize> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use yazi_boot::BOOT;
|
||||
use yazi_macro::render;
|
||||
use yazi_proxy::AppProxy;
|
||||
use yazi_shared::{event::{Cmd, Data}, fs::Url};
|
||||
use yazi_shared::{event::CmdCow, fs::Url};
|
||||
|
||||
use crate::{manager::Tabs, tab::Tab};
|
||||
|
||||
|
|
@ -12,16 +12,13 @@ struct Opt {
|
|||
current: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
if c.bool("current") {
|
||||
Self { url: Default::default(), current: true }
|
||||
} else {
|
||||
Self {
|
||||
url: c
|
||||
.take_first()
|
||||
.and_then(Data::into_url)
|
||||
.unwrap_or_else(|| Url::from(&BOOT.cwds[0])),
|
||||
url: c.take_first_url().unwrap_or_else(|| Url::from(&BOOT.cwds[0])),
|
||||
current: false,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::manager::Tabs;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Tabs {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::manager::Tabs;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
relative: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self {
|
||||
Self { step: c.first().and_then(Data::as_isize).unwrap_or(0), relative: c.bool("relative") }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use std::borrow::Cow;
|
|||
use yazi_fs::Folder;
|
||||
use yazi_macro::render;
|
||||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::{event::Cmd, fs::FilesOp};
|
||||
use yazi_shared::{event::CmdCow, fs::FilesOp};
|
||||
|
||||
use crate::{manager::{LINKED, Manager}, tab::Tab, tasks::Tasks};
|
||||
|
||||
|
|
@ -11,10 +11,10 @@ pub struct Opt {
|
|||
op: FilesOp,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { op: c.take_any("op").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||
|
||||
use tracing::error;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{event::Cmd, fs::Url};
|
||||
use yazi_shared::{event::CmdCow, fs::Url};
|
||||
|
||||
use crate::{manager::{LINKED, Manager}, tasks::Tasks};
|
||||
|
||||
|
|
@ -10,11 +10,11 @@ pub struct Opt {
|
|||
updates: HashMap<String, String>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
Ok(Self { updates: c.take("updates").ok_or(())?.into_dict_string() })
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { updates: c.try_take("updates").ok_or(())?.into_dict_string() })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::{Cmd, Data}, fs::Url};
|
||||
use yazi_shared::{event::{CmdCow, Data}, fs::Url};
|
||||
|
||||
use crate::{manager::Manager, tasks::Tasks};
|
||||
|
||||
|
|
@ -8,12 +8,9 @@ pub struct Opt {
|
|||
only_if: Option<Url>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self {
|
||||
page: c.first().and_then(Data::as_usize),
|
||||
only_if: c.take("only-if").and_then(Data::into_url),
|
||||
}
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self { page: c.first().and_then(Data::as_usize), only_if: c.take_url("only-if") }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::{event::Cmd, fs::Url};
|
||||
use yazi_shared::{event::CmdCow, fs::Url};
|
||||
|
||||
use crate::manager::Manager;
|
||||
|
||||
|
|
@ -6,10 +6,10 @@ pub struct Opt {
|
|||
urls: Vec<Url>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { urls: c.take_any("urls").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{event::Cmd, fs::Url};
|
||||
use yazi_shared::{event::CmdCow, fs::Url};
|
||||
|
||||
use crate::manager::{Manager, Yanked};
|
||||
|
||||
|
|
@ -11,10 +11,10 @@ pub struct Opt {
|
|||
urls: HashSet<Url>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
if let Some(iter) = c.take_any::<yazi_dds::body::BodyYankIter>("urls") {
|
||||
Ok(Self { urls: iter.urls.into_iter().collect(), cut: iter.cut })
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::manager::{Manager, Yanked};
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
cut: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { cut: c.bool("cut") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut") } }
|
||||
}
|
||||
|
||||
impl Manager {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::time::Duration;
|
|||
|
||||
use ratatui::layout::Rect;
|
||||
use yazi_macro::emit;
|
||||
use yazi_shared::{Layer, event::{Cmd, Data}};
|
||||
use yazi_shared::{Layer, event::{Cmd, CmdCow, Data}};
|
||||
|
||||
use crate::notify::Notify;
|
||||
|
||||
|
|
@ -10,10 +10,10 @@ pub struct Opt {
|
|||
interval: Duration,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(c: CmdCow) -> Result<Self, Self::Error> {
|
||||
let interval = c.first().and_then(Data::as_f64).ok_or(())?;
|
||||
if interval < 0.0 {
|
||||
return Err(());
|
||||
|
|
@ -23,6 +23,12 @@ impl TryFrom<Cmd> for Opt {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(c: Cmd) -> Result<Self, Self::Error> { Self::try_from(CmdCow::from(c)) }
|
||||
}
|
||||
|
||||
impl Notify {
|
||||
pub fn tick(&mut self, opt: impl TryInto<Opt>, area: Rect) {
|
||||
self.tick_handle.take().map(|h| h.abort());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::pick::Pick;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Pick {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use anyhow::anyhow;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::pick::Pick;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
submit: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { submit: c.bool("submit") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { submit: c.bool("submit") } }
|
||||
}
|
||||
impl From<bool> for Opt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use tokio::sync::oneshot;
|
||||
use yazi_config::popup::PickCfg;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::pick::Pick;
|
||||
|
||||
|
|
@ -10,10 +10,10 @@ pub struct Opt {
|
|||
tx: oneshot::Sender<anyhow::Result<usize>>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { cfg: c.take_any("cfg").ok_or(())?, tx: c.take_any("tx").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::spot::Spot;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Spot {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::spot::Spot;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use yazi_plugin::CLIPBOARD;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::spot::Spot;
|
||||
|
||||
struct Opt {
|
||||
type_: String,
|
||||
type_: Cow<'static, str>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { type_: c.take_first_str().unwrap_or_default() } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self { Self { type_: c.take_first_str().unwrap_or_default() } }
|
||||
}
|
||||
|
||||
impl Spot {
|
||||
|
|
@ -18,7 +20,7 @@ impl Spot {
|
|||
let Some(table) = lock.table() else { return };
|
||||
|
||||
let mut s = String::new();
|
||||
match opt.type_.as_str() {
|
||||
match opt.type_.as_ref() {
|
||||
"cell" => {
|
||||
let Some(cell) = table.selected_cell() else { return };
|
||||
s = cell.to_string();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_proxy::{ManagerProxy, TabProxy};
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::spot::Spot;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl Spot {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use yazi_fs::Step;
|
||||
use yazi_macro::render;
|
||||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -9,10 +9,10 @@ struct Opt {
|
|||
step: Step,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
let step = match c.take_first() {
|
||||
Some(Data::Integer(i)) => Step::from(i as isize),
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self {
|
||||
let step = match c.first() {
|
||||
Some(Data::Integer(i)) => Step::from(*i as isize),
|
||||
Some(Data::String(s)) => s.parse().unwrap_or_default(),
|
||||
_ => Step::default(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn back(&mut self, _: Cmd) { self.backstack.shift_backward().cloned().map(|u| self.cd(u)); }
|
||||
pub fn back(&mut self, _: CmdCow) {
|
||||
self.backstack.shift_backward().cloned().map(|u| self.cd(u));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use yazi_config::popup::InputCfg;
|
|||
use yazi_dds::Pubsub;
|
||||
use yazi_macro::render;
|
||||
use yazi_proxy::{CompletionProxy, InputProxy, ManagerProxy, TabProxy};
|
||||
use yazi_shared::{Debounce, errors::InputError, event::{Cmd, Data}, fs::{Url, expand_path}};
|
||||
use yazi_shared::{Debounce, errors::InputError, event::CmdCow, fs::{Url, expand_path}};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -15,11 +15,11 @@ struct Opt {
|
|||
interactive: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
interactive: c.bool("interactive"),
|
||||
..Self::from(c.take_first().and_then(Data::into_url).unwrap_or_default())
|
||||
..Self::from(c.take_first_url().unwrap_or_default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
use std::{borrow::Cow, ffi::{OsStr, OsString}, path::Path};
|
||||
|
||||
use yazi_plugin::CLIPBOARD;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
struct Opt {
|
||||
type_: String,
|
||||
type_: Cow<'static, str>,
|
||||
separator: Separator,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
type_: c.take_first_str().unwrap_or_default(),
|
||||
separator: c.str("separator").unwrap_or_default().into(),
|
||||
|
|
@ -29,7 +29,7 @@ impl Tab {
|
|||
let mut s = OsString::new();
|
||||
let mut it = self.selected_or_hovered(true).peekable();
|
||||
while let Some(u) = it.next() {
|
||||
s.push(match opt.type_.as_str() {
|
||||
s.push(match opt.type_.as_ref() {
|
||||
"path" => opt.separator.transform(u),
|
||||
"dirname" => opt.separator.transform(u.parent().unwrap_or(Path::new(""))),
|
||||
"filename" => opt.separator.transform(u.name()),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn enter(&mut self, _: Cmd) {
|
||||
pub fn enter(&mut self, _: CmdCow) {
|
||||
self.hovered().filter(|h| h.is_dir()).map(|h| h.url.to_regular()).map(|u| self.cd(u));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use bitflags::bitflags;
|
||||
use yazi_macro::{render, render_and};
|
||||
use yazi_proxy::{AppProxy, ManagerProxy};
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -15,8 +15,8 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self {
|
||||
c.args.iter().fold(Opt::empty(), |acc, (k, v)| {
|
||||
match (k.as_str(), v.as_bool().unwrap_or(false)) {
|
||||
("all", true) => Self::all(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::time::Duration;
|
||||
use std::{borrow::Cow, time::Duration};
|
||||
|
||||
use tokio::pin;
|
||||
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
||||
|
|
@ -6,22 +6,22 @@ use yazi_config::popup::InputCfg;
|
|||
use yazi_fs::FilterCase;
|
||||
use yazi_macro::emit;
|
||||
use yazi_proxy::InputProxy;
|
||||
use yazi_shared::{Debounce, Layer, errors::InputError, event::Cmd};
|
||||
use yazi_shared::{Debounce, Layer, errors::InputError, event::{Cmd, CmdCow}};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
#[derive(Default)]
|
||||
pub(super) struct Opt {
|
||||
pub query: String,
|
||||
pub query: Cow<'static, str>,
|
||||
pub case: FilterCase,
|
||||
pub done: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
query: c.take_first_str().unwrap_or_default(),
|
||||
case: FilterCase::from(&c),
|
||||
case: FilterCase::from(&*c),
|
||||
done: c.bool("done"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::time::Duration;
|
||||
use std::{borrow::Cow, time::Duration};
|
||||
|
||||
use tokio::pin;
|
||||
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
||||
|
|
@ -6,19 +6,19 @@ use yazi_config::popup::InputCfg;
|
|||
use yazi_fs::FilterCase;
|
||||
use yazi_macro::emit;
|
||||
use yazi_proxy::InputProxy;
|
||||
use yazi_shared::{Debounce, Layer, errors::InputError, event::Cmd};
|
||||
use yazi_shared::{Debounce, Layer, errors::InputError, event::{Cmd, CmdCow}};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
pub(super) struct Opt {
|
||||
pub(super) query: Option<String>,
|
||||
pub(super) query: Option<Cow<'static, str>>,
|
||||
pub(super) prev: bool,
|
||||
pub(super) case: FilterCase,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
Self { query: c.take_first_str(), prev: c.bool("previous"), case: FilterCase::from(&c) }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self { query: c.take_first_str(), prev: c.bool("previous"), case: FilterCase::from(&*c) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
prev: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { prev: c.bool("previous") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { prev: c.bool("previous") } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn forward(&mut self, _: Cmd) { self.backstack.shift_forward().cloned().map(|u| self.cd(u)); }
|
||||
pub fn forward(&mut self, _: CmdCow) {
|
||||
self.backstack.shift_forward().cloned().map(|u| self.cd(u));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn hidden(&mut self, mut c: Cmd) {
|
||||
pub fn hidden(&mut self, mut c: CmdCow) {
|
||||
self.pref.show_hidden = match c.take_first_str().as_deref() {
|
||||
Some("show") => true,
|
||||
Some("hide") => false,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -6,8 +6,8 @@ struct Opt;
|
|||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
}
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
impl Tab {
|
||||
pub fn linemode(&mut self, mut c: Cmd) {
|
||||
pub fn linemode(&mut self, mut c: CmdCow) {
|
||||
render!(self.pref.patch(|new| {
|
||||
let Some(mode) = c.take_first_str() else {
|
||||
return;
|
||||
};
|
||||
if !mode.is_empty() && mode.len() <= 20 {
|
||||
new.linemode = mode;
|
||||
new.linemode = mode.into_owned();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::{event::{Cmd, Data}, fs::{File, FilesOp, Url, expand_path}};
|
||||
use yazi_shared::{event::CmdCow, fs::{File, FilesOp, Url, expand_path}};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ struct Opt {
|
|||
target: Url,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
let mut target = c.take_first().and_then(Data::into_url).unwrap_or_default();
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
let mut target = c.take_first_url().unwrap_or_default();
|
||||
if target.is_regular() {
|
||||
target = Url::from(expand_path(&target));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{mem, time::Duration};
|
||||
use std::{borrow::Cow, mem, time::Duration};
|
||||
|
||||
use tokio::pin;
|
||||
use tokio_stream::{StreamExt, wrappers::UnboundedReceiverStream};
|
||||
|
|
@ -29,7 +29,7 @@ impl Tab {
|
|||
InputProxy::show(InputCfg::search(&opt.via.to_string()).with_value(opt.subject));
|
||||
|
||||
if let Some(Ok(subject)) = input.recv().await {
|
||||
opt.subject = subject;
|
||||
opt.subject = Cow::Owned(subject);
|
||||
TabProxy::search_do(opt);
|
||||
}
|
||||
});
|
||||
|
|
@ -52,14 +52,14 @@ impl Tab {
|
|||
external::rg(external::RgOpt {
|
||||
cwd: cwd.clone(),
|
||||
hidden,
|
||||
subject: opt.subject,
|
||||
subject: opt.subject.into_owned(),
|
||||
args: opt.args,
|
||||
})
|
||||
} else {
|
||||
external::fd(external::FdOpt {
|
||||
cwd: cwd.clone(),
|
||||
hidden,
|
||||
subject: opt.subject,
|
||||
subject: opt.subject.into_owned(),
|
||||
args: opt.args,
|
||||
})
|
||||
}?;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use std::time::Duration;
|
||||
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl From<()> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,12 @@ use std::{borrow::Cow, fmt::Display};
|
|||
use anyhow::bail;
|
||||
use yazi_config::{open::Opener, popup::InputCfg};
|
||||
use yazi_proxy::{AppProxy, InputProxy, TasksProxy};
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
pub struct Opt {
|
||||
run: String,
|
||||
run: Cow<'static, str>,
|
||||
block: bool,
|
||||
orphan: bool,
|
||||
confirm: bool,
|
||||
|
|
@ -16,10 +16,10 @@ pub struct Opt {
|
|||
cursor: Option<usize>,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
let me = Self {
|
||||
run: c.take_first_str().unwrap_or_default(),
|
||||
block: c.bool("block"),
|
||||
|
|
@ -71,7 +71,7 @@ Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` wi
|
|||
let mut result =
|
||||
InputProxy::show(InputCfg::shell(opt.block).with_value(opt.run).with_cursor(opt.cursor));
|
||||
match result.recv().await {
|
||||
Some(Ok(e)) => opt.run = e,
|
||||
Some(Ok(e)) => opt.run = Cow::Owned(e),
|
||||
_ => return,
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ Please replace e.g. `shell` with `shell --interactive`, `shell "my-template"` wi
|
|||
TasksProxy::open_with(
|
||||
selected,
|
||||
Cow::Owned(Opener {
|
||||
run: opt.run,
|
||||
run: opt.run.into_owned(),
|
||||
block: opt.block,
|
||||
orphan: opt.orphan,
|
||||
desc: Default::default(),
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ use std::str::FromStr;
|
|||
|
||||
use yazi_config::manager::SortBy;
|
||||
use yazi_proxy::ManagerProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{tab::Tab, tasks::Tasks};
|
||||
|
||||
impl Tab {
|
||||
pub fn sort(&mut self, mut c: Cmd, tasks: &Tasks) {
|
||||
pub fn sort(&mut self, mut c: CmdCow, tasks: &Tasks) {
|
||||
let pref = &mut self.pref;
|
||||
if let Some(by) = c.take_first_str() {
|
||||
pref.sort_by = SortBy::from_str(&by).unwrap_or_default();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render_and;
|
||||
use yazi_proxy::AppProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
state: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
state: match c.take_first_str().as_deref() {
|
||||
Some("on") => Some(true),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_proxy::AppProxy;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -8,8 +8,8 @@ struct Opt {
|
|||
state: Option<bool>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self {
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self {
|
||||
Self {
|
||||
state: match c.take_first_str().as_deref() {
|
||||
Some("on") => Some(true),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_plugin::utils::PreviewLock;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -8,10 +8,10 @@ pub struct Opt {
|
|||
lock: PreviewLock,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { lock: c.take_any("lock").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_plugin::utils::SpotLock;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::Tab;
|
||||
|
||||
|
|
@ -8,10 +8,10 @@ pub struct Opt {
|
|||
lock: SpotLock,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self { lock: c.take_any("lock").ok_or(())? })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::BTreeSet;
|
||||
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tab::{Mode, Tab};
|
||||
|
||||
|
|
@ -9,8 +9,8 @@ struct Opt {
|
|||
unset: bool,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { unset: c.bool("unset") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { unset: c.bool("unset") } }
|
||||
}
|
||||
|
||||
impl Tab {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
step: isize,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(c: Cmd) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(c: CmdCow) -> Self { Self { step: c.first().and_then(Data::as_isize).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl From<isize> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
impl Tasks {
|
||||
pub fn cancel(&mut self, _: Cmd) {
|
||||
pub fn cancel(&mut self, _: CmdCow) {
|
||||
let id = self.ongoing().lock().get_id(self.cursor);
|
||||
if id.map(|id| self.scheduler.cancel(id)) != Some(true) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ use crossterm::terminal::{disable_raw_mode, enable_raw_mode};
|
|||
use scopeguard::defer;
|
||||
use tokio::{io::{AsyncReadExt, stdin}, select, sync::mpsc, time};
|
||||
use yazi_proxy::{AppProxy, HIDER};
|
||||
use yazi_shared::{event::Cmd, terminal_clear};
|
||||
use yazi_shared::{event::CmdCow, terminal_clear};
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
impl Tasks {
|
||||
pub fn inspect(&self, _: Cmd) {
|
||||
pub fn inspect(&self, _: CmdCow) {
|
||||
let ongoing = self.ongoing().clone();
|
||||
let Some(id) = ongoing.lock().get_id(self.cursor) else {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::tasks::Tasks;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
impl From<()> for Opt {
|
||||
fn from(_: ()) -> Self { Self }
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use tokio::sync::mpsc;
|
||||
use tracing::error;
|
||||
use yazi_shared::event::{Cmd, Data};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
use crate::which::Which;
|
||||
|
||||
|
|
@ -9,10 +9,10 @@ pub struct Opt {
|
|||
idx: usize,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
tx: c.take_any("tx").ok_or(())?,
|
||||
idx: c.first().and_then(Data::as_usize).ok_or(())?,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::str::FromStr;
|
|||
|
||||
use yazi_config::{KEYMAP, keymap::{Chord, Key}};
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::{Layer, event::Cmd};
|
||||
use yazi_shared::{Layer, event::CmdCow};
|
||||
|
||||
use crate::which::{Which, WhichSorter};
|
||||
|
||||
|
|
@ -12,10 +12,10 @@ pub struct Opt {
|
|||
silent: bool,
|
||||
}
|
||||
|
||||
impl TryFrom<Cmd> for Opt {
|
||||
impl TryFrom<CmdCow> for Opt {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(mut c: Cmd) -> Result<Self, Self::Error> {
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
Ok(Self {
|
||||
cands: c.take_any("candidates").unwrap_or_default(),
|
||||
layer: Layer::from_str(&c.take_str("layer").unwrap_or_default())?,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use crossterm::event::KeyEvent;
|
|||
use yazi_config::keymap::Key;
|
||||
use yazi_core::input::InputMode;
|
||||
use yazi_macro::emit;
|
||||
use yazi_shared::{Layer, event::{Cmd, Event, NEED_RENDER}};
|
||||
use yazi_shared::{Layer, event::{CmdCow, Event, NEED_RENDER}};
|
||||
|
||||
use crate::{Ctx, Executor, Router, Signals, Term, lives::Lives};
|
||||
|
||||
|
|
@ -66,10 +66,12 @@ impl App {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn dispatch_call(&mut self, cmd: Cmd, layer: Layer) { Executor::new(self).execute(cmd, layer); }
|
||||
fn dispatch_call(&mut self, cmd: CmdCow, layer: Layer) {
|
||||
Executor::new(self).execute(cmd, layer);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn dispatch_seq(&mut self, mut cmds: VecDeque<Cmd>, layer: Layer) {
|
||||
fn dispatch_seq(&mut self, mut cmds: VecDeque<CmdCow>, layer: Layer) {
|
||||
if let Some(cmd) = cmds.pop_front() {
|
||||
Executor::new(self).execute(cmd, layer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ use mlua::IntoLua;
|
|||
use tracing::error;
|
||||
use yazi_dds::{LOCAL, Payload, REMOTE};
|
||||
use yazi_plugin::LUA;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{app::App, lives::Lives};
|
||||
|
||||
impl App {
|
||||
pub(crate) fn accept_payload(&mut self, mut cmd: Cmd) {
|
||||
pub(crate) fn accept_payload(&mut self, mut cmd: CmdCow) {
|
||||
let Some(payload) = cmd.take_any::<Payload>("payload") else {
|
||||
return;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@ impl App {
|
|||
};
|
||||
|
||||
let mut hits = false;
|
||||
if let Some(chunk) = LOADER.read().get(&opt.id) {
|
||||
if let Some(chunk) = LOADER.read().get(opt.id.as_ref()) {
|
||||
hits = true;
|
||||
opt.mode = opt.mode.auto_then(chunk.sync_entry);
|
||||
}
|
||||
|
||||
if opt.mode == PluginMode::Async {
|
||||
return self.cx.tasks.plugin_micro(opt.id, opt.args);
|
||||
return self.cx.tasks.plugin_micro(opt.id.into_owned(), opt.args);
|
||||
} else if opt.mode == PluginMode::Sync && hits {
|
||||
return self.plugin_do(opt);
|
||||
}
|
||||
|
|
@ -42,12 +42,12 @@ impl App {
|
|||
};
|
||||
|
||||
let loader = LOADER.read();
|
||||
let Some(chunk) = loader.get(&opt.id) else {
|
||||
let Some(chunk) = loader.get(opt.id.as_ref()) else {
|
||||
return warn!("plugin `{}` not found", opt.id);
|
||||
};
|
||||
|
||||
if opt.mode.auto_then(chunk.sync_entry) != PluginMode::Sync {
|
||||
return self.cx.tasks.plugin_micro(opt.id, opt.args);
|
||||
return self.cx.tasks.plugin_micro(opt.id.into_owned(), opt.args);
|
||||
}
|
||||
|
||||
match LUA.named_registry_value::<RtRef>("rt") {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ use ratatui::layout::Position;
|
|||
use tracing::error;
|
||||
use yazi_config::LAYOUT;
|
||||
use yazi_macro::render;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{Root, app::App, lives::Lives};
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl From<()> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
struct Opt;
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(_: Cmd) -> Self { Self }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(_: CmdCow) -> Self { Self }
|
||||
}
|
||||
|
||||
impl From<()> for Opt {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::{Term, app::App};
|
||||
|
||||
impl App {
|
||||
pub(crate) fn resume(&mut self, _: Cmd) {
|
||||
pub(crate) fn resume(&mut self, _: CmdCow) {
|
||||
self.cx.active_mut().preview.reset_image();
|
||||
self.term = Some(Term::start().unwrap());
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use tokio::sync::oneshot;
|
||||
use yazi_shared::event::Cmd;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
|
|
@ -7,8 +7,8 @@ struct Opt {
|
|||
tx: Option<oneshot::Sender<()>>,
|
||||
}
|
||||
|
||||
impl From<Cmd> for Opt {
|
||||
fn from(mut c: Cmd) -> Self { Self { tx: c.take_any("tx") } }
|
||||
impl From<CmdCow> for Opt {
|
||||
fn from(mut c: CmdCow) -> Self { Self { tx: c.take_any("tx") } }
|
||||
}
|
||||
|
||||
impl App {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue