1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-29 00:21:57 +03:00

mux: add lua api equivalent to move-pane-to-new-tab

refs: #3374
This commit is contained in:
Wez Furlong 2023-03-26 11:07:44 -07:00
parent d9d6b2a01a
commit e56b169cc4
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
5 changed files with 53 additions and 0 deletions

View File

@ -33,6 +33,8 @@ As features stabilize some brief notes about them will accumulate here.
enables a nice translucent window effect. Thanks to @Gkirito! #3344 enables a nice translucent window effect. Thanks to @Gkirito! #3344
* [new-tab-button-click event](config/lua/window-events/new-tab-button-click.md) * [new-tab-button-click event](config/lua/window-events/new-tab-button-click.md)
allows overriding the effect of clicking the New Tab button. #323 allows overriding the effect of clicking the New Tab button. #323
* [pane:move_to_new_window()](config/lua/pane/move_to_new_window.md),
[pane:move_to_new_tab()](config/lua/pane/move_to_new_tab.md). #3374
#### Fixed #### Fixed
* ssh ProxyCommand didn't parse command lines containing `=` correctly. #3307 * ssh ProxyCommand didn't parse command lines containing `=` correctly. #3307

View File

@ -14,6 +14,9 @@ The following arguments modify the behavior:
* `--workspace WORKSPACE` - When using `--new-window`, use `WORKSPACE` as the name of the workspace for the newly created window rather than the default workspace name `"default"`. * `--workspace WORKSPACE` - When using `--new-window`, use `WORKSPACE` as the name of the workspace for the newly created window rather than the default workspace name `"default"`.
* `--pane-id` - Specifies which pane to move. See also [Targeting Panes](index.md#targeting-panes). * `--pane-id` - Specifies which pane to move. See also [Targeting Panes](index.md#targeting-panes).
See also: [pane:move_to_new_window()](../../config/lua/pane/move_to_new_window.md),
[pane:move_to_new_tab()](../../config/lua/pane/move_to_new_tab.md).
## Synopsis ## Synopsis
```console ```console

View File

@ -0,0 +1,8 @@
# `pane:move_to_new_tab()`
{{since('nightly')}}
Creates a new tab in the window that contains `pane`, and moves `pane` into that tab.
See also [pane:move_to_new_window()](move_to_new_window.md),
[wezterm cli move-pane-to-new-tab](../../../cli/cli/move-pane-to-new-tab.md).

View File

@ -0,0 +1,14 @@
# `pane:move_to_new_window([WORKSPACE])`
{{since('nightly')}}
Creates a window and moves `pane` into that window.
The *WORKSPACE* parameter is optional; if specified, it will be used
as the name of the workspace that should be associated with the new
window. Otherwise, the current active workspace will be used.
See also [pane:move_to_new_window()](move_to_new_window.md),
[wezterm cli move-pane-to-new-tab](../../../cli/cli/move-pane-to-new-tab.md).

View File

@ -353,6 +353,32 @@ impl UserData for MuxPane {
}; };
this.get_text_from_semantic_zone(zone) this.get_text_from_semantic_zone(zone)
}); });
methods.add_async_method("move_to_new_tab", |_lua, this, ()| async move {
let mux = Mux::get();
let (_domain, window_id, _tab) = mux
.resolve_pane_id(this.0)
.ok_or_else(|| mlua::Error::external(format!("pane {} not found", this.0)))?;
let (tab, window) = mux
.move_pane_to_new_tab(this.0, Some(window_id), None)
.await
.map_err(|e| mlua::Error::external(format!("{:#?}", e)))?;
Ok((MuxTab(tab.tab_id()), MuxWindow(window)))
});
methods.add_async_method(
"move_to_new_window",
|_lua, this, workspace: Option<String>| async move {
let mux = Mux::get();
let (tab, window) = mux
.move_pane_to_new_tab(this.0, None, workspace)
.await
.map_err(|e| mlua::Error::external(format!("{:#?}", e)))?;
Ok((MuxTab(tab.tab_id()), MuxWindow(window)))
},
);
} }
} }