-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
158 additions
and
238 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,5 @@ | ||
mod peek; | ||
mod preload; | ||
|
||
pub use peek::*; | ||
pub use preload::*; |
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,20 @@ | ||
use mlua::{ExternalError, Lua, Table, TableExt}; | ||
|
||
use crate::bindings::{Cast, File}; | ||
|
||
pub async fn peek(file: yazi_shared::fs::File, skip: usize) -> mlua::Result<()> { | ||
tokio::task::spawn_local(async move { | ||
let lua = Lua::new(); | ||
crate::bindings::Url::register(&lua)?; | ||
crate::bindings::File::register(&lua, |_| {})?; | ||
crate::Utils::install(&lua)?; | ||
|
||
let plugin: Table = | ||
lua.load(include_str!("../../../yazi-plugin/preset/plugins/image.lua")).call(())?; | ||
|
||
let file = File::cast(&lua, file)?; | ||
plugin.call_async_method::<_, ()>("peek", (file, skip)).await | ||
}) | ||
.await | ||
.map_err(|_| "peek error".into_lua_err())? | ||
} |
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,19 @@ | ||
use mlua::{Lua, Table, TableExt}; | ||
|
||
use crate::bindings::{Cast, File}; | ||
|
||
pub async fn preload(files: &[yazi_shared::fs::File]) -> mlua::Result<()> { | ||
let lua = Lua::new(); | ||
crate::bindings::Url::register(&lua)?; | ||
crate::bindings::File::register(&lua, |_| {})?; | ||
crate::Utils::install(&lua)?; | ||
|
||
let plugin: Table = | ||
lua.load(include_str!("../../../yazi-plugin/preset/plugins/image.lua")).call(())?; | ||
|
||
for file in files { | ||
let file = File::cast(&lua, file.clone())?; | ||
plugin.call_async_method::<_, mlua::Error>("preload", file).await.ok(); | ||
} | ||
Ok(()) | ||
} |
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
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
Oops, something went wrong.