forked from wez/wezterm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for pane swapping in Key Assignment and Lua API.
Adds a couple of variants: - SwapActivePaneDirection / tab:swap_active_pane_direction analogous to ActivatePaneDirection. - SwapActivePaneByIndex / tab:swap_active_pane_by_index analogous to ActivatePaneByIndex.
- Loading branch information
1 parent
986eac2
commit 7384a83
Showing
8 changed files
with
390 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# `tab:swap_active_pane_direction{ direction, keep_focus }` | ||
|
||
{{since('nightly')}} | ||
|
||
Swaps the active pane with the pane adjacent to it in the direction *direction*. | ||
If *keep_focus* is true, focus is retained on the currently active pane but in its | ||
new position. | ||
|
||
Valid values for *direction* are: | ||
|
||
* `"Left"` | ||
* `"Right"` | ||
* `"Up"` | ||
* `"Down"` | ||
* `"Prev"` | ||
* `"Next"` | ||
|
||
An example of usage is below: | ||
|
||
```lua | ||
local wezterm = require 'wezterm' | ||
local config = {} | ||
|
||
local function swap_active_pane_action(direction) | ||
return wezterm.action_callback(function(_window, pane) | ||
local tab = pane:tab() | ||
if tab ~= nil then | ||
tab:swap_active_pane_direction { | ||
direction = direction, | ||
keep_focus = true, | ||
} | ||
end | ||
end) | ||
end | ||
|
||
config.keys = { | ||
{ | ||
key = 'LeftArrow', | ||
mods = 'CTRL|ALT', | ||
action = swap_active_pane_action 'Prev', | ||
}, | ||
{ | ||
key = 'RightArrow', | ||
mods = 'CTRL|ALT', | ||
action = swap_active_pane_action 'Next', | ||
}, | ||
} | ||
return config | ||
``` | ||
|
||
See [ActivatePaneDirection](../keyassignment/ActivatePaneDirection.md) for more information | ||
about how panes are selected given a direction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# `tab:swap_active_pane_with_index{ pane_index, keep_focus }` | ||
|
||
{{since('nightly')}} | ||
|
||
Swaps the active pane with the pane corresponding to *pane_index*. | ||
If *keep_focus* is true, focus is retained on the currently active pane but in | ||
its new position. | ||
|
||
See [tab:panes_with_info](panes_with_info.md) for more information about how to | ||
obtain pane indexes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# `SwapActivePaneDirection` | ||
|
||
{{since('nightly')}} | ||
|
||
`SwapActivePaneDirection` swaps the active pane with the pane adjacent to it in | ||
a specific direction. | ||
|
||
See [ActivatePaneDirection](../keyassignment/ActivatePaneDirection.md) for more information | ||
about how panes are selected given a direction. | ||
|
||
The action requires two named arguments, *direction* and *keep_focus*. | ||
|
||
If *keep_focus* is true, focus is retained on the currently active pane but in its | ||
new position. | ||
|
||
Valid values for *direction* are: | ||
|
||
* `"Left"` | ||
* `"Right"` | ||
* `"Up"` | ||
* `"Down"` | ||
* `"Prev"` | ||
* `"Next"` | ||
|
||
An example of usage is below: | ||
|
||
```lua | ||
local wezterm = require 'wezterm' | ||
local act = wezterm.action | ||
local config = {} | ||
|
||
config.keys = { | ||
{ | ||
key = 'LeftArrow', | ||
mods = 'CTRL|ALT', | ||
action = act.SwapActivePaneDirection { direction = 'Prev', keep_focus = true }, | ||
}, | ||
{ | ||
key = 'RightArrow', | ||
mods = 'CTRL|ALT', | ||
action = act.SwapActivePaneDirection { direction = 'Next', keep_focus = true }, | ||
}, | ||
} | ||
return config | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# `SwapActivePaneWithIndex` | ||
|
||
{{since('20220319-142410-0fcdea07')}} | ||
|
||
`SwapActivePaneWithIndex` swaps the active pane with the pane with the specified | ||
index within the current tab. Invalid indices are ignored. | ||
|
||
This example causes CTRL-ALT-a, CTRL-ALT-b, CTRL-ALT-c to swap the current pane | ||
with the 0th, 1st and 2nd panes, respectively: | ||
|
||
```lua | ||
local wezterm = require 'wezterm' | ||
local act = wezterm.action | ||
local config = {} | ||
|
||
config.keys = { | ||
{ | ||
key = 'a', | ||
mods = 'CTRL|ALT', | ||
action = act.SwapActivePaneWithIndex { pane_index = 0, keep_focus = true }, | ||
}, | ||
{ | ||
key = 'b', | ||
mods = 'CTRL|ALT', | ||
action = act.SwapActivePaneWithIndex { pane_index = 1, keep_focus = true }, | ||
}, | ||
{ | ||
key = 'c', | ||
mods = 'CTRL|ALT', | ||
action = act.SwapActivePaneWithIndex { pane_index = 2, keep_focus = true }, | ||
}, | ||
} | ||
|
||
return config | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.