mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
Format
This commit is contained in:
parent
63b20ba2cb
commit
bfdbe4ffa0
5 changed files with 12 additions and 29 deletions
|
|
@ -2,9 +2,7 @@ use anyhow::Result;
|
||||||
use mlua::{ExternalResult, IntoLua, Lua, Value};
|
use mlua::{ExternalResult, IntoLua, Lua, Value};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::{
|
use super::{BodyBulk, BodyCd, BodyCustom, BodyHey, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank};
|
||||||
BodyBulk, BodyCd, BodyCustom, BodyHey, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank,
|
|
||||||
};
|
|
||||||
use crate::Payload;
|
use crate::Payload;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ impl BodyMove<'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<BodyMove<'a>> for Body<'a> {
|
impl<'a> From<BodyMove<'a>> for Body<'a> {
|
||||||
fn from(value: BodyMove<'a>) -> Self {
|
fn from(value: BodyMove<'a>) -> Self { Self::Move(value) }
|
||||||
Self::Move(value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntoLua<'_> for BodyMove<'static> {
|
impl IntoLua<'_> for BodyMove<'static> {
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,9 @@ pub struct Payload<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Payload<'a> {
|
impl<'a> Payload<'a> {
|
||||||
pub(super) fn new(body: Body<'a>) -> Self {
|
pub(super) fn new(body: Body<'a>) -> Self { Self { receiver: 0, sender: *ID, body } }
|
||||||
Self { receiver: 0, sender: *ID, body }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn flush(&self) {
|
pub(super) fn flush(&self) { writeln!(std::io::stdout(), "{self}").ok(); }
|
||||||
writeln!(std::io::stdout(), "{self}").ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(super) fn try_flush(&self) {
|
pub(super) fn try_flush(&self) {
|
||||||
let b = if self.receiver == 0 {
|
let b = if self.receiver == 0 {
|
||||||
|
|
@ -75,9 +71,7 @@ impl FromStr for Payload<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> From<Body<'a>> for Payload<'a> {
|
impl<'a> From<Body<'a>> for Payload<'a> {
|
||||||
fn from(value: Body<'a>) -> Self {
|
fn from(value: Body<'a>) -> Self { Self::new(value) }
|
||||||
Self::new(value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Payload<'_> {
|
impl Display for Payload<'_> {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,7 @@ use parking_lot::RwLock;
|
||||||
use yazi_boot::BOOT;
|
use yazi_boot::BOOT;
|
||||||
use yazi_shared::{fs::Url, RoCell};
|
use yazi_shared::{fs::Url, RoCell};
|
||||||
|
|
||||||
use crate::{
|
use crate::{body::{Body, BodyCd, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank}, Client, ID, PEERS};
|
||||||
body::{Body, BodyCd, BodyHi, BodyHover, BodyMove, BodyRename, BodyYank},
|
|
||||||
Client, ID, PEERS,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub static LOCAL: RoCell<RwLock<HashMap<String, HashMap<String, Function<'static>>>>> =
|
pub static LOCAL: RoCell<RwLock<HashMap<String, HashMap<String, Function<'static>>>>> =
|
||||||
RoCell::new();
|
RoCell::new();
|
||||||
|
|
@ -62,17 +59,13 @@ impl Pubsub {
|
||||||
sub!(REMOTE)(plugin, kind, f) && Self::pub_from_hi()
|
sub!(REMOTE)(plugin, kind, f) && Self::pub_from_hi()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unsub(plugin: &str, kind: &str) -> bool {
|
pub fn unsub(plugin: &str, kind: &str) -> bool { unsub!(LOCAL)(plugin, kind) }
|
||||||
unsub!(LOCAL)(plugin, kind)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn unsub_remote(plugin: &str, kind: &str) -> bool {
|
pub fn unsub_remote(plugin: &str, kind: &str) -> bool {
|
||||||
unsub!(REMOTE)(plugin, kind) && Self::pub_from_hi()
|
unsub!(REMOTE)(plugin, kind) && Self::pub_from_hi()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pub_(body: Body<'static>) {
|
pub fn pub_(body: Body<'static>) { body.with_receiver(*ID).emit(); }
|
||||||
body.with_receiver(*ID).emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pub_to(receiver: u64, body: Body<'static>) {
|
pub fn pub_to(receiver: u64, body: Body<'static>) {
|
||||||
if receiver == *ID {
|
if receiver == *ID {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue