1
1
mirror of https://github.com/wez/wezterm.git synced 2024-10-06 03:07:36 +03:00

lua: add MuxWindow::gui_window() method

This is the inverse of Window::mux_window().
This commit is contained in:
Wez Furlong 2022-07-06 15:52:31 -07:00
parent 87ce88b924
commit 8f45cb8dfa

View File

@ -1,6 +1,6 @@
use config::keyassignment::SpawnTabDomain;
use config::lua::get_or_create_sub_module;
use config::lua::mlua::{self, Lua, UserData, UserDataMethods, Value as LuaValue};
use config::lua::{get_or_create_module, get_or_create_sub_module};
use luahelper::impl_lua_conversion_dynamic;
use mux::domain::SplitSource;
use mux::pane::{Pane, PaneId};
@ -334,6 +334,15 @@ impl_lua_conversion_dynamic!(MuxTabInfo);
impl UserData for MuxWindow {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("window_id", |_, this, _: ()| Ok(this.0));
methods.add_method("gui_window", |lua, this, _: ()| {
// Weakly bound to the gui module; mux cannot hard-depend
// on wezterm-gui, but we can runtime resolve the appropriate module
let wezterm_mod = get_or_create_module(lua, "wezterm")
.map_err(|err| mlua::Error::external(format!("{err:#}")))?;
let gui: mlua::Table = wezterm_mod.get("gui")?;
let func: mlua::Function = gui.get("gui_window_for_mux_window")?;
func.call::<_, mlua::Value>(this.0)
});
methods.add_method("get_workspace", |_, this, _: ()| {
let mux = get_mux()?;
let window = this.resolve(&mux)?;