mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
46 lines
1.1 KiB
Rust
46 lines
1.1 KiB
Rust
use mlua::{IntoLua, Lua, Value};
|
|
use yazi_binding::elements::Rect;
|
|
use yazi_config::{LAYOUT, plugin::PreviewerArc};
|
|
use yazi_fs::file::File;
|
|
use yazi_shared::{data::Sendable, pool::Symbol};
|
|
|
|
#[derive(Clone, Debug)]
|
|
pub struct PeekJob {
|
|
pub previewer: PreviewerArc,
|
|
pub file: File,
|
|
pub mime: Symbol<str>,
|
|
pub skip: usize,
|
|
}
|
|
|
|
impl IntoLua for PeekJob {
|
|
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
|
lua
|
|
.create_table_from([
|
|
("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
|
|
("args", Sendable::args_to_table_ref(lua, &self.previewer.args)?.into_lua(lua)?),
|
|
("file", self.file.into_lua(lua)?),
|
|
("mime", self.mime.into_lua(lua)?),
|
|
("skip", self.skip.into_lua(lua)?),
|
|
])?
|
|
.into_lua(lua)
|
|
}
|
|
}
|
|
|
|
// --- Seek
|
|
#[derive(Clone, Debug)]
|
|
pub struct SeekJob {
|
|
pub file: File,
|
|
pub units: i16,
|
|
}
|
|
|
|
impl IntoLua for SeekJob {
|
|
fn into_lua(self, lua: &Lua) -> mlua::Result<Value> {
|
|
lua
|
|
.create_table_from([
|
|
("area", Rect::from(LAYOUT.get().preview).into_lua(lua)?),
|
|
("file", self.file.into_lua(lua)?),
|
|
("units", self.units.into_lua(lua)?),
|
|
])?
|
|
.into_lua(lua)
|
|
}
|
|
}
|