1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-24 05:42:03 +03:00

lua: add window:mux_window() and pane:mux_window() methods

These allow converting the gui versions of these objects
to the mux versions.

refs: https://github.com/wez/wezterm/issues/225
This commit is contained in:
Wez Furlong 2022-06-27 20:28:26 -07:00
parent fb1a659c4c
commit f1c53495e7
7 changed files with 22 additions and 3 deletions

1
Cargo.lock generated
View File

@ -4761,6 +4761,7 @@ dependencies = [
"metrics",
"mlua",
"mux",
"mux-lua",
"open",
"ordered-float",
"portable-pty",

View File

@ -0,0 +1,6 @@
# pane:mux_pane()
*Since: nightly builds only*
Returns the [MuxPane](../MuxPane.md) representation of this pane.

View File

@ -0,0 +1,5 @@
# window:mux_window()
*Since: nightly builds only*
Returns the [MuxWindow](../MuxWindow.md) representation of this window.

View File

@ -258,11 +258,11 @@ impl SpawnWindow {
}
#[derive(Clone, Copy, Debug)]
struct MuxWindow(WindowId);
pub struct MuxWindow(pub WindowId);
#[derive(Clone, Copy, Debug)]
struct MuxTab(TabId);
pub struct MuxTab(pub TabId);
#[derive(Clone, Copy, Debug)]
struct MuxPane(PaneId);
pub struct MuxPane(pub PaneId);
impl MuxWindow {
fn resolve<'a>(&self, mux: &'a Rc<Mux>) -> mlua::Result<Ref<'a, Window>> {

View File

@ -46,6 +46,7 @@ luahelper = { path = "../luahelper" }
metrics = { version="0.17", features=["std"]}
mlua = {version="0.8.0-beta.4", features=["send"]}
mux = { path = "../mux" }
mux-lua = { path = "../lua-api-crates/mux" }
open = "3.0"
ordered-float = "3.0"
portable-pty = { path = "../pty", features = ["serde_support", "ssh"]}

View File

@ -32,6 +32,9 @@ impl GuiWin {
impl UserData for GuiWin {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("window_id", |_, this, _: ()| Ok(this.mux_window_id));
methods.add_method("mux_window", |_, this, _: ()| {
Ok(mux_lua::MuxWindow(this.mux_window_id))
});
methods.add_method(
"toast_notification",
|_, _, (title, message, url, timeout): (String, String, Option<String>, Option<u64>)| {

View File

@ -31,6 +31,9 @@ impl PaneObject {
impl UserData for PaneObject {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("pane_id", |_, this, _: ()| Ok(this.pane()?.pane_id()));
methods.add_method("mux_pane", |_, this, _: ()| {
Ok(mux_lua::MuxPane(this.pane()?.pane_id()))
});
methods.add_method("get_title", |_, this, _: ()| Ok(this.pane()?.get_title()));
methods.add_method("get_current_working_dir", |_, this, _: ()| {
Ok(this