diff --git a/yazi-fm/src/dispatcher.rs b/yazi-fm/src/dispatcher.rs index 83025aba0..2a62fe6a1 100644 --- a/yazi-fm/src/dispatcher.rs +++ b/yazi-fm/src/dispatcher.rs @@ -2,8 +2,12 @@ use std::sync::atomic::Ordering; use anyhow::Result; use crossterm::event::KeyEvent; +use mlua::{ObjectLike, Table, Value}; +use tracing::error; +use yazi_actor::lives::Lives; use yazi_config::keymap::Key; use yazi_macro::{act, emit, succ}; +use yazi_plugin::LUA; use yazi_shared::event::{CmdCow, Data, Event, NEED_RENDER}; use yazi_widgets::input::InputMode; @@ -58,6 +62,23 @@ impl<'a> Dispatcher<'a> { succ!(); } + #[inline] + fn dispatch_drop(&mut self, str: String) -> Result { + let Some(size) = self.app.term.as_ref().and_then(|t| t.size().ok()) else { succ!() }; + + let result = Lives::scope(&self.app.core, move || { + let area = yazi_binding::elements::Rect::from(size); + let root = LUA.globals().raw_get::("Root")?.call_method::
("new", area)?; + root.call_method::("drop", str.to_string())?; + Ok(()) + }); + + if let Err(ref e) = result { + error!("{e}"); + } + succ!(); + } + #[inline] fn dispatch_paste(&mut self, str: String) -> Result { if self.app.core.input.visible { @@ -67,6 +88,8 @@ impl<'a> Dispatcher<'a> { } else if input.mode() == InputMode::Replace { input.replace_str(&str)?; } + } else { + self.dispatch_drop(str)?; } succ!(); } diff --git a/yazi-plugin/preset/components/root.lua b/yazi-plugin/preset/components/root.lua index 678249856..1f6311463 100644 --- a/yazi-plugin/preset/components/root.lua +++ b/yazi-plugin/preset/components/root.lua @@ -76,3 +76,5 @@ end function Root:move(event) end function Root:drag(event) end + +function Root:drop(data) end