mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-22 07:11:03 +00:00
17 lines
455 B
Rust
17 lines
455 B
Rust
use core::Ctx;
|
|
|
|
pub use mlua::Scope;
|
|
|
|
use crate::{bindings, GLOBALS, LUA};
|
|
|
|
pub fn scope<'a>(cx: &'a Ctx, f: impl FnOnce(&Scope<'a, 'a>)) {
|
|
_ = LUA.scope(|scope| {
|
|
let tbl = LUA.create_table()?;
|
|
tbl.set("active", bindings::Active::new(scope, cx).make()?)?;
|
|
tbl.set("tabs", bindings::Tabs::new(scope, &cx.manager.tabs).make()?)?;
|
|
tbl.set("tasks", bindings::Tasks::new(scope, &cx.tasks).make()?)?;
|
|
GLOBALS.set("cx", tbl)?;
|
|
|
|
Ok(f(scope))
|
|
});
|
|
}
|