-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cut and paste (x -> p) sends new "move" events
- Loading branch information
1 parent
357f87a
commit edb2840
Showing
6 changed files
with
96 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use std::borrow::Cow; | ||
|
||
use mlua::{IntoLua, Lua, Value}; | ||
use serde::{Deserialize, Serialize}; | ||
use yazi_shared::fs::Url; | ||
|
||
use super::Body; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub struct BodyMove<'a> { | ||
pub tab: usize, | ||
pub from: Cow<'a, Url>, | ||
pub to: Cow<'a, Url>, | ||
} | ||
|
||
impl<'a> BodyMove<'a> { | ||
#[inline] | ||
pub fn borrowed(tab: usize, from: &'a Url, to: &'a Url) -> Body<'a> { | ||
Self { tab, from: Cow::Borrowed(from), to: Cow::Borrowed(to) }.into() | ||
} | ||
} | ||
|
||
impl BodyMove<'static> { | ||
#[inline] | ||
pub fn dummy(tab: usize, from: &Url, to: &Url) -> Body<'static> { | ||
Self { tab, from: Cow::Owned(from.clone()), to: Cow::Owned(to.clone()) }.into() | ||
} | ||
} | ||
|
||
impl<'a> From<BodyMove<'a>> for Body<'a> { | ||
fn from(value: BodyMove<'a>) -> Self { | ||
Self::Move(value) | ||
} | ||
} | ||
|
||
impl IntoLua<'_> for BodyMove<'static> { | ||
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> { | ||
lua | ||
.create_table_from([ | ||
("tab", self.tab.into_lua(lua)?), | ||
("from", lua.create_any_userdata(self.from.into_owned())?.into_lua(lua)?), | ||
("to", lua.create_any_userdata(self.to.into_owned())?.into_lua(lua)?), | ||
])? | ||
.into_lua(lua) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters