mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: allow DDS events to change command arguments
This commit is contained in:
parent
0b45ed868f
commit
7724ee9cad
118 changed files with 1360 additions and 776 deletions
28
Cargo.lock
generated
28
Cargo.lock
generated
|
|
@ -71,9 +71,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.19"
|
||||
version = "0.6.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933"
|
||||
checksum = "3ae563653d1938f79b1ab1b5e668c87c76a9930414574a6583a7b7e11a8e6192"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
|
|
@ -101,22 +101,22 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.3"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9"
|
||||
checksum = "9e231f6134f61b71076a3eab506c379d4f36122f2af15a9ff04415ea4c3339e2"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.9"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882"
|
||||
checksum = "3e0633414522a32ffaac8ac6cc8f748e090c5717661fddeea04219e2344f5f2a"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"once_cell_polyfill",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -2751,9 +2751,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.9.4"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41ae868b5a0f67631c14589f7e250c1ea2c574ee5ba21c6c8dd4b1485705a5a1"
|
||||
checksum = "75129e1dc5000bfbaa9fee9d1b21f974f9fbad9daec557a521ee6e080825f6e8"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
|
|
@ -2797,9 +2797,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.0.1"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97200572db069e74c512a14117b296ba0a80a30123fbbb5aa1f4a348f639ca30"
|
||||
checksum = "b551886f449aa90d4fe2bdaa9f4a2577ad2dde302c61ecf262d80b116db95c10"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
|
@ -3580,7 +3580,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"toml 0.9.4",
|
||||
"toml 0.9.5",
|
||||
"twox-hash",
|
||||
"vergen-gitcl",
|
||||
"yazi-boot",
|
||||
|
|
@ -3611,7 +3611,7 @@ dependencies = [
|
|||
"ratatui",
|
||||
"regex",
|
||||
"serde",
|
||||
"toml 0.9.4",
|
||||
"toml 0.9.5",
|
||||
"tracing",
|
||||
"yazi-codegen",
|
||||
"yazi-fs",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ syntect = { version = "5.2.0", default-features = false, features =
|
|||
tokio = { version = "1.47.1", features = [ "full" ] }
|
||||
tokio-stream = "0.1.17"
|
||||
tokio-util = "0.7.16"
|
||||
toml = { version = "0.9.4" }
|
||||
toml = { version = "0.9.5" }
|
||||
tracing = { version = "0.1.41", features = [ "max_level_debug", "release_max_level_debug" ] }
|
||||
twox-hash = { version = "2.1.1", default-features = false, features = [ "std", "random", "xxhash3_128" ] }
|
||||
unicode-width = { version = "0.2.0", default-features = false }
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ Yazi (means "duck") is a terminal file manager written in Rust, based on non-blo
|
|||
- 💫 Vim-like input/pick/confirm/which/notify component, auto-completion for cd paths
|
||||
- 🏷️ Multi-Tab Support, Cross-directory selection, Scrollable Preview (for videos, PDFs, archives, code, directories, etc.)
|
||||
- 🔄 Bulk Renaming, Archive Extraction, Visual Mode, File Chooser, [Git Integration](https://github.com/yazi-rs/plugins/tree/main/git.yazi), [Mount Manager](https://github.com/yazi-rs/plugins/tree/main/mount.yazi)
|
||||
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, CSI u, OSC 52
|
||||
- 🎨 Theme System, Mouse Support, Trash Bin, Custom Layouts, Virtual Filesystem, CSI u, OSC 52
|
||||
- ... and more!
|
||||
|
||||
https://github.com/sxyazi/yazi/assets/17523360/92ff23fa-0cd5-4f04-b387-894c12265cc7
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use anyhow::Result;
|
||||
use yazi_dds::spark::SparkKind;
|
||||
use yazi_shared::event::Data;
|
||||
|
||||
use crate::Ctx;
|
||||
|
|
@ -10,5 +11,5 @@ pub trait Actor {
|
|||
|
||||
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data>;
|
||||
|
||||
fn hook(_cx: &Ctx, _opt: &Self::Options) -> Option<&'static str> { None }
|
||||
fn hook(_cx: &Ctx, _opt: &Self::Options) -> Option<SparkKind> { None }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,45 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use anyhow::Result;
|
||||
use mlua::{IntoLua, Value};
|
||||
use tracing::error;
|
||||
use mlua::{ErrorContext, ExternalError, IntoLua, Value};
|
||||
use yazi_binding::runtime_mut;
|
||||
use yazi_dds::{LOCAL, body::Body};
|
||||
use yazi_macro::succ;
|
||||
use yazi_dds::{LOCAL, spark::{Spark, SparkKind}};
|
||||
use yazi_plugin::LUA;
|
||||
use yazi_shared::event::Data;
|
||||
|
||||
use crate::{Actor, Ctx, lives::Lives};
|
||||
use crate::{Ctx, lives::Lives};
|
||||
|
||||
pub struct Preflight<'a> {
|
||||
_lifetime: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
impl<'a> Actor for Preflight<'a> {
|
||||
type Options = (&'static str, Body<'a>);
|
||||
|
||||
const NAME: &'static str = "preflight";
|
||||
|
||||
fn act(cx: &mut Ctx, opt: Self::Options) -> Result<Data> {
|
||||
impl<'a> Preflight<'a> {
|
||||
pub fn act(cx: &mut Ctx, opt: (SparkKind, Spark<'a>)) -> Result<Spark<'a>> {
|
||||
let kind = opt.0;
|
||||
let Some(handlers) = LOCAL.read().get(kind).filter(|&m| !m.is_empty()).cloned() else {
|
||||
succ!(false)
|
||||
let Some(handlers) = LOCAL.read().get(kind.as_ref()).filter(|&m| !m.is_empty()).cloned() else {
|
||||
return Ok(opt.1);
|
||||
};
|
||||
|
||||
succ!(Lives::scope(cx.core, || {
|
||||
let body = opt.1.into_lua(&LUA)?;
|
||||
Ok(Lives::scope(cx.core, || {
|
||||
let mut body = opt.1.into_lua(&LUA)?;
|
||||
for (id, cb) in handlers {
|
||||
runtime_mut!(LUA)?.push(&id);
|
||||
let result = cb.call::<Value>(body.clone());
|
||||
let result = cb.call::<Value>(&body);
|
||||
runtime_mut!(LUA)?.pop();
|
||||
|
||||
match result {
|
||||
Ok(Value::Boolean(true)) => return Ok(true),
|
||||
Ok(Value::Nil | Value::Boolean(false)) => {}
|
||||
Ok(v) => {
|
||||
error!("Unexpected return type from `{kind}` event handler in `{id}` plugin: {v:?}")
|
||||
}
|
||||
Err(e) => error!("Failed to run `{kind}` event handler in `{id}` plugin: {e}"),
|
||||
}
|
||||
Ok(Value::Nil) => Err(
|
||||
format!("Cancelled by `{kind}` event handler in `{id}` plugin on preflight")
|
||||
.into_lua_err(),
|
||||
)?,
|
||||
Ok(v) => body = v,
|
||||
Err(e) => Err(
|
||||
format!("Failed to run `{kind}` event handler in `{id}` plugin: {e}").into_lua_err(),
|
||||
)?,
|
||||
};
|
||||
}
|
||||
Ok(false)
|
||||
|
||||
Spark::from_lua(&LUA, kind, body)
|
||||
.with_context(|e| format!("Unexpected return type from `{kind}` event handlers: {e}"))
|
||||
})?)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use anyhow::Result;
|
|||
use tokio::{select, time};
|
||||
use yazi_boot::ARGS;
|
||||
use yazi_config::popup::ConfirmCfg;
|
||||
use yazi_dds::spark::SparkKind;
|
||||
use yazi_macro::{emit, succ};
|
||||
use yazi_parser::mgr::{OpenOpt, QuitOpt};
|
||||
use yazi_proxy::ConfirmProxy;
|
||||
|
|
@ -60,8 +61,8 @@ impl Actor for Quit {
|
|||
succ!();
|
||||
}
|
||||
|
||||
fn hook(cx: &Ctx, _opt: &Self::Options) -> Option<&'static str> {
|
||||
Some("key-quit").filter(|_| cx.source().is_key())
|
||||
fn hook(cx: &Ctx, _opt: &Self::Options) -> Option<SparkKind> {
|
||||
Some(SparkKind::KeyQuit).filter(|_| cx.source().is_key())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use yazi_shared::{IntoStringLossy, url::Url};
|
|||
use super::{Offset, Position};
|
||||
use crate::YAZI;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct InputCfg {
|
||||
pub title: String,
|
||||
pub value: String,
|
||||
|
|
@ -15,14 +15,14 @@ pub struct InputCfg {
|
|||
pub completion: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct PickCfg {
|
||||
pub title: String,
|
||||
pub items: Vec<String>,
|
||||
pub position: Position,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ConfirmCfg {
|
||||
pub position: Position,
|
||||
pub title: Line<'static>,
|
||||
|
|
|
|||
|
|
@ -1,344 +0,0 @@
|
|||
use anyhow::{Result, bail};
|
||||
use mlua::{ExternalResult, IntoLua, Lua, Value};
|
||||
use yazi_shared::Id;
|
||||
|
||||
use super::{BodyBulk, BodyBye, BodyCd, BodyCustom, BodyDelete, BodyHey, BodyHi, BodyHover, BodyLoad, BodyMount, BodyMove, BodyRename, BodyTab, BodyTrash, BodyYank};
|
||||
use crate::Payload;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Body<'a> {
|
||||
Hi(BodyHi<'a>),
|
||||
Hey(BodyHey),
|
||||
Bye(BodyBye),
|
||||
Tab(BodyTab),
|
||||
Cd(BodyCd<'a>),
|
||||
Load(BodyLoad<'a>),
|
||||
Hover(BodyHover<'a>),
|
||||
Rename(BodyRename<'a>),
|
||||
Bulk(BodyBulk<'a>),
|
||||
Yank(BodyYank<'a>),
|
||||
Move(BodyMove<'a>),
|
||||
Trash(BodyTrash<'a>),
|
||||
Delete(BodyDelete<'a>),
|
||||
Mount(BodyMount),
|
||||
Custom(BodyCustom),
|
||||
|
||||
// Manager key events
|
||||
KeyArrow(&'a yazi_parser::ArrowOpt),
|
||||
KeyBack(&'a yazi_parser::VoidOpt),
|
||||
KeyBulkRename(&'a yazi_parser::VoidOpt),
|
||||
KeyCd(&'a yazi_parser::mgr::CdOpt),
|
||||
KeyClose(&'a yazi_parser::mgr::CloseOpt),
|
||||
KeyCopy(&'a yazi_parser::mgr::CopyOpt),
|
||||
KeyCreate(&'a yazi_parser::mgr::CreateOpt),
|
||||
KeyEnter(&'a yazi_parser::VoidOpt),
|
||||
KeyEscape(&'a yazi_parser::mgr::EscapeOpt),
|
||||
KeyEscapeFilter(&'a yazi_parser::VoidOpt),
|
||||
KeyEscapeFind(&'a yazi_parser::VoidOpt),
|
||||
KeyEscapeSearch(&'a yazi_parser::VoidOpt),
|
||||
KeyEscapeSelect(&'a yazi_parser::VoidOpt),
|
||||
KeyEscapeVisual(&'a yazi_parser::VoidOpt),
|
||||
KeyFilter(&'a yazi_parser::mgr::FilterOpt),
|
||||
KeyFilterDo(&'a yazi_parser::mgr::FilterOpt),
|
||||
KeyFind(&'a yazi_parser::mgr::FindOpt),
|
||||
KeyFindArrow(&'a yazi_parser::mgr::FindArrowOpt),
|
||||
KeyFindDo(&'a yazi_parser::mgr::FindDoOpt),
|
||||
KeyFollow(&'a yazi_parser::VoidOpt),
|
||||
KeyForward(&'a yazi_parser::VoidOpt),
|
||||
KeyHardlink(&'a yazi_parser::mgr::HardlinkOpt),
|
||||
KeyHidden(&'a yazi_parser::mgr::HiddenOpt),
|
||||
KeyHover(&'a yazi_parser::mgr::HoverOpt),
|
||||
KeyHoverDo(&'a yazi_parser::mgr::HoverDoOpt),
|
||||
KeyLeave(&'a yazi_parser::VoidOpt),
|
||||
KeyLinemode(&'a yazi_parser::mgr::LinemodeOpt),
|
||||
KeyLink(&'a yazi_parser::mgr::LinkOpt),
|
||||
KeyOpen(&'a yazi_parser::mgr::OpenOpt),
|
||||
KeyOpenDo(&'a yazi_parser::mgr::OpenDoOpt),
|
||||
KeyPaste(&'a yazi_parser::mgr::PasteOpt),
|
||||
KeyPeek(&'a yazi_parser::mgr::PeekOpt),
|
||||
KeyQuit(&'a yazi_parser::mgr::QuitOpt),
|
||||
KeyRefresh(&'a yazi_parser::VoidOpt),
|
||||
KeyRemove(&'a yazi_parser::mgr::RemoveOpt),
|
||||
KeyRemoveDo(&'a yazi_parser::mgr::RemoveOpt),
|
||||
KeyRename(&'a yazi_parser::mgr::RenameOpt),
|
||||
KeyReveal(&'a yazi_parser::mgr::RevealOpt),
|
||||
KeySearch(&'a yazi_parser::mgr::SearchOpt),
|
||||
KeySearchDo(&'a yazi_parser::mgr::SearchOpt),
|
||||
KeySearchStop(&'a yazi_parser::VoidOpt),
|
||||
KeySeek(&'a yazi_parser::mgr::SeekOpt),
|
||||
KeyShell(&'a yazi_parser::mgr::ShellOpt),
|
||||
KeySort(&'a yazi_parser::mgr::SortOpt),
|
||||
KeySpot(&'a yazi_parser::mgr::SpotOpt),
|
||||
KeySuspend(&'a yazi_parser::VoidOpt),
|
||||
KeyTabClose(&'a yazi_parser::mgr::TabCloseOpt),
|
||||
KeyTabCreate(&'a yazi_parser::mgr::TabCreateOpt),
|
||||
KeyTabSwap(&'a yazi_parser::ArrowOpt),
|
||||
KeyTabSwitch(&'a yazi_parser::mgr::TabSwitchOpt),
|
||||
KeyToggle(&'a yazi_parser::mgr::ToggleOpt),
|
||||
KeyToggleAll(&'a yazi_parser::mgr::ToggleAllOpt),
|
||||
KeyUnyank(&'a yazi_parser::VoidOpt),
|
||||
KeyUpdateFiles(&'a yazi_parser::mgr::UpdateFilesOpt),
|
||||
KeyUpdateMimes(&'a yazi_parser::mgr::UpdateMimesOpt),
|
||||
KeyUpdatePaged(&'a yazi_parser::mgr::UpdatePagedOpt),
|
||||
KeyUpdatePeeked(&'a yazi_parser::mgr::UpdatePeekedOpt),
|
||||
KeyUpdateSpotted(&'a yazi_parser::mgr::UpdateSpottedOpt),
|
||||
KeyUpdateTasks(&'a yazi_parser::mgr::UpdateTasksOpt),
|
||||
KeyUpdateYanked(&'a yazi_parser::mgr::UpdateYankedOpt<'a>),
|
||||
KeyVisualMode(&'a yazi_parser::mgr::VisualModeOpt),
|
||||
KeyWatch(&'a yazi_parser::VoidOpt),
|
||||
KeyYank(&'a yazi_parser::mgr::YankOpt),
|
||||
// Void
|
||||
Void(&'a yazi_parser::VoidOpt),
|
||||
}
|
||||
|
||||
impl Body<'static> {
|
||||
pub fn from_str(kind: &str, body: &str) -> Result<Self> {
|
||||
Ok(match kind {
|
||||
"hi" => Self::Hi(serde_json::from_str(body)?),
|
||||
"hey" => Self::Hey(serde_json::from_str(body)?),
|
||||
"bye" => Self::Bye(serde_json::from_str(body)?),
|
||||
"tab" => Self::Tab(serde_json::from_str(body)?),
|
||||
"cd" => Self::Cd(serde_json::from_str(body)?),
|
||||
"load" => Self::Load(serde_json::from_str(body)?),
|
||||
"hover" => Self::Hover(serde_json::from_str(body)?),
|
||||
"rename" => Self::Rename(serde_json::from_str(body)?),
|
||||
"bulk" => Self::Bulk(serde_json::from_str(body)?),
|
||||
"@yank" => Self::Yank(serde_json::from_str(body)?),
|
||||
"move" => Self::Move(serde_json::from_str(body)?),
|
||||
"trash" => Self::Trash(serde_json::from_str(body)?),
|
||||
"delete" => Self::Delete(serde_json::from_str(body)?),
|
||||
"mount" => Self::Mount(serde_json::from_str(body)?),
|
||||
_ => BodyCustom::from_str(kind, body)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_lua(lua: &Lua, kind: &str, value: Value) -> mlua::Result<Self> {
|
||||
Self::validate(kind).into_lua_err()?;
|
||||
BodyCustom::from_lua(lua, kind, value)
|
||||
}
|
||||
|
||||
pub fn validate(kind: &str) -> Result<()> {
|
||||
if matches!(
|
||||
kind,
|
||||
"hi"
|
||||
| "hey"
|
||||
| "bye"
|
||||
| "tab"
|
||||
| "cd"
|
||||
| "load"
|
||||
| "hover"
|
||||
| "rename"
|
||||
| "bulk"
|
||||
| "@yank"
|
||||
| "move"
|
||||
| "trash"
|
||||
| "delete"
|
||||
| "mount"
|
||||
) || kind.starts_with("emit-")
|
||||
|| kind.starts_with("emit-ind-")
|
||||
|| kind.starts_with("ind-")
|
||||
|| kind.starts_with("key-")
|
||||
|| kind.starts_with("relay-")
|
||||
|| kind.starts_with("relay-ind-")
|
||||
{
|
||||
bail!("Cannot construct system event");
|
||||
}
|
||||
|
||||
let mut it = kind.bytes().peekable();
|
||||
if it.peek() == Some(&b'@') {
|
||||
it.next(); // Skip `@` as it's a prefix for static messages
|
||||
}
|
||||
if !it.all(|b| b.is_ascii_alphanumeric() || b == b'-') {
|
||||
bail!("Kind must be alphanumeric with dashes");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Body<'a> {
|
||||
#[inline]
|
||||
pub fn kind(&self) -> &str {
|
||||
match self {
|
||||
Self::Hi(_) => "hi",
|
||||
Self::Hey(_) => "hey",
|
||||
Self::Bye(_) => "bye",
|
||||
Self::Tab(_) => "tab",
|
||||
Self::Cd(_) => "cd",
|
||||
Self::Load(_) => "load",
|
||||
Self::Hover(_) => "hover",
|
||||
Self::Rename(_) => "rename",
|
||||
Self::Bulk(_) => "bulk",
|
||||
Self::Yank(_) => "@yank",
|
||||
Self::Move(_) => "move",
|
||||
Self::Trash(_) => "trash",
|
||||
Self::Delete(_) => "delete",
|
||||
Self::Mount(_) => "mount",
|
||||
Self::Custom(b) => b.kind.as_str(),
|
||||
|
||||
// Manager key events
|
||||
Self::KeyArrow(_) => "key-arrow",
|
||||
Self::KeyBack(_) => "key-back",
|
||||
Self::KeyBulkRename(_) => "key-bulk-rename",
|
||||
Self::KeyCd(_) => "key-cd",
|
||||
Self::KeyClose(_) => "key-close",
|
||||
Self::KeyCopy(_) => "key-copy",
|
||||
Self::KeyCreate(_) => "key-create",
|
||||
Self::KeyEnter(_) => "key-enter",
|
||||
Self::KeyEscape(_) => "key-escape",
|
||||
Self::KeyEscapeFilter(_) => "key-escape-filter",
|
||||
Self::KeyEscapeFind(_) => "key-escape-find",
|
||||
Self::KeyEscapeSearch(_) => "key-escape-search",
|
||||
Self::KeyEscapeSelect(_) => "key-escape-select",
|
||||
Self::KeyEscapeVisual(_) => "key-escape-visual",
|
||||
Self::KeyFilter(_) => "key-filter",
|
||||
Self::KeyFilterDo(_) => "key-filter-do",
|
||||
Self::KeyFind(_) => "key-find",
|
||||
Self::KeyFindArrow(_) => "key-find-arrow",
|
||||
Self::KeyFindDo(_) => "key-find-do",
|
||||
Self::KeyFollow(_) => "key-follow",
|
||||
Self::KeyForward(_) => "key-forward",
|
||||
Self::KeyHardlink(_) => "key-hardlink",
|
||||
Self::KeyHidden(_) => "key-hidden",
|
||||
Self::KeyHover(_) => "key-hover",
|
||||
Self::KeyHoverDo(_) => "key-hover-do",
|
||||
Self::KeyLeave(_) => "key-leave",
|
||||
Self::KeyLinemode(_) => "key-linemode",
|
||||
Self::KeyLink(_) => "key-link",
|
||||
Self::KeyOpen(_) => "key-open",
|
||||
Self::KeyOpenDo(_) => "key-open-do",
|
||||
Self::KeyPaste(_) => "key-paste",
|
||||
Self::KeyPeek(_) => "key-peek",
|
||||
Self::KeyQuit(_) => "key-quit",
|
||||
Self::KeyRefresh(_) => "key-refresh",
|
||||
Self::KeyRemove(_) => "key-remove",
|
||||
Self::KeyRemoveDo(_) => "key-remove-do",
|
||||
Self::KeyRename(_) => "key-rename",
|
||||
Self::KeyReveal(_) => "key-reveal",
|
||||
Self::KeySearch(_) => "key-search",
|
||||
Self::KeySearchDo(_) => "key-search-do",
|
||||
Self::KeySearchStop(_) => "key-search-stop",
|
||||
Self::KeySeek(_) => "key-seek",
|
||||
Self::KeyShell(_) => "key-shell",
|
||||
Self::KeySort(_) => "key-sort",
|
||||
Self::KeySpot(_) => "key-spot",
|
||||
Self::KeySuspend(_) => "key-suspend",
|
||||
Self::KeyTabClose(_) => "key-tab-close",
|
||||
Self::KeyTabCreate(_) => "key-tab-create",
|
||||
Self::KeyTabSwap(_) => "key-tab-swap",
|
||||
Self::KeyTabSwitch(_) => "key-tab-switch",
|
||||
Self::KeyToggle(_) => "key-toggle",
|
||||
Self::KeyToggleAll(_) => "key-toggle-all",
|
||||
Self::KeyUnyank(_) => "key-unyank",
|
||||
Self::KeyUpdateFiles(_) => "key-update-files",
|
||||
Self::KeyUpdateMimes(_) => "key-update-mimes",
|
||||
Self::KeyUpdatePaged(_) => "key-update-paged",
|
||||
Self::KeyUpdatePeeked(_) => "key-update-peeked",
|
||||
Self::KeyUpdateSpotted(_) => "key-update-spotted",
|
||||
Self::KeyUpdateTasks(_) => "key-update-tasks",
|
||||
Self::KeyUpdateYanked(_) => "key-update-yanked",
|
||||
Self::KeyVisualMode(_) => "key-visual-mode",
|
||||
Self::KeyWatch(_) => "key-watch",
|
||||
Self::KeyYank(_) => "key-yank",
|
||||
// Void
|
||||
Self::Void(_) => "void",
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_receiver(self, receiver: Id) -> Payload<'a> {
|
||||
Payload::new(self).with_receiver(receiver)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_sender(self, sender: Id) -> Payload<'a> { Payload::new(self).with_sender(sender) }
|
||||
}
|
||||
|
||||
impl<'a> IntoLua for Body<'a> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
match self {
|
||||
Self::Hi(b) => b.into_lua(lua),
|
||||
Self::Hey(b) => b.into_lua(lua),
|
||||
Self::Bye(b) => b.into_lua(lua),
|
||||
Self::Cd(b) => b.into_lua(lua),
|
||||
Self::Load(b) => b.into_lua(lua),
|
||||
Self::Hover(b) => b.into_lua(lua),
|
||||
Self::Tab(b) => b.into_lua(lua),
|
||||
Self::Rename(b) => b.into_lua(lua),
|
||||
Self::Bulk(b) => b.into_lua(lua),
|
||||
Self::Yank(b) => b.into_lua(lua),
|
||||
Self::Move(b) => b.into_lua(lua),
|
||||
Self::Trash(b) => b.into_lua(lua),
|
||||
Self::Delete(b) => b.into_lua(lua),
|
||||
Self::Mount(b) => b.into_lua(lua),
|
||||
Self::Custom(b) => b.into_lua(lua),
|
||||
|
||||
// Manager key events
|
||||
Self::KeyArrow(b) => b.into_lua(lua),
|
||||
Self::KeyBack(b) => b.into_lua(lua),
|
||||
Self::KeyBulkRename(b) => b.into_lua(lua),
|
||||
Self::KeyCd(b) => b.into_lua(lua),
|
||||
Self::KeyClose(b) => b.into_lua(lua),
|
||||
Self::KeyCopy(b) => b.into_lua(lua),
|
||||
Self::KeyCreate(b) => b.into_lua(lua),
|
||||
Self::KeyEnter(b) => b.into_lua(lua),
|
||||
Self::KeyEscape(b) => b.into_lua(lua),
|
||||
Self::KeyEscapeFilter(b) => b.into_lua(lua),
|
||||
Self::KeyEscapeFind(b) => b.into_lua(lua),
|
||||
Self::KeyEscapeSearch(b) => b.into_lua(lua),
|
||||
Self::KeyEscapeSelect(b) => b.into_lua(lua),
|
||||
Self::KeyEscapeVisual(b) => b.into_lua(lua),
|
||||
Self::KeyFilter(b) => b.into_lua(lua),
|
||||
Self::KeyFilterDo(b) => b.into_lua(lua),
|
||||
Self::KeyFind(b) => b.into_lua(lua),
|
||||
Self::KeyFindArrow(b) => b.into_lua(lua),
|
||||
Self::KeyFindDo(b) => b.into_lua(lua),
|
||||
Self::KeyFollow(b) => b.into_lua(lua),
|
||||
Self::KeyForward(b) => b.into_lua(lua),
|
||||
Self::KeyHardlink(b) => b.into_lua(lua),
|
||||
Self::KeyHidden(b) => b.into_lua(lua),
|
||||
Self::KeyHover(b) => b.into_lua(lua),
|
||||
Self::KeyHoverDo(b) => b.into_lua(lua),
|
||||
Self::KeyLeave(b) => b.into_lua(lua),
|
||||
Self::KeyLinemode(b) => b.into_lua(lua),
|
||||
Self::KeyLink(b) => b.into_lua(lua),
|
||||
Self::KeyOpen(b) => b.into_lua(lua),
|
||||
Self::KeyOpenDo(b) => b.into_lua(lua),
|
||||
Self::KeyPaste(b) => b.into_lua(lua),
|
||||
Self::KeyPeek(b) => b.into_lua(lua),
|
||||
Self::KeyQuit(b) => b.into_lua(lua),
|
||||
Self::KeyRefresh(b) => b.into_lua(lua),
|
||||
Self::KeyRemove(b) => b.into_lua(lua),
|
||||
Self::KeyRemoveDo(b) => b.into_lua(lua),
|
||||
Self::KeyRename(b) => b.into_lua(lua),
|
||||
Self::KeyReveal(b) => b.into_lua(lua),
|
||||
Self::KeySearch(b) => b.into_lua(lua),
|
||||
Self::KeySearchDo(b) => b.into_lua(lua),
|
||||
Self::KeySearchStop(b) => b.into_lua(lua),
|
||||
Self::KeySeek(b) => b.into_lua(lua),
|
||||
Self::KeyShell(b) => b.into_lua(lua),
|
||||
Self::KeySort(b) => b.into_lua(lua),
|
||||
Self::KeySpot(b) => b.into_lua(lua),
|
||||
Self::KeySuspend(b) => b.into_lua(lua),
|
||||
Self::KeyTabClose(b) => b.into_lua(lua),
|
||||
Self::KeyTabCreate(b) => b.into_lua(lua),
|
||||
Self::KeyTabSwap(b) => b.into_lua(lua),
|
||||
Self::KeyTabSwitch(b) => b.into_lua(lua),
|
||||
Self::KeyToggle(b) => b.into_lua(lua),
|
||||
Self::KeyToggleAll(b) => b.into_lua(lua),
|
||||
Self::KeyUnyank(b) => b.into_lua(lua),
|
||||
Self::KeyUpdateFiles(b) => b.into_lua(lua),
|
||||
Self::KeyUpdateMimes(b) => b.into_lua(lua),
|
||||
Self::KeyUpdatePaged(b) => b.into_lua(lua),
|
||||
Self::KeyUpdatePeeked(b) => b.into_lua(lua),
|
||||
Self::KeyUpdateSpotted(b) => b.into_lua(lua),
|
||||
Self::KeyUpdateTasks(b) => b.into_lua(lua),
|
||||
Self::KeyUpdateYanked(b) => b.into_lua(lua),
|
||||
Self::KeyVisualMode(b) => b.into_lua(lua),
|
||||
Self::KeyWatch(b) => b.into_lua(lua),
|
||||
Self::KeyYank(b) => b.into_lua(lua),
|
||||
// Void
|
||||
Self::Void(b) => b.into_lua(lua),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
use super::Body;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyDelete<'a> {
|
||||
pub urls: Cow<'a, Vec<Url>>,
|
||||
}
|
||||
|
||||
impl<'a> BodyDelete<'a> {
|
||||
pub fn borrowed(urls: &'a Vec<Url>) -> Body<'a> { Self { urls: Cow::Borrowed(urls) }.into() }
|
||||
}
|
||||
|
||||
impl BodyDelete<'static> {
|
||||
pub fn owned(urls: Vec<Url>) -> Body<'static> { Self { urls: Cow::Owned(urls) }.into() }
|
||||
}
|
||||
|
||||
impl<'a> From<BodyDelete<'a>> for Body<'a> {
|
||||
fn from(value: BodyDelete<'a>) -> Self { Self::Delete(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyDelete<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
let urls =
|
||||
lua.create_sequence_from(self.urls.into_owned().into_iter().map(yazi_binding::Url::new))?;
|
||||
|
||||
lua.create_table_from([("urls", urls)])?.into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#![allow(clippy::module_inception)]
|
||||
|
||||
yazi_macro::mod_flat!(
|
||||
body bulk bye cd custom delete hey hi hover load mount r#move rename tab trash yank
|
||||
);
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Body;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyMount;
|
||||
|
||||
impl BodyMount {
|
||||
pub fn owned() -> Body<'static> { Self.into() }
|
||||
|
||||
pub fn borrowed() -> Body<'static> { Self::owned() }
|
||||
}
|
||||
|
||||
impl From<BodyMount> for Body<'_> {
|
||||
fn from(value: BodyMount) -> Self { Self::Mount(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyMount {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Ok(Value::Nil) }
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::Id;
|
||||
|
||||
use super::Body;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyTab {
|
||||
pub id: Id,
|
||||
}
|
||||
|
||||
impl BodyTab {
|
||||
pub fn owned(id: Id) -> Body<'static> { Self { id }.into() }
|
||||
|
||||
pub fn borrowed(id: Id) -> Body<'static> { Self::owned(id) }
|
||||
}
|
||||
|
||||
impl From<BodyTab> for Body<'_> {
|
||||
fn from(value: BodyTab) -> Self { Self::Tab(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyTab {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua.create_table_from([("idx", self.id.get())])?.into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ use tracing::error;
|
|||
use yazi_macro::try_format;
|
||||
use yazi_shared::{Id, RoCell};
|
||||
|
||||
use crate::{ClientReader, ClientWriter, Payload, Pubsub, Server, Stream, body::{Body, BodyBye, BodyHi}};
|
||||
use crate::{ClientReader, ClientWriter, Payload, Pubsub, Server, Stream, ember::{Ember, EmberBye, EmberHi}};
|
||||
|
||||
pub static ID: RoCell<Id> = RoCell::new();
|
||||
pub(super) static PEERS: RoCell<RwLock<HashMap<Id, Peer>>> = RoCell::new();
|
||||
|
|
@ -67,12 +67,12 @@ impl Client {
|
|||
|
||||
/// Connect to an existing server to send a single message.
|
||||
pub async fn shot(kind: &str, receiver: Id, body: &str) -> Result<()> {
|
||||
Body::validate(kind)?;
|
||||
Ember::validate(kind)?;
|
||||
|
||||
let payload = try_format!(
|
||||
"{}\n{kind},{receiver},{ID},{body}\n{}\n",
|
||||
Payload::new(BodyHi::borrowed(iter::empty())),
|
||||
Payload::new(BodyBye::owned())
|
||||
Payload::new(EmberHi::borrowed(iter::empty())),
|
||||
Payload::new(EmberBye::owned())
|
||||
)?;
|
||||
|
||||
let (mut lines, mut writer) = Stream::connect().await?;
|
||||
|
|
@ -84,7 +84,7 @@ impl Client {
|
|||
while let Ok(Some(line)) = lines.next_line().await {
|
||||
match line.split(',').next() {
|
||||
Some("hey") => {
|
||||
if let Ok(Body::Hey(hey)) = Payload::from_str(&line).map(|p| p.body) {
|
||||
if let Ok(Ember::Hey(hey)) = Payload::from_str(&line).map(|p| p.body) {
|
||||
(peers, version) = (hey.peers, Some(hey.version));
|
||||
}
|
||||
}
|
||||
|
|
@ -93,10 +93,10 @@ impl Client {
|
|||
}
|
||||
}
|
||||
|
||||
if version.as_deref() != Some(BodyHi::version()) {
|
||||
if version.as_deref() != Some(EmberHi::version()) {
|
||||
bail!(
|
||||
"Incompatible version (Ya {}, Yazi {}). Restart all `ya` and `yazi` processes if you upgrade either one.",
|
||||
BodyHi::version(),
|
||||
EmberHi::version(),
|
||||
version.as_deref().unwrap_or("Unknown")
|
||||
);
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ impl Client {
|
|||
pub async fn draw(kinds: HashSet<&str>) -> Result<()> {
|
||||
async fn make(kinds: &HashSet<&str>) -> Result<ClientReader> {
|
||||
let (lines, mut writer) = Stream::connect().await?;
|
||||
let hi = Payload::new(BodyHi::borrowed(kinds.iter().copied()));
|
||||
let hi = Payload::new(EmberHi::borrowed(kinds.iter().copied()));
|
||||
writer.write_all(try_format!("{hi}\n")?.as_bytes()).await?;
|
||||
writer.flush().await?;
|
||||
Ok(lines)
|
||||
|
|
@ -192,7 +192,7 @@ impl Client {
|
|||
}
|
||||
|
||||
fn handle_hey(s: &str) {
|
||||
if let Ok(Body::Hey(mut hey)) = Payload::from_str(s).map(|p| p.body) {
|
||||
if let Ok(Ember::Hey(mut hey)) = Payload::from_str(s).map(|p| p.body) {
|
||||
hey.peers.retain(|&id, _| id != *ID);
|
||||
*PEERS.write() = hey.peers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,15 +4,15 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyBulk<'a> {
|
||||
pub struct EmberBulk<'a> {
|
||||
pub changes: HashMap<Cow<'a, Url>, Cow<'a, Url>>,
|
||||
}
|
||||
|
||||
impl<'a> BodyBulk<'a> {
|
||||
pub fn borrowed<I>(changes: I) -> Body<'a>
|
||||
impl<'a> EmberBulk<'a> {
|
||||
pub fn borrowed<I>(changes: I) -> Ember<'a>
|
||||
where
|
||||
I: Iterator<Item = (&'a Url, &'a Url)>,
|
||||
{
|
||||
|
|
@ -20,8 +20,8 @@ impl<'a> BodyBulk<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl BodyBulk<'static> {
|
||||
pub fn owned<'a, I>(changes: I) -> Body<'static>
|
||||
impl EmberBulk<'static> {
|
||||
pub fn owned<'a, I>(changes: I) -> Ember<'static>
|
||||
where
|
||||
I: Iterator<Item = (&'a Url, &'a Url)>,
|
||||
{
|
||||
|
|
@ -30,11 +30,11 @@ impl BodyBulk<'static> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyBulk<'a>> for Body<'a> {
|
||||
fn from(value: BodyBulk<'a>) -> Self { Self::Bulk(value) }
|
||||
impl<'a> From<EmberBulk<'a>> for Ember<'a> {
|
||||
fn from(value: EmberBulk<'a>) -> Self { Self::Bulk(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyBulk<'_> {
|
||||
impl IntoLua for EmberBulk<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua
|
||||
.create_table_from(
|
||||
|
|
@ -1,20 +1,20 @@
|
|||
use mlua::{ExternalResult, IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyBye;
|
||||
pub struct EmberBye;
|
||||
|
||||
impl BodyBye {
|
||||
pub fn owned() -> Body<'static> { Self.into() }
|
||||
impl EmberBye {
|
||||
pub fn owned() -> Ember<'static> { Self.into() }
|
||||
}
|
||||
|
||||
impl From<BodyBye> for Body<'_> {
|
||||
fn from(value: BodyBye) -> Self { Self::Bye(value) }
|
||||
impl From<EmberBye> for Ember<'_> {
|
||||
fn from(value: EmberBye) -> Self { Self::Bye(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyBye {
|
||||
impl IntoLua for EmberBye {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> {
|
||||
Err("BodyBye cannot be converted to Lua").into_lua_err()
|
||||
}
|
||||
|
|
@ -4,33 +4,33 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::{Id, url::Url};
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyCd<'a> {
|
||||
pub struct EmberCd<'a> {
|
||||
pub tab: Id,
|
||||
pub url: Cow<'a, Url>,
|
||||
#[serde(skip)]
|
||||
dummy: bool,
|
||||
}
|
||||
|
||||
impl<'a> BodyCd<'a> {
|
||||
pub fn borrowed(tab: Id, url: &'a Url) -> Body<'a> {
|
||||
impl<'a> EmberCd<'a> {
|
||||
pub fn borrowed(tab: Id, url: &'a Url) -> Ember<'a> {
|
||||
Self { tab, url: url.into(), dummy: false }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyCd<'static> {
|
||||
pub fn owned(tab: Id, _: &Url) -> Body<'static> {
|
||||
impl EmberCd<'static> {
|
||||
pub fn owned(tab: Id, _: &Url) -> Ember<'static> {
|
||||
Self { tab, url: Default::default(), dummy: true }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyCd<'a>> for Body<'a> {
|
||||
fn from(value: BodyCd<'a>) -> Self { Self::Cd(value) }
|
||||
impl<'a> From<EmberCd<'a>> for Ember<'a> {
|
||||
fn from(value: EmberCd<'a>) -> Self { Self::Cd(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyCd<'_> {
|
||||
impl IntoLua for EmberCd<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua
|
||||
.create_table_from([
|
||||
|
|
@ -2,34 +2,34 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::Serialize;
|
||||
use yazi_shared::event::Data;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
use crate::Sendable;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BodyCustom {
|
||||
pub struct EmberCustom {
|
||||
pub kind: String,
|
||||
pub data: Data,
|
||||
}
|
||||
|
||||
impl BodyCustom {
|
||||
pub fn from_str(kind: &str, data: &str) -> anyhow::Result<Body<'static>> {
|
||||
impl EmberCustom {
|
||||
pub fn from_str(kind: &str, data: &str) -> anyhow::Result<Ember<'static>> {
|
||||
Ok(Self { kind: kind.to_owned(), data: serde_json::from_str(data)? }.into())
|
||||
}
|
||||
|
||||
pub fn from_lua(lua: &Lua, kind: &str, data: Value) -> mlua::Result<Body<'static>> {
|
||||
pub fn from_lua(lua: &Lua, kind: &str, data: Value) -> mlua::Result<Ember<'static>> {
|
||||
Ok(Self { kind: kind.to_owned(), data: Sendable::value_to_data(lua, data)? }.into())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BodyCustom> for Body<'_> {
|
||||
fn from(value: BodyCustom) -> Self { Self::Custom(value) }
|
||||
impl From<EmberCustom> for Ember<'_> {
|
||||
fn from(value: EmberCustom) -> Self { Self::Custom(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyCustom {
|
||||
impl IntoLua for EmberCustom {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> { Sendable::data_to_value(lua, self.data) }
|
||||
}
|
||||
|
||||
impl Serialize for BodyCustom {
|
||||
impl Serialize for EmberCustom {
|
||||
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
serde::Serialize::serialize(&self.data, serializer)
|
||||
}
|
||||
33
yazi-dds/src/ember/delete.rs
Normal file
33
yazi-dds/src/ember/delete.rs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct EmberDelete<'a> {
|
||||
pub urls: Cow<'a, Vec<Url>>,
|
||||
}
|
||||
|
||||
impl<'a> EmberDelete<'a> {
|
||||
pub fn borrowed(urls: &'a Vec<Url>) -> Ember<'a> { Self { urls: Cow::Borrowed(urls) }.into() }
|
||||
}
|
||||
|
||||
impl EmberDelete<'static> {
|
||||
pub fn owned(urls: Vec<Url>) -> Ember<'static> { Self { urls: Cow::Owned(urls) }.into() }
|
||||
}
|
||||
|
||||
impl<'a> From<EmberDelete<'a>> for Ember<'a> {
|
||||
fn from(value: EmberDelete<'a>) -> Self { Self::Delete(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for EmberDelete<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
let urls =
|
||||
lua.create_sequence_from(self.urls.into_owned().into_iter().map(yazi_binding::Url::new))?;
|
||||
|
||||
lua.create_table_from([("urls", urls)])?.into_lua(lua)
|
||||
}
|
||||
}
|
||||
143
yazi-dds/src/ember/ember.rs
Normal file
143
yazi-dds/src/ember/ember.rs
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
use anyhow::{Result, bail};
|
||||
use mlua::{ExternalResult, IntoLua, Lua, Value};
|
||||
use yazi_shared::Id;
|
||||
|
||||
use super::{EmberBulk, EmberBye, EmberCd, EmberCustom, EmberDelete, EmberHey, EmberHi, EmberHover, EmberLoad, EmberMount, EmberMove, EmberRename, EmberTab, EmberTrash, EmberYank};
|
||||
use crate::Payload;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Ember<'a> {
|
||||
Hi(EmberHi<'a>),
|
||||
Hey(EmberHey),
|
||||
Bye(EmberBye),
|
||||
Tab(EmberTab),
|
||||
Cd(EmberCd<'a>),
|
||||
Load(EmberLoad<'a>),
|
||||
Hover(EmberHover<'a>),
|
||||
Rename(EmberRename<'a>),
|
||||
Bulk(EmberBulk<'a>),
|
||||
Yank(EmberYank<'a>),
|
||||
Move(EmberMove<'a>),
|
||||
Trash(EmberTrash<'a>),
|
||||
Delete(EmberDelete<'a>),
|
||||
Mount(EmberMount),
|
||||
Custom(EmberCustom),
|
||||
}
|
||||
|
||||
impl Ember<'static> {
|
||||
pub fn from_str(kind: &str, body: &str) -> Result<Self> {
|
||||
Ok(match kind {
|
||||
"hi" => Self::Hi(serde_json::from_str(body)?),
|
||||
"hey" => Self::Hey(serde_json::from_str(body)?),
|
||||
"bye" => Self::Bye(serde_json::from_str(body)?),
|
||||
"tab" => Self::Tab(serde_json::from_str(body)?),
|
||||
"cd" => Self::Cd(serde_json::from_str(body)?),
|
||||
"load" => Self::Load(serde_json::from_str(body)?),
|
||||
"hover" => Self::Hover(serde_json::from_str(body)?),
|
||||
"rename" => Self::Rename(serde_json::from_str(body)?),
|
||||
"bulk" => Self::Bulk(serde_json::from_str(body)?),
|
||||
"@yank" => Self::Yank(serde_json::from_str(body)?),
|
||||
"move" => Self::Move(serde_json::from_str(body)?),
|
||||
"trash" => Self::Trash(serde_json::from_str(body)?),
|
||||
"delete" => Self::Delete(serde_json::from_str(body)?),
|
||||
"mount" => Self::Mount(serde_json::from_str(body)?),
|
||||
_ => EmberCustom::from_str(kind, body)?,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn from_lua(lua: &Lua, kind: &str, value: Value) -> mlua::Result<Self> {
|
||||
Self::validate(kind).into_lua_err()?;
|
||||
EmberCustom::from_lua(lua, kind, value)
|
||||
}
|
||||
|
||||
pub fn validate(kind: &str) -> Result<()> {
|
||||
if matches!(
|
||||
kind,
|
||||
"hi"
|
||||
| "hey"
|
||||
| "bye"
|
||||
| "tab"
|
||||
| "cd"
|
||||
| "load"
|
||||
| "hover"
|
||||
| "rename"
|
||||
| "bulk"
|
||||
| "@yank"
|
||||
| "move"
|
||||
| "trash"
|
||||
| "delete"
|
||||
| "mount"
|
||||
) || kind.starts_with("emit-")
|
||||
|| kind.starts_with("emit-ind-")
|
||||
|| kind.starts_with("ind-")
|
||||
|| kind.starts_with("key-")
|
||||
|| kind.starts_with("relay-")
|
||||
|| kind.starts_with("relay-ind-")
|
||||
{
|
||||
bail!("Cannot construct system event");
|
||||
}
|
||||
|
||||
let mut it = kind.bytes().peekable();
|
||||
if it.peek() == Some(&b'@') {
|
||||
it.next(); // Skip `@` as it's a prefix for static messages
|
||||
}
|
||||
if !it.all(|b| b.is_ascii_alphanumeric() || b == b'-') {
|
||||
bail!("Kind must be alphanumeric with dashes");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Ember<'a> {
|
||||
#[inline]
|
||||
pub fn kind(&self) -> &str {
|
||||
match self {
|
||||
Self::Hi(_) => "hi",
|
||||
Self::Hey(_) => "hey",
|
||||
Self::Bye(_) => "bye",
|
||||
Self::Tab(_) => "tab",
|
||||
Self::Cd(_) => "cd",
|
||||
Self::Load(_) => "load",
|
||||
Self::Hover(_) => "hover",
|
||||
Self::Rename(_) => "rename",
|
||||
Self::Bulk(_) => "bulk",
|
||||
Self::Yank(_) => "@yank",
|
||||
Self::Move(_) => "move",
|
||||
Self::Trash(_) => "trash",
|
||||
Self::Delete(_) => "delete",
|
||||
Self::Mount(_) => "mount",
|
||||
Self::Custom(b) => b.kind.as_str(),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_receiver(self, receiver: Id) -> Payload<'a> {
|
||||
Payload::new(self).with_receiver(receiver)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn with_sender(self, sender: Id) -> Payload<'a> { Payload::new(self).with_sender(sender) }
|
||||
}
|
||||
|
||||
impl<'a> IntoLua for Ember<'a> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
match self {
|
||||
Self::Hi(b) => b.into_lua(lua),
|
||||
Self::Hey(b) => b.into_lua(lua),
|
||||
Self::Bye(b) => b.into_lua(lua),
|
||||
Self::Cd(b) => b.into_lua(lua),
|
||||
Self::Load(b) => b.into_lua(lua),
|
||||
Self::Hover(b) => b.into_lua(lua),
|
||||
Self::Tab(b) => b.into_lua(lua),
|
||||
Self::Rename(b) => b.into_lua(lua),
|
||||
Self::Bulk(b) => b.into_lua(lua),
|
||||
Self::Yank(b) => b.into_lua(lua),
|
||||
Self::Move(b) => b.into_lua(lua),
|
||||
Self::Trash(b) => b.into_lua(lua),
|
||||
Self::Delete(b) => b.into_lua(lua),
|
||||
Self::Mount(b) => b.into_lua(lua),
|
||||
Self::Custom(b) => b.into_lua(lua),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,27 +4,27 @@ use mlua::{ExternalResult, IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::{Id, SStr};
|
||||
|
||||
use super::{Body, BodyHi};
|
||||
use super::{Ember, EmberHi};
|
||||
use crate::Peer;
|
||||
|
||||
/// Server handshake
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyHey {
|
||||
pub struct EmberHey {
|
||||
pub peers: HashMap<Id, Peer>,
|
||||
pub version: SStr,
|
||||
}
|
||||
|
||||
impl BodyHey {
|
||||
pub fn owned(peers: HashMap<Id, Peer>) -> Body<'static> {
|
||||
Self { peers, version: BodyHi::version().into() }.into()
|
||||
impl EmberHey {
|
||||
pub fn owned(peers: HashMap<Id, Peer>) -> Ember<'static> {
|
||||
Self { peers, version: EmberHi::version().into() }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BodyHey> for Body<'_> {
|
||||
fn from(value: BodyHey) -> Self { Self::Hey(value) }
|
||||
impl From<EmberHey> for Ember<'_> {
|
||||
fn from(value: EmberHey) -> Self { Self::Hey(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyHey {
|
||||
impl IntoLua for EmberHey {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> {
|
||||
Err("BodyHey cannot be converted to Lua").into_lua_err()
|
||||
}
|
||||
|
|
@ -4,18 +4,18 @@ use mlua::{ExternalResult, IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::SStr;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
/// Client handshake
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyHi<'a> {
|
||||
pub struct EmberHi<'a> {
|
||||
/// Kinds of events the client can handle
|
||||
pub abilities: HashSet<Cow<'a, str>>,
|
||||
pub version: SStr,
|
||||
}
|
||||
|
||||
impl<'a> BodyHi<'a> {
|
||||
pub fn borrowed<I>(abilities: I) -> Body<'a>
|
||||
impl<'a> EmberHi<'a> {
|
||||
pub fn borrowed<I>(abilities: I) -> Ember<'a>
|
||||
where
|
||||
I: Iterator<Item = &'a str>,
|
||||
{
|
||||
|
|
@ -27,11 +27,11 @@ impl<'a> BodyHi<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyHi<'a>> for Body<'a> {
|
||||
fn from(value: BodyHi<'a>) -> Self { Self::Hi(value) }
|
||||
impl<'a> From<EmberHi<'a>> for Ember<'a> {
|
||||
fn from(value: EmberHi<'a>) -> Self { Self::Hi(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyHi<'_> {
|
||||
impl IntoLua for EmberHi<'_> {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> {
|
||||
Err("BodyHi cannot be converted to Lua").into_lua_err()
|
||||
}
|
||||
|
|
@ -4,29 +4,29 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::{Id, url::Url};
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyHover<'a> {
|
||||
pub struct EmberHover<'a> {
|
||||
pub tab: Id,
|
||||
pub url: Option<Cow<'a, Url>>,
|
||||
}
|
||||
|
||||
impl<'a> BodyHover<'a> {
|
||||
pub fn borrowed(tab: Id, url: Option<&'a Url>) -> Body<'a> {
|
||||
impl<'a> EmberHover<'a> {
|
||||
pub fn borrowed(tab: Id, url: Option<&'a Url>) -> Ember<'a> {
|
||||
Self { tab, url: url.map(Into::into) }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyHover<'static> {
|
||||
pub fn owned(tab: Id, _: Option<&Url>) -> Body<'static> { Self { tab, url: None }.into() }
|
||||
impl EmberHover<'static> {
|
||||
pub fn owned(tab: Id, _: Option<&Url>) -> Ember<'static> { Self { tab, url: None }.into() }
|
||||
}
|
||||
|
||||
impl<'a> From<BodyHover<'a>> for Body<'a> {
|
||||
fn from(value: BodyHover<'a>) -> Self { Self::Hover(value) }
|
||||
impl<'a> From<EmberHover<'a>> for Ember<'a> {
|
||||
fn from(value: EmberHover<'a>) -> Self { Self::Hover(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyHover<'_> {
|
||||
impl IntoLua for EmberHover<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua
|
||||
.create_table_from([
|
||||
|
|
@ -5,32 +5,32 @@ use serde::{Deserialize, Serialize};
|
|||
use yazi_fs::FolderStage;
|
||||
use yazi_shared::{Id, url::Url};
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyLoad<'a> {
|
||||
pub struct EmberLoad<'a> {
|
||||
pub tab: Id,
|
||||
pub url: Cow<'a, Url>,
|
||||
pub stage: FolderStage,
|
||||
}
|
||||
|
||||
impl<'a> BodyLoad<'a> {
|
||||
pub fn borrowed(tab: Id, url: &'a Url, stage: FolderStage) -> Body<'a> {
|
||||
impl<'a> EmberLoad<'a> {
|
||||
pub fn borrowed(tab: Id, url: &'a Url, stage: FolderStage) -> Ember<'a> {
|
||||
Self { tab, url: url.into(), stage }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyLoad<'static> {
|
||||
pub fn owned(tab: Id, url: &Url, stage: FolderStage) -> Body<'static> {
|
||||
impl EmberLoad<'static> {
|
||||
pub fn owned(tab: Id, url: &Url, stage: FolderStage) -> Ember<'static> {
|
||||
Self { tab, url: url.clone().into(), stage }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyLoad<'a>> for Body<'a> {
|
||||
fn from(value: BodyLoad<'a>) -> Self { Self::Load(value) }
|
||||
impl<'a> From<EmberLoad<'a>> for Ember<'a> {
|
||||
fn from(value: EmberLoad<'a>) -> Self { Self::Load(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyLoad<'_> {
|
||||
impl IntoLua for EmberLoad<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua
|
||||
.create_table_from([
|
||||
5
yazi-dds/src/ember/mod.rs
Normal file
5
yazi-dds/src/ember/mod.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#![allow(clippy::module_inception)]
|
||||
|
||||
yazi_macro::mod_flat!(
|
||||
bulk bye cd custom delete ember hey hi hover load mount r#move rename tab trash yank
|
||||
);
|
||||
21
yazi-dds/src/ember/mount.rs
Normal file
21
yazi-dds/src/ember/mount.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct EmberMount;
|
||||
|
||||
impl EmberMount {
|
||||
pub fn owned() -> Ember<'static> { Self.into() }
|
||||
|
||||
pub fn borrowed() -> Ember<'static> { Self::owned() }
|
||||
}
|
||||
|
||||
impl From<EmberMount> for Ember<'_> {
|
||||
fn from(value: EmberMount) -> Self { Self::Mount(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for EmberMount {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Ok(Value::Nil) }
|
||||
}
|
||||
|
|
@ -4,30 +4,30 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyMove<'a> {
|
||||
pub struct EmberMove<'a> {
|
||||
pub items: Cow<'a, Vec<BodyMoveItem>>,
|
||||
}
|
||||
|
||||
impl<'a> BodyMove<'a> {
|
||||
pub fn borrowed(items: &'a Vec<BodyMoveItem>) -> Body<'a> {
|
||||
impl<'a> EmberMove<'a> {
|
||||
pub fn borrowed(items: &'a Vec<BodyMoveItem>) -> Ember<'a> {
|
||||
Self { items: Cow::Borrowed(items) }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyMove<'static> {
|
||||
pub fn owned(items: Vec<BodyMoveItem>) -> Body<'static> {
|
||||
impl EmberMove<'static> {
|
||||
pub fn owned(items: Vec<BodyMoveItem>) -> Ember<'static> {
|
||||
Self { items: Cow::Owned(items) }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyMove<'a>> for Body<'a> {
|
||||
fn from(value: BodyMove<'a>) -> Self { Self::Move(value) }
|
||||
impl<'a> From<EmberMove<'a>> for Ember<'a> {
|
||||
fn from(value: EmberMove<'a>) -> Self { Self::Move(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyMove<'_> {
|
||||
impl IntoLua for EmberMove<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua.create_table_from([("items", self.items.into_owned())])?.into_lua(lua)
|
||||
}
|
||||
|
|
@ -4,32 +4,32 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::{Id, url::Url};
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyRename<'a> {
|
||||
pub struct EmberRename<'a> {
|
||||
pub tab: Id,
|
||||
pub from: Cow<'a, Url>,
|
||||
pub to: Cow<'a, Url>,
|
||||
}
|
||||
|
||||
impl<'a> BodyRename<'a> {
|
||||
pub fn borrowed(tab: Id, from: &'a Url, to: &'a Url) -> Body<'a> {
|
||||
impl<'a> EmberRename<'a> {
|
||||
pub fn borrowed(tab: Id, from: &'a Url, to: &'a Url) -> Ember<'a> {
|
||||
Self { tab, from: from.into(), to: to.into() }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyRename<'static> {
|
||||
pub fn owned(tab: Id, from: &Url, to: &Url) -> Body<'static> {
|
||||
impl EmberRename<'static> {
|
||||
pub fn owned(tab: Id, from: &Url, to: &Url) -> Ember<'static> {
|
||||
Self { tab, from: from.clone().into(), to: to.clone().into() }.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyRename<'a>> for Body<'a> {
|
||||
fn from(value: BodyRename<'a>) -> Self { Self::Rename(value) }
|
||||
impl<'a> From<EmberRename<'a>> for Ember<'a> {
|
||||
fn from(value: EmberRename<'a>) -> Self { Self::Rename(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyRename<'_> {
|
||||
impl IntoLua for EmberRename<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua
|
||||
.create_table_from([
|
||||
26
yazi-dds/src/ember/tab.rs
Normal file
26
yazi-dds/src/ember/tab.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use mlua::{IntoLua, Lua, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::Id;
|
||||
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct EmberTab {
|
||||
pub id: Id,
|
||||
}
|
||||
|
||||
impl EmberTab {
|
||||
pub fn owned(id: Id) -> Ember<'static> { Self { id }.into() }
|
||||
|
||||
pub fn borrowed(id: Id) -> Ember<'static> { Self::owned(id) }
|
||||
}
|
||||
|
||||
impl From<EmberTab> for Ember<'_> {
|
||||
fn from(value: EmberTab) -> Self { Self::Tab(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for EmberTab {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
lua.create_table_from([("idx", self.id.get())])?.into_lua(lua)
|
||||
}
|
||||
}
|
||||
|
|
@ -4,26 +4,26 @@ use mlua::{IntoLua, Lua, Value};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::url::Url;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyTrash<'a> {
|
||||
pub struct EmberTrash<'a> {
|
||||
pub urls: Cow<'a, Vec<Url>>,
|
||||
}
|
||||
|
||||
impl<'a> BodyTrash<'a> {
|
||||
pub fn borrowed(urls: &'a Vec<Url>) -> Body<'a> { Self { urls: Cow::Borrowed(urls) }.into() }
|
||||
impl<'a> EmberTrash<'a> {
|
||||
pub fn borrowed(urls: &'a Vec<Url>) -> Ember<'a> { Self { urls: Cow::Borrowed(urls) }.into() }
|
||||
}
|
||||
|
||||
impl BodyTrash<'static> {
|
||||
pub fn owned(urls: Vec<Url>) -> Body<'static> { Self { urls: Cow::Owned(urls) }.into() }
|
||||
impl EmberTrash<'static> {
|
||||
pub fn owned(urls: Vec<Url>) -> Ember<'static> { Self { urls: Cow::Owned(urls) }.into() }
|
||||
}
|
||||
|
||||
impl<'a> From<BodyTrash<'a>> for Body<'a> {
|
||||
fn from(value: BodyTrash<'a>) -> Self { Self::Trash(value) }
|
||||
impl<'a> From<EmberTrash<'a>> for Ember<'a> {
|
||||
fn from(value: EmberTrash<'a>) -> Self { Self::Trash(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyTrash<'_> {
|
||||
impl IntoLua for EmberTrash<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
let urls =
|
||||
lua.create_sequence_from(self.urls.into_owned().into_iter().map(yazi_binding::Url::new))?;
|
||||
|
|
@ -5,27 +5,27 @@ use serde::{Deserialize, Serialize};
|
|||
use yazi_parser::mgr::UpdateYankedOpt;
|
||||
use yazi_shared::url::CovUrl;
|
||||
|
||||
use super::Body;
|
||||
use super::Ember;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct BodyYank<'a>(UpdateYankedOpt<'a>);
|
||||
pub struct EmberYank<'a>(UpdateYankedOpt<'a>);
|
||||
|
||||
impl<'a> BodyYank<'a> {
|
||||
pub fn borrowed(cut: bool, urls: &'a HashSet<CovUrl>) -> Body<'a> {
|
||||
impl<'a> EmberYank<'a> {
|
||||
pub fn borrowed(cut: bool, urls: &'a HashSet<CovUrl>) -> Ember<'a> {
|
||||
Self(UpdateYankedOpt { cut, urls: Cow::Borrowed(urls) }).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl BodyYank<'static> {
|
||||
pub fn owned(cut: bool, _: &HashSet<CovUrl>) -> Body<'static> {
|
||||
impl EmberYank<'static> {
|
||||
pub fn owned(cut: bool, _: &HashSet<CovUrl>) -> Ember<'static> {
|
||||
Self(UpdateYankedOpt { cut, urls: Default::default() }).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<BodyYank<'a>> for Body<'a> {
|
||||
fn from(value: BodyYank<'a>) -> Self { Self::Yank(value) }
|
||||
impl<'a> From<EmberYank<'a>> for Ember<'a> {
|
||||
fn from(value: EmberYank<'a>) -> Self { Self::Yank(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for BodyYank<'_> {
|
||||
impl IntoLua for EmberYank<'_> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> { self.0.into_lua(lua) }
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
mod macros;
|
||||
|
||||
yazi_macro::mod_pub!(body);
|
||||
yazi_macro::mod_pub!(ember spark);
|
||||
|
||||
yazi_macro::mod_flat!(client payload pubsub pump sendable server state stream);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,38 @@
|
|||
#[macro_export]
|
||||
macro_rules! body {
|
||||
macro_rules! spark {
|
||||
(mgr: $name:ident, $body:expr) => {
|
||||
paste::paste! {
|
||||
$crate::body::Body::[<Key $name:camel>]($body)
|
||||
$crate::spark::Spark::[<$name:camel>]($body)
|
||||
}
|
||||
};
|
||||
($layer:ident : $name:ident, $body:expr) => {
|
||||
$crate::body::Body::Void(&yazi_parser::VoidOpt)
|
||||
$crate::spark::Spark::Void(yazi_parser::VoidOpt)
|
||||
// paste::paste! {
|
||||
// $crate::body::Body::[<Key $layer:camel $name:camel>]($body)
|
||||
// }
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! try_from_spark {
|
||||
($opt:ty, $($($layer:ident)? : $name:ident),+) => {
|
||||
impl<'a> std::convert::TryFrom<$crate::spark::Spark<'a>> for paste::paste! { yazi_parser::$opt } {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: $crate::spark::Spark<'a>) -> Result<Self, Self::Error> {
|
||||
$(
|
||||
try_from_spark!(@if $($layer)? : $name, value);
|
||||
)+
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
};
|
||||
(@if mgr : $name:ident, $value:ident) => {
|
||||
try_from_spark!(@if : $name, $value);
|
||||
};
|
||||
(@if $($layer:ident)? : $name:ident, $value:ident) => {
|
||||
if let paste::paste! { $crate::spark::Spark::[<$($layer:camel)* $name:camel>](opt) } = $value {
|
||||
return Ok(<_>::from(opt))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,17 @@ use yazi_boot::BOOT;
|
|||
use yazi_macro::{emit, relay};
|
||||
use yazi_shared::Id;
|
||||
|
||||
use crate::{ID, body::Body};
|
||||
use crate::{ID, ember::Ember};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Payload<'a> {
|
||||
pub receiver: Id,
|
||||
pub sender: Id,
|
||||
pub body: Body<'a>,
|
||||
pub body: Ember<'a>,
|
||||
}
|
||||
|
||||
impl<'a> Payload<'a> {
|
||||
pub(super) fn new(body: Body<'a>) -> Self { Self { receiver: Id(0), sender: *ID, body } }
|
||||
pub(super) fn new(body: Ember<'a>) -> Self { Self { receiver: Id(0), sender: *ID, body } }
|
||||
|
||||
pub(super) fn flush(&self) -> Result<()> {
|
||||
writeln!(std::io::stdout(), "{self}")?;
|
||||
|
|
@ -25,7 +25,7 @@ impl<'a> Payload<'a> {
|
|||
pub(super) fn try_flush(&self) -> Result<()> {
|
||||
let b = if self.receiver == 0 {
|
||||
BOOT.remote_events.contains(self.body.kind())
|
||||
} else if let Body::Custom(b) = &self.body {
|
||||
} else if let Ember::Custom(b) = &self.body {
|
||||
BOOT.local_events.contains(&b.kind)
|
||||
} else {
|
||||
false
|
||||
|
|
@ -68,33 +68,32 @@ impl FromStr for Payload<'static> {
|
|||
|
||||
let body = parts.next().ok_or_else(|| anyhow!("empty body"))?;
|
||||
|
||||
Ok(Self { receiver, sender, body: Body::from_str(kind, body)? })
|
||||
Ok(Self { receiver, sender, body: Ember::from_str(kind, body)? })
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<Body<'a>> for Payload<'a> {
|
||||
fn from(value: Body<'a>) -> Self { Self::new(value) }
|
||||
impl<'a> From<Ember<'a>> for Payload<'a> {
|
||||
fn from(value: Ember<'a>) -> Self { Self::new(value) }
|
||||
}
|
||||
|
||||
impl Display for Payload<'_> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let result = match &self.body {
|
||||
Body::Hi(b) => serde_json::to_string(b),
|
||||
Body::Hey(b) => serde_json::to_string(b),
|
||||
Body::Bye(b) => serde_json::to_string(b),
|
||||
Body::Cd(b) => serde_json::to_string(b),
|
||||
Body::Load(b) => serde_json::to_string(b),
|
||||
Body::Hover(b) => serde_json::to_string(b),
|
||||
Body::Tab(b) => serde_json::to_string(b),
|
||||
Body::Rename(b) => serde_json::to_string(b),
|
||||
Body::Bulk(b) => serde_json::to_string(b),
|
||||
Body::Yank(b) => serde_json::to_string(b),
|
||||
Body::Move(b) => serde_json::to_string(b),
|
||||
Body::Trash(b) => serde_json::to_string(b),
|
||||
Body::Delete(b) => serde_json::to_string(b),
|
||||
Body::Mount(b) => serde_json::to_string(b),
|
||||
Body::Custom(b) => serde_json::to_string(b),
|
||||
_ => return Err(std::fmt::Error),
|
||||
Ember::Hi(b) => serde_json::to_string(b),
|
||||
Ember::Hey(b) => serde_json::to_string(b),
|
||||
Ember::Bye(b) => serde_json::to_string(b),
|
||||
Ember::Cd(b) => serde_json::to_string(b),
|
||||
Ember::Load(b) => serde_json::to_string(b),
|
||||
Ember::Hover(b) => serde_json::to_string(b),
|
||||
Ember::Tab(b) => serde_json::to_string(b),
|
||||
Ember::Rename(b) => serde_json::to_string(b),
|
||||
Ember::Bulk(b) => serde_json::to_string(b),
|
||||
Ember::Yank(b) => serde_json::to_string(b),
|
||||
Ember::Move(b) => serde_json::to_string(b),
|
||||
Ember::Trash(b) => serde_json::to_string(b),
|
||||
Ember::Delete(b) => serde_json::to_string(b),
|
||||
Ember::Mount(b) => serde_json::to_string(b),
|
||||
Ember::Custom(b) => serde_json::to_string(b),
|
||||
};
|
||||
|
||||
if let Ok(s) = result {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use yazi_boot::BOOT;
|
|||
use yazi_fs::FolderStage;
|
||||
use yazi_shared::{Id, RoCell, url::{CovUrl, Url}};
|
||||
|
||||
use crate::{Client, ID, PEERS, body::{Body, BodyBulk, BodyHi, BodyMoveItem}};
|
||||
use crate::{Client, ID, PEERS, ember::{BodyMoveItem, Ember, EmberBulk, EmberHi}};
|
||||
|
||||
pub static LOCAL: RoCell<RwLock<HashMap<String, HashMap<String, Function>>>> = RoCell::new();
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ macro_rules! pub_after {
|
|||
(&impl $name:ident ($($param:ident: $param_ty:ty),*), ($($borrowed:expr),*), ($($owned:expr),*), $static:literal) => {
|
||||
paste::paste! {
|
||||
pub fn [<pub_after_ $name>]($($param: $param_ty),*) -> Result<()> {
|
||||
use crate::body::[<Body $name:camel>] as B;
|
||||
use crate::ember::[<Ember $name:camel>] as B;
|
||||
|
||||
let n = if $static { concat!("@", stringify!($name)) } else { stringify!($name) };
|
||||
if BOOT.local_events.contains(n) {
|
||||
|
|
@ -97,9 +97,9 @@ impl Pubsub {
|
|||
unsub!(REMOTE)(plugin, kind) && Self::pub_inner_hi()
|
||||
}
|
||||
|
||||
pub fn r#pub(body: Body<'static>) -> Result<()> { body.with_receiver(*ID).emit() }
|
||||
pub fn r#pub(body: Ember<'static>) -> Result<()> { body.with_receiver(*ID).emit() }
|
||||
|
||||
pub fn pub_to(receiver: Id, body: Body<'static>) -> Result<()> {
|
||||
pub fn pub_to(receiver: Id, body: Ember<'static>) -> Result<()> {
|
||||
if receiver == *ID {
|
||||
return Self::r#pub(body);
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ impl Pubsub {
|
|||
let abilities = BOOT.remote_events.union(&abilities).map(AsRef::as_ref);
|
||||
|
||||
// FIXME: handle error
|
||||
Client::push(BodyHi::borrowed(abilities)).ok();
|
||||
Client::push(EmberHi::borrowed(abilities)).ok();
|
||||
true
|
||||
}
|
||||
|
||||
|
|
@ -127,13 +127,13 @@ impl Pubsub {
|
|||
I: Iterator<Item = (&'a Url, &'a Url)> + Clone,
|
||||
{
|
||||
if BOOT.local_events.contains("bulk") {
|
||||
BodyBulk::borrowed(changes.clone()).with_receiver(*ID).flush()?;
|
||||
EmberBulk::borrowed(changes.clone()).with_receiver(*ID).flush()?;
|
||||
}
|
||||
if PEERS.read().values().any(|p| p.able("bulk")) {
|
||||
Client::push(BodyBulk::borrowed(changes.clone()))?;
|
||||
Client::push(EmberBulk::borrowed(changes.clone()))?;
|
||||
}
|
||||
if LOCAL.read().contains_key("bulk") {
|
||||
Self::r#pub(BodyBulk::owned(changes))?;
|
||||
Self::r#pub(EmberBulk::owned(changes))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use tokio_util::sync::CancellationToken;
|
|||
use yazi_macro::err;
|
||||
use yazi_shared::{RoCell, url::Url};
|
||||
|
||||
use crate::{Pubsub, body::BodyMoveItem};
|
||||
use crate::{Pubsub, ember::BodyMoveItem};
|
||||
|
||||
static CT: RoCell<CancellationToken> = RoCell::new();
|
||||
static MOVE_TX: Mutex<Option<mpsc::UnboundedSender<BodyMoveItem>>> = Mutex::new(None);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use tokio::{io::{AsyncBufReadExt, AsyncWriteExt, BufReader}, select, sync::mpsc:
|
|||
use yazi_macro::try_format;
|
||||
use yazi_shared::{Id, RoCell};
|
||||
|
||||
use crate::{Client, ClientWriter, Payload, Peer, STATE, Stream, body::{Body, BodyBye, BodyHey}};
|
||||
use crate::{Client, ClientWriter, Payload, Peer, STATE, Stream, ember::{Ember, EmberBye, EmberHey}};
|
||||
|
||||
pub(super) static CLIENTS: RoCell<RwLock<HashMap<Id, Client>>> = RoCell::new();
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ impl Server {
|
|||
|
||||
fn handle_hi(s: String, id: &mut Option<Id>, tx: mpsc::UnboundedSender<String>) {
|
||||
let Ok(payload) = Payload::from_str(&s) else { return };
|
||||
let Body::Hi(hi) = payload.body else { return };
|
||||
let Ember::Hi(hi) = payload.body else { return };
|
||||
|
||||
if id.is_none()
|
||||
&& let Some(ref state) = *STATE.read()
|
||||
|
|
@ -110,7 +110,7 @@ impl Server {
|
|||
}
|
||||
|
||||
fn handle_hey(clients: &HashMap<Id, Client>) {
|
||||
let payload = Payload::new(BodyHey::owned(
|
||||
let payload = Payload::new(EmberHey::owned(
|
||||
clients.values().map(|c| (c.id, Peer::new(&c.abilities))).collect(),
|
||||
));
|
||||
if let Ok(s) = try_format!("{payload}\n") {
|
||||
|
|
@ -125,7 +125,7 @@ impl Server {
|
|||
}
|
||||
}
|
||||
|
||||
let bye = BodyBye::owned().with_receiver(id).with_sender(Id(0));
|
||||
let bye = EmberBye::owned().with_receiver(id).with_sender(Id(0));
|
||||
if let Ok(s) = try_format!("{bye}") {
|
||||
writer.write_all(s.as_bytes()).await.ok();
|
||||
writer.flush().await.ok();
|
||||
|
|
|
|||
18
yazi-dds/src/spark/kind.rs
Normal file
18
yazi-dds/src/spark/kind.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum SparkKind {
|
||||
KeyQuit,
|
||||
}
|
||||
|
||||
impl AsRef<str> for SparkKind {
|
||||
fn as_ref(&self) -> &str {
|
||||
match self {
|
||||
Self::KeyQuit => "key-quit",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for SparkKind {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_str(self.as_ref()) }
|
||||
}
|
||||
1
yazi-dds/src/spark/mod.rs
Normal file
1
yazi-dds/src/spark/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
yazi_macro::mod_flat!(kind spark);
|
||||
330
yazi-dds/src/spark/spark.rs
Normal file
330
yazi-dds/src/spark/spark.rs
Normal file
|
|
@ -0,0 +1,330 @@
|
|||
use mlua::{FromLua, IntoLua, Lua, Value};
|
||||
|
||||
use crate::{spark::SparkKind, try_from_spark};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Spark<'a> {
|
||||
// Void
|
||||
Void(yazi_parser::VoidOpt),
|
||||
|
||||
// Mgr
|
||||
Arrow(yazi_parser::ArrowOpt),
|
||||
Back(yazi_parser::VoidOpt),
|
||||
BulkRename(yazi_parser::VoidOpt),
|
||||
Cd(yazi_parser::mgr::CdOpt),
|
||||
Close(yazi_parser::mgr::CloseOpt),
|
||||
Copy(yazi_parser::mgr::CopyOpt),
|
||||
Create(yazi_parser::mgr::CreateOpt),
|
||||
Enter(yazi_parser::VoidOpt),
|
||||
Escape(yazi_parser::mgr::EscapeOpt),
|
||||
EscapeFilter(yazi_parser::VoidOpt),
|
||||
EscapeFind(yazi_parser::VoidOpt),
|
||||
EscapeSearch(yazi_parser::VoidOpt),
|
||||
EscapeSelect(yazi_parser::VoidOpt),
|
||||
EscapeVisual(yazi_parser::VoidOpt),
|
||||
Filter(yazi_parser::mgr::FilterOpt),
|
||||
FilterDo(yazi_parser::mgr::FilterOpt),
|
||||
Find(yazi_parser::mgr::FindOpt),
|
||||
FindArrow(yazi_parser::mgr::FindArrowOpt),
|
||||
FindDo(yazi_parser::mgr::FindDoOpt),
|
||||
Follow(yazi_parser::VoidOpt),
|
||||
Forward(yazi_parser::VoidOpt),
|
||||
Hardlink(yazi_parser::mgr::HardlinkOpt),
|
||||
Hidden(yazi_parser::mgr::HiddenOpt),
|
||||
Hover(yazi_parser::mgr::HoverOpt),
|
||||
HoverDo(yazi_parser::mgr::HoverDoOpt),
|
||||
Leave(yazi_parser::VoidOpt),
|
||||
Linemode(yazi_parser::mgr::LinemodeOpt),
|
||||
Link(yazi_parser::mgr::LinkOpt),
|
||||
Open(yazi_parser::mgr::OpenOpt),
|
||||
OpenWith(yazi_parser::mgr::OpenWithOpt),
|
||||
OpenDo(yazi_parser::mgr::OpenDoOpt),
|
||||
Paste(yazi_parser::mgr::PasteOpt),
|
||||
Peek(yazi_parser::mgr::PeekOpt),
|
||||
Quit(yazi_parser::mgr::QuitOpt),
|
||||
Refresh(yazi_parser::VoidOpt),
|
||||
Remove(yazi_parser::mgr::RemoveOpt),
|
||||
RemoveDo(yazi_parser::mgr::RemoveOpt),
|
||||
Rename(yazi_parser::mgr::RenameOpt),
|
||||
Reveal(yazi_parser::mgr::RevealOpt),
|
||||
Search(yazi_parser::mgr::SearchOpt),
|
||||
SearchDo(yazi_parser::mgr::SearchOpt),
|
||||
SearchStop(yazi_parser::VoidOpt),
|
||||
Seek(yazi_parser::mgr::SeekOpt),
|
||||
Shell(yazi_parser::mgr::ShellOpt),
|
||||
Sort(yazi_parser::mgr::SortOpt),
|
||||
Spot(yazi_parser::mgr::SpotOpt),
|
||||
Suspend(yazi_parser::VoidOpt),
|
||||
TabClose(yazi_parser::mgr::TabCloseOpt),
|
||||
TabCreate(yazi_parser::mgr::TabCreateOpt),
|
||||
TabSwap(yazi_parser::ArrowOpt),
|
||||
TabSwitch(yazi_parser::mgr::TabSwitchOpt),
|
||||
Toggle(yazi_parser::mgr::ToggleOpt),
|
||||
ToggleAll(yazi_parser::mgr::ToggleAllOpt),
|
||||
Unyank(yazi_parser::VoidOpt),
|
||||
UpdateFiles(yazi_parser::mgr::UpdateFilesOpt),
|
||||
UpdateMimes(yazi_parser::mgr::UpdateMimesOpt),
|
||||
UpdatePaged(yazi_parser::mgr::UpdatePagedOpt),
|
||||
UpdatePeeked(yazi_parser::mgr::UpdatePeekedOpt),
|
||||
UpdateSpotted(yazi_parser::mgr::UpdateSpottedOpt),
|
||||
UpdateTasks(yazi_parser::mgr::UpdateTasksOpt),
|
||||
UpdateYanked(yazi_parser::mgr::UpdateYankedOpt<'a>),
|
||||
VisualMode(yazi_parser::mgr::VisualModeOpt),
|
||||
Watch(yazi_parser::VoidOpt),
|
||||
Yank(yazi_parser::mgr::YankOpt),
|
||||
|
||||
// Cmp
|
||||
CmpClose(yazi_parser::cmp::CloseOpt),
|
||||
CmpShow(yazi_parser::cmp::ShowOpt),
|
||||
CmpTrigger(yazi_parser::cmp::TriggerOpt),
|
||||
|
||||
// Confirm
|
||||
ConfirmClose(yazi_parser::confirm::CloseOpt),
|
||||
ConfirmShow(Box<yazi_parser::confirm::ShowOpt>),
|
||||
|
||||
// Help
|
||||
HelpToggle(yazi_parser::help::ToggleOpt),
|
||||
|
||||
// Input
|
||||
InputBackspace(yazi_parser::input::BackspaceOpt),
|
||||
InputBackward(yazi_parser::input::BackwardOpt),
|
||||
InputClose(yazi_parser::input::CloseOpt),
|
||||
InputComplete(yazi_parser::input::CompleteOpt),
|
||||
InputDelete(yazi_parser::input::DeleteOpt),
|
||||
InputForward(yazi_parser::input::ForwardOpt),
|
||||
InputInsert(yazi_parser::input::InsertOpt),
|
||||
InputKill(yazi_parser::input::KillOpt),
|
||||
InputMove(yazi_parser::input::MoveOpt),
|
||||
InputPaste(yazi_parser::input::PasteOpt),
|
||||
InputShow(yazi_parser::input::ShowOpt),
|
||||
|
||||
// Notify
|
||||
NotifyTick(yazi_parser::notify::TickOpt),
|
||||
|
||||
// Pick
|
||||
PickClose(yazi_parser::pick::CloseOpt),
|
||||
PickShow(yazi_parser::pick::ShowOpt),
|
||||
|
||||
// Spot
|
||||
SpotCopy(yazi_parser::spot::CopyOpt),
|
||||
|
||||
// Tasks
|
||||
TasksProcessExec(yazi_parser::tasks::ProcessExecOpt),
|
||||
|
||||
// Which
|
||||
WhichCallback(yazi_parser::which::CallbackOpt),
|
||||
WhichShow(yazi_parser::which::ShowOpt),
|
||||
}
|
||||
|
||||
impl<'a> Spark<'a> {
|
||||
pub fn from_lua(lua: &Lua, kind: SparkKind, value: Value) -> mlua::Result<Self> {
|
||||
Ok(match kind {
|
||||
SparkKind::KeyQuit => Self::Quit(<_>::from_lua(value, lua)?),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoLua for Spark<'a> {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
||||
match self {
|
||||
// Void
|
||||
Self::Void(b) => b.into_lua(lua),
|
||||
|
||||
// Mgr
|
||||
Self::Arrow(b) => b.into_lua(lua),
|
||||
Self::Back(b) => b.into_lua(lua),
|
||||
Self::BulkRename(b) => b.into_lua(lua),
|
||||
Self::Cd(b) => b.into_lua(lua),
|
||||
Self::Close(b) => b.into_lua(lua),
|
||||
Self::Copy(b) => b.into_lua(lua),
|
||||
Self::Create(b) => b.into_lua(lua),
|
||||
Self::Enter(b) => b.into_lua(lua),
|
||||
Self::Escape(b) => b.into_lua(lua),
|
||||
Self::EscapeFilter(b) => b.into_lua(lua),
|
||||
Self::EscapeFind(b) => b.into_lua(lua),
|
||||
Self::EscapeSearch(b) => b.into_lua(lua),
|
||||
Self::EscapeSelect(b) => b.into_lua(lua),
|
||||
Self::EscapeVisual(b) => b.into_lua(lua),
|
||||
Self::Filter(b) => b.into_lua(lua),
|
||||
Self::FilterDo(b) => b.into_lua(lua),
|
||||
Self::Find(b) => b.into_lua(lua),
|
||||
Self::FindArrow(b) => b.into_lua(lua),
|
||||
Self::FindDo(b) => b.into_lua(lua),
|
||||
Self::Follow(b) => b.into_lua(lua),
|
||||
Self::Forward(b) => b.into_lua(lua),
|
||||
Self::Hardlink(b) => b.into_lua(lua),
|
||||
Self::Hidden(b) => b.into_lua(lua),
|
||||
Self::Hover(b) => b.into_lua(lua),
|
||||
Self::HoverDo(b) => b.into_lua(lua),
|
||||
Self::Leave(b) => b.into_lua(lua),
|
||||
Self::Linemode(b) => b.into_lua(lua),
|
||||
Self::Link(b) => b.into_lua(lua),
|
||||
Self::Open(b) => b.into_lua(lua),
|
||||
Self::OpenWith(b) => b.into_lua(lua),
|
||||
Self::OpenDo(b) => b.into_lua(lua),
|
||||
Self::Paste(b) => b.into_lua(lua),
|
||||
Self::Peek(b) => b.into_lua(lua),
|
||||
Self::Quit(b) => b.into_lua(lua),
|
||||
Self::Refresh(b) => b.into_lua(lua),
|
||||
Self::Remove(b) => b.into_lua(lua),
|
||||
Self::RemoveDo(b) => b.into_lua(lua),
|
||||
Self::Rename(b) => b.into_lua(lua),
|
||||
Self::Reveal(b) => b.into_lua(lua),
|
||||
Self::Search(b) => b.into_lua(lua),
|
||||
Self::SearchDo(b) => b.into_lua(lua),
|
||||
Self::SearchStop(b) => b.into_lua(lua),
|
||||
Self::Seek(b) => b.into_lua(lua),
|
||||
Self::Shell(b) => b.into_lua(lua),
|
||||
Self::Sort(b) => b.into_lua(lua),
|
||||
Self::Spot(b) => b.into_lua(lua),
|
||||
Self::Suspend(b) => b.into_lua(lua),
|
||||
Self::TabClose(b) => b.into_lua(lua),
|
||||
Self::TabCreate(b) => b.into_lua(lua),
|
||||
Self::TabSwap(b) => b.into_lua(lua),
|
||||
Self::TabSwitch(b) => b.into_lua(lua),
|
||||
Self::Toggle(b) => b.into_lua(lua),
|
||||
Self::ToggleAll(b) => b.into_lua(lua),
|
||||
Self::Unyank(b) => b.into_lua(lua),
|
||||
Self::UpdateFiles(b) => b.into_lua(lua),
|
||||
Self::UpdateMimes(b) => b.into_lua(lua),
|
||||
Self::UpdatePaged(b) => b.into_lua(lua),
|
||||
Self::UpdatePeeked(b) => b.into_lua(lua),
|
||||
Self::UpdateSpotted(b) => b.into_lua(lua),
|
||||
Self::UpdateTasks(b) => b.into_lua(lua),
|
||||
Self::UpdateYanked(b) => b.into_lua(lua),
|
||||
Self::VisualMode(b) => b.into_lua(lua),
|
||||
Self::Watch(b) => b.into_lua(lua),
|
||||
Self::Yank(b) => b.into_lua(lua),
|
||||
|
||||
// Cmp
|
||||
Self::CmpClose(b) => b.into_lua(lua),
|
||||
Self::CmpShow(b) => b.into_lua(lua),
|
||||
Self::CmpTrigger(b) => b.into_lua(lua),
|
||||
|
||||
// Confirm
|
||||
Self::ConfirmClose(b) => b.into_lua(lua),
|
||||
Self::ConfirmShow(b) => b.into_lua(lua),
|
||||
|
||||
// Help
|
||||
Self::HelpToggle(b) => b.into_lua(lua),
|
||||
|
||||
// Input
|
||||
Self::InputBackspace(b) => b.into_lua(lua),
|
||||
Self::InputBackward(b) => b.into_lua(lua),
|
||||
Self::InputClose(b) => b.into_lua(lua),
|
||||
Self::InputComplete(b) => b.into_lua(lua),
|
||||
Self::InputDelete(b) => b.into_lua(lua),
|
||||
Self::InputForward(b) => b.into_lua(lua),
|
||||
Self::InputInsert(b) => b.into_lua(lua),
|
||||
Self::InputKill(b) => b.into_lua(lua),
|
||||
Self::InputMove(b) => b.into_lua(lua),
|
||||
Self::InputPaste(b) => b.into_lua(lua),
|
||||
Self::InputShow(b) => b.into_lua(lua),
|
||||
|
||||
// Notify
|
||||
Self::NotifyTick(b) => b.into_lua(lua),
|
||||
|
||||
// Pick
|
||||
Self::PickClose(b) => b.into_lua(lua),
|
||||
Self::PickShow(b) => b.into_lua(lua),
|
||||
|
||||
// Spot
|
||||
Self::SpotCopy(b) => b.into_lua(lua),
|
||||
|
||||
// Tasks
|
||||
Self::TasksProcessExec(b) => b.into_lua(lua),
|
||||
|
||||
// Which
|
||||
Self::WhichCallback(b) => b.into_lua(lua),
|
||||
Self::WhichShow(b) => b.into_lua(lua),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try_from_spark!(
|
||||
VoidOpt,
|
||||
mgr:back,
|
||||
mgr:bulk_rename,
|
||||
mgr:enter,
|
||||
mgr:escape_filter,
|
||||
mgr:escape_find,
|
||||
mgr:escape_search,
|
||||
mgr:escape_select,
|
||||
mgr:escape_visual,
|
||||
mgr:follow,
|
||||
mgr:forward,
|
||||
mgr:leave,
|
||||
mgr:refresh,
|
||||
mgr:search_stop,
|
||||
mgr:suspend,
|
||||
mgr:unyank,
|
||||
mgr:watch
|
||||
);
|
||||
try_from_spark!(ArrowOpt, mgr:arrow, mgr:tab_swap);
|
||||
try_from_spark!(cmp::CloseOpt, cmp:close);
|
||||
try_from_spark!(cmp::ShowOpt, cmp:show);
|
||||
try_from_spark!(cmp::TriggerOpt, cmp:trigger);
|
||||
try_from_spark!(confirm::CloseOpt, confirm:close);
|
||||
try_from_spark!(confirm::ShowOpt, confirm:show);
|
||||
try_from_spark!(help::ToggleOpt, help:toggle);
|
||||
try_from_spark!(input::BackspaceOpt, input:backspace);
|
||||
try_from_spark!(input::BackwardOpt, input:backward);
|
||||
try_from_spark!(input::CloseOpt, input:close);
|
||||
try_from_spark!(input::CompleteOpt, input:complete);
|
||||
try_from_spark!(input::DeleteOpt, input:delete);
|
||||
try_from_spark!(input::ForwardOpt, input:forward);
|
||||
try_from_spark!(input::InsertOpt, input:insert);
|
||||
try_from_spark!(input::KillOpt, input:kill);
|
||||
try_from_spark!(input::MoveOpt, input:move);
|
||||
try_from_spark!(input::PasteOpt, input:paste);
|
||||
try_from_spark!(input::ShowOpt, input:show);
|
||||
try_from_spark!(mgr::CdOpt, mgr:cd);
|
||||
try_from_spark!(mgr::CloseOpt, mgr:close);
|
||||
try_from_spark!(mgr::CopyOpt, mgr:copy);
|
||||
try_from_spark!(mgr::CreateOpt, mgr:create);
|
||||
try_from_spark!(mgr::EscapeOpt, mgr:escape);
|
||||
try_from_spark!(mgr::FilterOpt, mgr:filter, mgr:filter_do);
|
||||
try_from_spark!(mgr::FindArrowOpt, mgr:find_arrow);
|
||||
try_from_spark!(mgr::FindDoOpt, mgr:find_do);
|
||||
try_from_spark!(mgr::FindOpt, mgr:find);
|
||||
try_from_spark!(mgr::HardlinkOpt, mgr:hardlink);
|
||||
try_from_spark!(mgr::HiddenOpt, mgr:hidden);
|
||||
try_from_spark!(mgr::HoverDoOpt, mgr:hover_do);
|
||||
try_from_spark!(mgr::HoverOpt, mgr:hover);
|
||||
try_from_spark!(mgr::LinemodeOpt, mgr:linemode);
|
||||
try_from_spark!(mgr::LinkOpt, mgr:link);
|
||||
try_from_spark!(mgr::OpenDoOpt, mgr:open_do);
|
||||
try_from_spark!(mgr::OpenOpt, mgr:open);
|
||||
try_from_spark!(mgr::OpenWithOpt, mgr:open_with);
|
||||
try_from_spark!(mgr::PasteOpt, mgr:paste);
|
||||
try_from_spark!(mgr::PeekOpt, mgr:peek);
|
||||
try_from_spark!(mgr::QuitOpt, mgr:quit);
|
||||
try_from_spark!(mgr::RemoveOpt, mgr:remove, mgr:remove_do);
|
||||
try_from_spark!(mgr::RenameOpt, mgr:rename);
|
||||
try_from_spark!(mgr::RevealOpt, mgr:reveal);
|
||||
try_from_spark!(mgr::SearchOpt, mgr:search, mgr:search_do);
|
||||
try_from_spark!(mgr::SeekOpt, mgr:seek);
|
||||
try_from_spark!(mgr::ShellOpt, mgr:shell);
|
||||
try_from_spark!(mgr::SortOpt, mgr:sort);
|
||||
try_from_spark!(mgr::SpotOpt, mgr:spot);
|
||||
try_from_spark!(mgr::TabCloseOpt, mgr:tab_close);
|
||||
try_from_spark!(mgr::TabCreateOpt, mgr:tab_create);
|
||||
try_from_spark!(mgr::TabSwitchOpt, mgr:tab_switch);
|
||||
try_from_spark!(mgr::ToggleAllOpt, mgr:toggle_all);
|
||||
try_from_spark!(mgr::ToggleOpt, mgr:toggle);
|
||||
try_from_spark!(mgr::UpdateFilesOpt, mgr:update_files);
|
||||
try_from_spark!(mgr::UpdateMimesOpt, mgr:update_mimes);
|
||||
try_from_spark!(mgr::UpdatePagedOpt, mgr:update_paged);
|
||||
try_from_spark!(mgr::UpdatePeekedOpt, mgr:update_peeked);
|
||||
try_from_spark!(mgr::UpdateSpottedOpt, mgr:update_spotted);
|
||||
try_from_spark!(mgr::UpdateTasksOpt, mgr:update_tasks);
|
||||
try_from_spark!(mgr::UpdateYankedOpt<'a>, mgr:update_yanked);
|
||||
try_from_spark!(mgr::VisualModeOpt, mgr:visual_mode);
|
||||
try_from_spark!(mgr::YankOpt, mgr:yank);
|
||||
try_from_spark!(notify::TickOpt, notify:tick);
|
||||
try_from_spark!(pick::CloseOpt, pick:close);
|
||||
try_from_spark!(pick::ShowOpt, pick:show);
|
||||
try_from_spark!(spot::CopyOpt, spot:copy);
|
||||
try_from_spark!(tasks::ProcessExecOpt, tasks:process_exec);
|
||||
try_from_spark!(which::CallbackOpt, which:callback);
|
||||
try_from_spark!(which::ShowOpt, which:show);
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
#[macro_export]
|
||||
macro_rules! act {
|
||||
(@pre $layer:ident : $name:ident, $cx:ident, $opt:ident) => {
|
||||
<act!($layer:$name) as yazi_actor::Actor>::hook($cx, &$opt).map(|hook| {
|
||||
<act!(core:preflight) as yazi_actor::Actor>::act($cx, (hook, yazi_dds::body!($layer:$name, &$opt)))
|
||||
})
|
||||
if let Some(hook) = <act!($layer:$name) as yazi_actor::Actor>::hook($cx, &$opt) {
|
||||
<act!(core:preflight)>::act($cx, (hook, yazi_dds::spark!($layer:$name, $opt))).map(|spark| spark.try_into().unwrap())
|
||||
} else {
|
||||
Ok($opt)
|
||||
}
|
||||
};
|
||||
(@impl $layer:ident : $name:ident, $cx:ident, $opt:ident) => {{
|
||||
$cx.level += 1;
|
||||
let result = match act!(@pre $layer:$name, $cx, $opt) {
|
||||
Some(Ok(yazi_shared::event::Data::Boolean(true))) => Err(anyhow::anyhow!("canceled on preflight")),
|
||||
None | Some(Ok(_)) => <act!($layer:$name) as yazi_actor::Actor>::act($cx, $opt),
|
||||
Some(e @ Err(_)) => e,
|
||||
Ok(opt) => <act!($layer:$name) as yazi_actor::Actor>::act($cx, opt),
|
||||
Err(e) => Err(e),
|
||||
};
|
||||
$cx.level -= 1;
|
||||
result
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CloseOpt {
|
||||
pub submit: bool,
|
||||
}
|
||||
|
|
@ -12,3 +13,11 @@ impl From<CmdCow> for CloseOpt {
|
|||
impl From<bool> for CloseOpt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
}
|
||||
|
||||
impl FromLua for CloseOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CloseOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
use std::{ffi::OsString, path::MAIN_SEPARATOR_STR};
|
||||
|
||||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{Id, event::CmdCow, url::{Url, UrnBuf}};
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ShowOpt {
|
||||
pub cache: Vec<CmpItem>,
|
||||
pub cache_name: Url,
|
||||
|
|
@ -23,6 +24,14 @@ impl TryFrom<CmdCow> for ShowOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromLua for ShowOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ShowOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
// --- Item
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CmpItem {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{Id, SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TriggerOpt {
|
||||
pub word: SStr,
|
||||
pub ticket: Option<Id>,
|
||||
|
|
@ -10,3 +12,11 @@ impl From<CmdCow> for TriggerOpt {
|
|||
Self { word: c.take_first_str().unwrap_or_default(), ticket: c.id("ticket") }
|
||||
}
|
||||
}
|
||||
|
||||
impl FromLua for TriggerOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for TriggerOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CloseOpt {
|
||||
pub submit: bool,
|
||||
}
|
||||
|
|
@ -12,3 +13,11 @@ impl From<CmdCow> for CloseOpt {
|
|||
impl From<bool> for CloseOpt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
}
|
||||
|
||||
impl FromLua for CloseOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CloseOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use tokio::sync::oneshot;
|
||||
use yazi_config::popup::ConfirmCfg;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ShowOpt {
|
||||
pub cfg: ConfirmCfg,
|
||||
pub tx: oneshot::Sender<bool>,
|
||||
|
|
@ -23,3 +25,15 @@ impl TryFrom<CmdCow> for ShowOpt {
|
|||
Ok(Self { cfg, tx })
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Box<ShowOpt>> for ShowOpt {
|
||||
fn from(value: Box<ShowOpt>) -> Self { *value }
|
||||
}
|
||||
|
||||
impl FromLua for ShowOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ShowOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -1 +0,0 @@
|
|||
|
||||
|
|
@ -1 +1 @@
|
|||
yazi_macro::mod_flat!(escape filter toggle);
|
||||
yazi_macro::mod_flat!(toggle);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{Layer, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ToggleOpt {
|
||||
pub layer: Layer,
|
||||
}
|
||||
|
|
@ -20,3 +22,11 @@ impl TryFrom<CmdCow> for ToggleOpt {
|
|||
impl From<Layer> for ToggleOpt {
|
||||
fn from(layer: Layer) -> Self { Self { layer } }
|
||||
}
|
||||
|
||||
impl FromLua for ToggleOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ToggleOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct BackspaceOpt {
|
||||
pub under: bool,
|
||||
}
|
||||
|
|
@ -12,3 +13,11 @@ impl From<CmdCow> for BackspaceOpt {
|
|||
impl From<bool> for BackspaceOpt {
|
||||
fn from(under: bool) -> Self { Self { under } }
|
||||
}
|
||||
|
||||
impl FromLua for BackspaceOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for BackspaceOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct BackwardOpt {
|
||||
pub far: bool,
|
||||
}
|
||||
|
|
@ -7,3 +9,11 @@ pub struct BackwardOpt {
|
|||
impl From<CmdCow> for BackwardOpt {
|
||||
fn from(c: CmdCow) -> Self { Self { far: c.bool("far") } }
|
||||
}
|
||||
|
||||
impl FromLua for BackwardOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for BackwardOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CloseOpt {
|
||||
pub submit: bool,
|
||||
}
|
||||
|
|
@ -12,3 +13,11 @@ impl From<CmdCow> for CloseOpt {
|
|||
impl From<bool> for CloseOpt {
|
||||
fn from(submit: bool) -> Self { Self { submit } }
|
||||
}
|
||||
|
||||
impl FromLua for CloseOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CloseOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{Id, event::CmdCow};
|
||||
|
||||
use crate::cmp::CmpItem;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CompleteOpt {
|
||||
pub item: CmpItem,
|
||||
pub _ticket: Id, // FIXME: not used
|
||||
|
|
@ -19,3 +21,11 @@ impl TryFrom<CmdCow> for CompleteOpt {
|
|||
Ok(Self { item, _ticket: c.id("ticket").unwrap_or_default() })
|
||||
}
|
||||
}
|
||||
|
||||
impl FromLua for CompleteOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CompleteOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DeleteOpt {
|
||||
pub cut: bool,
|
||||
pub insert: bool,
|
||||
|
|
@ -8,3 +10,11 @@ pub struct DeleteOpt {
|
|||
impl From<CmdCow> for DeleteOpt {
|
||||
fn from(c: CmdCow) -> Self { Self { cut: c.bool("cut"), insert: c.bool("insert") } }
|
||||
}
|
||||
|
||||
impl FromLua for DeleteOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for DeleteOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ForwardOpt {
|
||||
pub far: bool,
|
||||
pub end_of_word: bool,
|
||||
|
|
@ -8,3 +10,11 @@ pub struct ForwardOpt {
|
|||
impl From<CmdCow> for ForwardOpt {
|
||||
fn from(c: CmdCow) -> Self { Self { far: c.bool("far"), end_of_word: c.bool("end-of-word") } }
|
||||
}
|
||||
|
||||
impl FromLua for ForwardOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ForwardOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct InsertOpt {
|
||||
pub append: bool,
|
||||
}
|
||||
|
|
@ -11,3 +13,11 @@ impl From<CmdCow> for InsertOpt {
|
|||
impl From<bool> for InsertOpt {
|
||||
fn from(append: bool) -> Self { Self { append } }
|
||||
}
|
||||
|
||||
impl FromLua for InsertOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for InsertOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct KillOpt {
|
||||
pub kind: SStr,
|
||||
}
|
||||
|
|
@ -7,3 +9,11 @@ pub struct KillOpt {
|
|||
impl From<CmdCow> for KillOpt {
|
||||
fn from(mut c: CmdCow) -> Self { Self { kind: c.take_first_str().unwrap_or_default() } }
|
||||
}
|
||||
|
||||
impl FromLua for KillOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for KillOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
use std::{num::ParseIntError, str::FromStr};
|
||||
|
||||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MoveOpt {
|
||||
pub step: MoveOptStep,
|
||||
pub in_operating: bool,
|
||||
|
|
@ -22,7 +23,16 @@ impl From<isize> for MoveOpt {
|
|||
fn from(step: isize) -> Self { Self { step: step.into(), in_operating: false } }
|
||||
}
|
||||
|
||||
impl FromLua for MoveOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for MoveOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
// --- Step
|
||||
#[derive(Debug)]
|
||||
pub enum MoveOptStep {
|
||||
Offset(isize),
|
||||
Bol,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct PasteOpt {
|
||||
pub before: bool,
|
||||
}
|
||||
|
|
@ -7,3 +9,11 @@ pub struct PasteOpt {
|
|||
impl From<CmdCow> for PasteOpt {
|
||||
fn from(c: CmdCow) -> Self { Self { before: c.bool("before") } }
|
||||
}
|
||||
|
||||
impl FromLua for PasteOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for PasteOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use tokio::sync::mpsc;
|
||||
use yazi_config::popup::InputCfg;
|
||||
use yazi_shared::{errors::InputError, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ShowOpt {
|
||||
pub cfg: InputCfg,
|
||||
pub tx: mpsc::UnboundedSender<Result<String, InputError>>,
|
||||
|
|
@ -23,3 +25,11 @@ impl TryFrom<CmdCow> for ShowOpt {
|
|||
Ok(Self { cfg, tx })
|
||||
}
|
||||
}
|
||||
|
||||
impl FromLua for ShowOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ShowOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::expand_url;
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
|
|
@ -29,7 +29,11 @@ impl From<(Url, CdSource)> for CdOpt {
|
|||
fn from((target, source): (Url, CdSource)) -> Self { Self { target, interactive: false, source } }
|
||||
}
|
||||
|
||||
impl IntoLua for &CdOpt {
|
||||
impl FromLua for CdOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CdOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
use crate::mgr::QuitOpt;
|
||||
|
|
@ -10,6 +10,10 @@ impl From<CmdCow> for CloseOpt {
|
|||
fn from(c: CmdCow) -> Self { Self(c.into()) }
|
||||
}
|
||||
|
||||
impl IntoLua for &CloseOpt {
|
||||
impl FromLua for CloseOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CloseOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{borrow::Cow, ffi::OsStr, path::Path};
|
||||
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -20,7 +20,11 @@ impl From<CmdCow> for CopyOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &CopyOpt {
|
||||
impl FromLua for CopyOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CopyOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -11,6 +11,10 @@ impl From<CmdCow> for CreateOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { dir: c.bool("dir"), force: c.bool("force") } }
|
||||
}
|
||||
|
||||
impl IntoLua for &CreateOpt {
|
||||
impl FromLua for CreateOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for CreateOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use bitflags::bitflags;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
bitflags! {
|
||||
|
|
@ -29,6 +29,10 @@ impl From<CmdCow> for EscapeOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &EscapeOpt {
|
||||
impl FromLua for EscapeOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for EscapeOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::FilterCase;
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
|
|
@ -25,6 +25,10 @@ impl TryFrom<CmdCow> for FilterOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &FilterOpt {
|
||||
impl FromLua for FilterOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for FilterOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::FilterCase;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
|
|
@ -16,6 +16,10 @@ impl TryFrom<CmdCow> for FindOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &FindOpt {
|
||||
impl FromLua for FindOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for FindOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -10,6 +10,10 @@ impl From<CmdCow> for FindArrowOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { prev: c.bool("previous") } }
|
||||
}
|
||||
|
||||
impl IntoLua for &FindArrowOpt {
|
||||
impl FromLua for FindArrowOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for FindArrowOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::FilterCase;
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
|
|
@ -26,6 +26,10 @@ impl TryFrom<CmdCow> for FindDoOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &FindDoOpt {
|
||||
impl FromLua for FindDoOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for FindDoOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -11,6 +11,10 @@ impl From<CmdCow> for HardlinkOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
}
|
||||
|
||||
impl IntoLua for &HardlinkOpt {
|
||||
impl FromLua for HardlinkOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for HardlinkOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -18,6 +18,10 @@ impl From<CmdCow> for HiddenOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &HiddenOpt {
|
||||
impl FromLua for HiddenOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for HiddenOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
@ -14,7 +14,11 @@ impl From<Option<Url>> for HoverOpt {
|
|||
fn from(url: Option<Url>) -> Self { Self { url } }
|
||||
}
|
||||
|
||||
impl IntoLua for &HoverOpt {
|
||||
impl FromLua for HoverOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for HoverOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
@ -28,6 +32,10 @@ impl From<Url> for HoverDoOpt {
|
|||
fn from(url: Url) -> Self { Self { url } }
|
||||
}
|
||||
|
||||
impl IntoLua for &HoverDoOpt {
|
||||
impl FromLua for HoverDoOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for HoverDoOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -23,6 +23,10 @@ impl TryFrom<CmdCow> for LinemodeOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &LinemodeOpt {
|
||||
impl FromLua for LinemodeOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for LinemodeOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -11,6 +11,10 @@ impl From<CmdCow> for LinkOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { relative: c.bool("relative"), force: c.bool("force") } }
|
||||
}
|
||||
|
||||
impl IntoLua for &LinkOpt {
|
||||
impl FromLua for LinkOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for LinkOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ yazi_macro::mod_flat!(
|
|||
linemode
|
||||
link
|
||||
open
|
||||
open_do
|
||||
open_with
|
||||
paste
|
||||
peek
|
||||
quit
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use yazi_config::opener::OpenerRule;
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct OpenOpt {
|
||||
|
|
@ -17,38 +13,10 @@ impl From<CmdCow> for OpenOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &OpenOpt {
|
||||
impl FromLua for OpenOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for OpenOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
// --- Do
|
||||
#[derive(Debug, Default)]
|
||||
pub struct OpenDoOpt {
|
||||
pub cwd: Url,
|
||||
pub hovered: Url,
|
||||
pub targets: Vec<(Url, &'static str)>,
|
||||
pub interactive: bool,
|
||||
}
|
||||
|
||||
impl From<CmdCow> for OpenDoOpt {
|
||||
fn from(mut c: CmdCow) -> Self { c.take_any("option").unwrap_or_default() }
|
||||
}
|
||||
|
||||
impl IntoLua for &OpenDoOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
// --- Open with
|
||||
pub struct OpenWithOpt {
|
||||
pub opener: Cow<'static, OpenerRule>,
|
||||
pub cwd: Url,
|
||||
pub targets: Vec<Url>,
|
||||
}
|
||||
|
||||
impl TryFrom<CmdCow> for OpenWithOpt {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
c.take_any("option").ok_or_else(|| anyhow!("Missing 'option' in OpenWithOpt"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
22
yazi-parser/src/mgr/open_do.rs
Normal file
22
yazi-parser/src/mgr/open_do.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct OpenDoOpt {
|
||||
pub cwd: Url,
|
||||
pub hovered: Url,
|
||||
pub targets: Vec<(Url, &'static str)>,
|
||||
pub interactive: bool,
|
||||
}
|
||||
|
||||
impl From<CmdCow> for OpenDoOpt {
|
||||
fn from(mut c: CmdCow) -> Self { c.take_any("option").unwrap_or_default() }
|
||||
}
|
||||
|
||||
impl FromLua for OpenDoOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for OpenDoOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
29
yazi-parser/src/mgr/open_with.rs
Normal file
29
yazi-parser/src/mgr/open_with.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use anyhow::anyhow;
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_config::opener::OpenerRule;
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OpenWithOpt {
|
||||
pub opener: Cow<'static, OpenerRule>,
|
||||
pub cwd: Url,
|
||||
pub targets: Vec<Url>,
|
||||
}
|
||||
|
||||
impl TryFrom<CmdCow> for OpenWithOpt {
|
||||
type Error = anyhow::Error;
|
||||
|
||||
fn try_from(mut c: CmdCow) -> Result<Self, Self::Error> {
|
||||
c.take_any("option").ok_or_else(|| anyhow!("Missing 'option' in OpenWithOpt"))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromLua for OpenWithOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for OpenWithOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -11,6 +11,10 @@ impl From<CmdCow> for PasteOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { force: c.bool("force"), follow: c.bool("follow") } }
|
||||
}
|
||||
|
||||
impl IntoLua for &PasteOpt {
|
||||
impl FromLua for PasteOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for PasteOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::{CmdCow, Data}, url::Url};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
@ -24,6 +24,10 @@ impl From<bool> for PeekOpt {
|
|||
fn from(force: bool) -> Self { Self { force, ..Default::default() } }
|
||||
}
|
||||
|
||||
impl IntoLua for &PeekOpt {
|
||||
impl FromLua for PeekOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for PeekOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{IntoLua, Lua, LuaSerdeExt, Value};
|
||||
use mlua::{FromLua, IntoLua, Lua, LuaSerdeExt, Value};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use yazi_shared::event::{CmdCow, Data, EventQuit};
|
||||
|
||||
|
|
@ -23,6 +23,10 @@ impl From<QuitOpt> for EventQuit {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &QuitOpt {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> { lua.to_value(self) }
|
||||
impl FromLua for QuitOpt {
|
||||
fn from_lua(value: Value, lua: &Lua) -> mlua::Result<Self> { lua.from_value(value) }
|
||||
}
|
||||
|
||||
impl IntoLua for QuitOpt {
|
||||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> { lua.to_value(&self) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -20,6 +20,10 @@ impl From<CmdCow> for RemoveOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &RemoveOpt {
|
||||
impl FromLua for RemoveOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for RemoveOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -20,6 +20,10 @@ impl From<CmdCow> for RenameOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &RenameOpt {
|
||||
impl FromLua for RenameOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for RenameOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::expand_url;
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
|
|
@ -35,6 +35,10 @@ impl From<(Url, CdSource)> for RevealOpt {
|
|||
fn from((target, source): (Url, CdSource)) -> Self { Self { target, source, no_dummy: false } }
|
||||
}
|
||||
|
||||
impl IntoLua for &RevealOpt {
|
||||
impl FromLua for RevealOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for RevealOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::CmdCow};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -35,7 +35,11 @@ impl TryFrom<CmdCow> for SearchOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &SearchOpt {
|
||||
impl FromLua for SearchOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for SearchOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -10,6 +10,10 @@ impl From<CmdCow> for SeekOpt {
|
|||
fn from(c: CmdCow) -> Self { Self { units: c.first().and_then(Data::as_i16).unwrap_or(0) } }
|
||||
}
|
||||
|
||||
impl IntoLua for &SeekOpt {
|
||||
impl FromLua for SeekOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for SeekOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{SStr, event::{CmdCow, Data}, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -37,6 +37,10 @@ impl TryFrom<CmdCow> for ShellOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &ShellOpt {
|
||||
impl FromLua for ShellOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ShellOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::str::FromStr;
|
||||
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::SortBy;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
|
|
@ -27,6 +27,10 @@ impl TryFrom<CmdCow> for SortOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &SortOpt {
|
||||
impl FromLua for SortOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for SortOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
@ -14,6 +14,10 @@ impl From<usize> for SpotOpt {
|
|||
fn from(skip: usize) -> Self { Self { skip: Some(skip) } }
|
||||
}
|
||||
|
||||
impl IntoLua for &SpotOpt {
|
||||
impl FromLua for SpotOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for SpotOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -14,6 +14,10 @@ impl From<usize> for TabCloseOpt {
|
|||
fn from(idx: usize) -> Self { Self { idx } }
|
||||
}
|
||||
|
||||
impl IntoLua for &TabCloseOpt {
|
||||
impl FromLua for TabCloseOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for TabCloseOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_boot::BOOT;
|
||||
use yazi_fs::expand_url;
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
|
@ -27,6 +27,10 @@ impl From<CmdCow> for TabCreateOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &TabCreateOpt {
|
||||
impl FromLua for TabCreateOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for TabCreateOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -13,6 +13,10 @@ impl From<CmdCow> for TabSwitchOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &TabSwitchOpt {
|
||||
impl FromLua for TabSwitchOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for TabSwitchOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -20,6 +20,10 @@ impl From<CmdCow> for ToggleOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &ToggleOpt {
|
||||
impl FromLua for ToggleOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ToggleOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -32,6 +32,10 @@ impl From<Option<bool>> for ToggleAllOpt {
|
|||
fn from(state: Option<bool>) -> Self { Self { urls: vec![], state } }
|
||||
}
|
||||
|
||||
impl IntoLua for &ToggleAllOpt {
|
||||
impl FromLua for ToggleAllOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for ToggleAllOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_fs::FilesOp;
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
|
|
@ -20,6 +20,10 @@ impl TryFrom<CmdCow> for UpdateFilesOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdateFilesOpt {
|
||||
impl FromLua for UpdateFilesOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdateFilesOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::event::{CmdCow, Data, DataKey};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -21,6 +21,10 @@ impl TryFrom<CmdCow> for UpdateMimesOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdateMimesOpt {
|
||||
impl FromLua for UpdateMimesOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdateMimesOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::{CmdCow, Data}, url::Url};
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
|
@ -17,6 +17,10 @@ impl From<()> for UpdatePagedOpt {
|
|||
fn from(_: ()) -> Self { Self::default() }
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdatePagedOpt {
|
||||
impl FromLua for UpdatePagedOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdatePagedOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Table, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
|
||||
use yazi_binding::{FileRef, elements::{Rect, Renderable}};
|
||||
use yazi_shared::event::CmdCow;
|
||||
|
||||
|
|
@ -24,7 +24,11 @@ impl TryFrom<CmdCow> for UpdatePeekedOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdatePeekedOpt {
|
||||
impl FromLua for UpdatePeekedOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdatePeekedOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Table, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Table, Value};
|
||||
use yazi_binding::{FileRef, elements::Renderable};
|
||||
use yazi_shared::{Id, event::CmdCow};
|
||||
|
||||
|
|
@ -24,7 +24,11 @@ impl TryFrom<CmdCow> for UpdateSpottedOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdateSpottedOpt {
|
||||
impl FromLua for UpdateSpottedOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdateSpottedOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use anyhow::bail;
|
||||
use mlua::{ExternalError, IntoLua, Lua, Value};
|
||||
use mlua::{ExternalError, FromLua, IntoLua, Lua, Value};
|
||||
use yazi_shared::{event::CmdCow, url::Url};
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
@ -19,6 +19,10 @@ impl TryFrom<CmdCow> for UpdateTasksOpt {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoLua for &UpdateTasksOpt {
|
||||
impl FromLua for UpdateTasksOpt {
|
||||
fn from_lua(_: Value, _: &Lua) -> mlua::Result<Self> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
||||
impl IntoLua for UpdateTasksOpt {
|
||||
fn into_lua(self, _: &Lua) -> mlua::Result<Value> { Err("unsupported".into_lua_err()) }
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue