1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

move wezterm.mux.split_pane(pane, {}) to pane:split{}

refs: #1949
refs: #674
This commit is contained in:
Wez Furlong 2022-06-17 19:23:19 -07:00
parent 4c03df884b
commit 00e5b9aae6
5 changed files with 110 additions and 117 deletions

View File

@ -10,4 +10,107 @@ It has the following methods:
Returns the pane id
## `pane::split{}`
Splits `pane` and spawns a program into the split, returning the
`MuxPane` object associated with it:
```lua
local new_pane = pane:split{}
```
When no arguments are passed, the pane is split in half left/right and the
right half has the default program spawned into it.
The following parameters are supported:
### args
Specifies the argument array for the command that should be spawned.
If omitted the default program for the domain will be spawned.
```lua
pane:split{args={"top"})
```
### cwd
Specify the current working directory that should be used for
the program.
If unspecified, follows the rules from [default_cwd](config/default_cwd.md)
```lua
pane:split{cwd="/tmp"})
```
### set_environment_variables
Sets additional environment variables in the environment for
this command invocation.
```lua
pane:split{set_environment_variables={"FOO"="BAR"})
```
### domain
Specifies the multiplexer domain into which the program should
be spawned. The default value is assumed to be `"CurrentPaneDomain"`,
which causes the default domain to be used.
You may specify the name of one of the multiplexer domains
defined in your configuration using the following:
```lua
pane:split{domain={DomainName="my.name"})
```
Or you may use the default domain:
```lua
pane:split{domain="DefaultDomain"})
```
### direction
Specifies where the new pane should be placed. Possible values are:
* `"Right"` - splits the pane left/right and places the new pane on the right.
* `"Left"` - splits the pane left/right and places the new pane on the left.
* `"Top"` - splits the pane top/bottom and places the new pane on the top.
* `"Bottom"` - splits the pane top/bottom and places the new pane on the bottom.
```lua
pane:split{direction="Top"})
```
### top_level
If `true`, rather than splitting `pane` in half, the tab that contains it
is split and the new pane runs the full extent of the tab dimensions.
```lua
pane:split{direction="Bottom", top_level=true})
```
### size
Controls the size of the new pane.
Numeric values less than `1.0` are used to express a fraction of the
available space; `0.5` means `50%` of the available space, for example.
Numeric values greater or equal to `1` are used to specify the number of
cells.
The default value is `0.5`.
This creates two additional splits within `pane`, creating three
total splits that each occupy 1/3 of the available space:
```lua
pane:split{direction="Top", size=0.333})
pane:split{direction="Top", size=0.5})
```

View File

@ -21,8 +21,8 @@ local mux = wezterm.mux
wezterm.on("gui-startup", function()
local tab, pane, window = mux.spawn_window{}
mux.split_pane(pane, {size=0.3})
mux.split_pane(pane, {size=0.5})
pane:split{size=0.3}
pane:split{size=0.5}
end)
return {}

View File

@ -20,7 +20,7 @@ local mux = wezterm.mux
-- It makes a window split top/bottom
wezterm.on("mux-startup", function()
local tab, pane, window = mux.spawn_window{}
mux.split_pane(pane, {direction="Top"})
pane:split{direction="Top"}
end)
return {

View File

@ -1,106 +0,0 @@
## `wezterm.mux.split_pane(pane, {})`
*Since: nightly builds only*
Splits `pane` and spawns a program into the split, returning the
[MuxPane](../MuxPane.md) object associated with it:
```lua
local new_pane = wezterm.mux.split_pane(pane)
```
When no arguments are passed, the pane is split in half left/right and the
right half has the default program spawned into it.
The following parameters are supported:
### args
Specifies the argument array for the command that should be spawned.
If omitted the default program for the domain will be spawned.
```lua
wezterm.mux.split_pane(pane, {args={"top"})
```
### cwd
Specify the current working directory that should be used for
the program.
If unspecified, follows the rules from [default_cwd](../config/default_cwd.md)
```lua
wezterm.mux.split_pane(pane, {cwd="/tmp"})
```
### set_environment_variables
Sets additional environment variables in the environment for
this command invocation.
```lua
wezterm.mux.split_pane(pane, {set_environment_variables={"FOO"="BAR"})
```
### domain
Specifies the multiplexer domain into which the program should
be spawned. The default value is assumed to be `"CurrentPaneDomain"`,
which causes the default domain to be used.
You may specify the name of one of the multiplexer domains
defined in your configuration using the following:
```lua
wezterm.mux.split_pane(pane, {domain={DomainName="my.name"})
```
Or you may use the default domain:
```lua
wezterm.mux.split_pane(pane, {domain="DefaultDomain"})
```
### direction
Specifies where the new pane should be placed. Possible values are:
* `"Right"` - splits the pane left/right and places the new pane on the right.
* `"Left"` - splits the pane left/right and places the new pane on the left.
* `"Top"` - splits the pane top/bottom and places the new pane on the top.
* `"Bottom"` - splits the pane top/bottom and places the new pane on the bottom.
```lua
wezterm.mux.split_pane(pane, {direction="Top"})
```
### top_level
If `true`, rather than splitting `pane` in half, the tab that contains it
is split and the new pane runs the full extent of the tab dimensions.
```lua
wezterm.mux.split_pane(pane, {direction="Bottom", top_level=true})
```
### size
Controls the size of the new pane.
Numeric values less than `1.0` are used to express a fraction of the
available space; `0.5` means `50%` of the available space, for example.
Numeric values greater or equal to `1` are used to specify the number of
cells.
The default value is `0.5`.
This creates two additional splits within `pane`, creating three
total splits that each occupy 1/3 of the available space:
```lua
wezterm.mux.split_pane(pane, {direction="Top", size=0.333})
wezterm.mux.split_pane(pane, {direction="Top", size=0.5})
```

View File

@ -66,14 +66,6 @@ pub fn register(lua: &Lua) -> anyhow::Result<()> {
lua.create_async_function(|_, spawn: SpawnWindow| async move { spawn.spawn().await })?,
)?;
mux_mod.set(
"split_pane",
lua.create_async_function(|_, (pane, args): (MuxPane, Option<SplitPane>)| async move {
let args = args.unwrap_or_default();
args.run(pane).await
})?,
)?;
wezterm_mod.set("mux", mux_mod)?;
Ok(())
}
@ -327,6 +319,10 @@ impl MuxPane {
impl UserData for MuxPane {
fn add_methods<'lua, M: UserDataMethods<'lua, Self>>(methods: &mut M) {
methods.add_method("pane_id", |_, this, _: ()| Ok(this.0));
methods.add_async_method("split", |_, this, args: Option<SplitPane>| async move {
let args = args.unwrap_or_default();
args.run(this).await
});
}
}