This commit is contained in:
sxyazi 2024-04-09 01:01:30 +08:00
parent 63b20ba2cb
commit bfdbe4ffa0
No known key found for this signature in database
5 changed files with 12 additions and 29 deletions

View file

@ -3,7 +3,7 @@ use yazi_shared::event::Cmd;
use crate::{manager::Manager, tasks::Tasks};
pub struct Opt {
force: bool,
force: bool,
follow: bool,
}

View file

@ -2,9 +2,7 @@ use anyhow::Result;
use mlua::{ExternalResult, IntoLua, Lua, Value};
use serde::Serialize;
use super::{
BodyBulk, BodyCd, BodyCustom, BodyHey, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank,
};
use super::{BodyBulk, BodyCd, BodyCustom, BodyHey, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank};
use crate::Payload;
#[derive(Debug, Serialize)]

View file

@ -9,7 +9,7 @@ use super::Body;
#[derive(Debug, Serialize, Deserialize)]
pub struct BodyMove<'a> {
pub from: Cow<'a, Url>,
pub to: Cow<'a, Url>,
pub to: Cow<'a, Url>,
}
impl<'a> BodyMove<'a> {
@ -27,9 +27,7 @@ impl BodyMove<'static> {
}
impl<'a> From<BodyMove<'a>> for Body<'a> {
fn from(value: BodyMove<'a>) -> Self {
Self::Move(value)
}
fn from(value: BodyMove<'a>) -> Self { Self::Move(value) }
}
impl IntoLua<'_> for BodyMove<'static> {

View file

@ -9,18 +9,14 @@ use crate::{body::Body, ID};
#[derive(Debug)]
pub struct Payload<'a> {
pub receiver: u64,
pub sender: u64,
pub body: Body<'a>,
pub sender: u64,
pub body: Body<'a>,
}
impl<'a> Payload<'a> {
pub(super) fn new(body: Body<'a>) -> Self {
Self { receiver: 0, sender: *ID, body }
}
pub(super) fn new(body: Body<'a>) -> Self { Self { receiver: 0, sender: *ID, body } }
pub(super) fn flush(&self) {
writeln!(std::io::stdout(), "{self}").ok();
}
pub(super) fn flush(&self) { writeln!(std::io::stdout(), "{self}").ok(); }
pub(super) fn try_flush(&self) {
let b = if self.receiver == 0 {
@ -75,9 +71,7 @@ impl FromStr for Payload<'_> {
}
impl<'a> From<Body<'a>> for Payload<'a> {
fn from(value: Body<'a>) -> Self {
Self::new(value)
}
fn from(value: Body<'a>) -> Self { Self::new(value) }
}
impl Display for Payload<'_> {

View file

@ -5,10 +5,7 @@ use parking_lot::RwLock;
use yazi_boot::BOOT;
use yazi_shared::{fs::Url, RoCell};
use crate::{
body::{Body, BodyCd, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank},
Client, ID, PEERS,
};
use crate::{body::{Body, BodyCd, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank}, Client, ID, PEERS};
pub static LOCAL: RoCell<RwLock<HashMap<String, HashMap<String, Function<'static>>>>> =
RoCell::new();
@ -62,17 +59,13 @@ impl Pubsub {
sub!(REMOTE)(plugin, kind, f) && Self::pub_from_hi()
}
pub fn unsub(plugin: &str, kind: &str) -> bool {
unsub!(LOCAL)(plugin, kind)
}
pub fn unsub(plugin: &str, kind: &str) -> bool { unsub!(LOCAL)(plugin, kind) }
pub fn unsub_remote(plugin: &str, kind: &str) -> bool {
unsub!(REMOTE)(plugin, kind) && Self::pub_from_hi()
}
pub fn pub_(body: Body<'static>) {
body.with_receiver(*ID).emit();
}
pub fn pub_(body: Body<'static>) { body.with_receiver(*ID).emit(); }
pub fn pub_to(receiver: u64, body: Body<'static>) {
if receiver == *ID {