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

add MuxTab:set_zoomed and SetPaneZoomState keyassignment

refs: #2284
This commit is contained in:
Wez Furlong 2022-07-19 05:51:48 -07:00
parent d15fd7b4db
commit 112feb3374
23 changed files with 111 additions and 54 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@
/docs/config/lua/keyassignment/index.md
/docs/config/lua/mux-events/index.md
/docs/config/lua/mux-window/index.md
/docs/config/lua/MuxTab/index.md
/docs/config/lua/pane/index.md
/docs/config/lua/wezterm.color/index.md
/docs/config/lua/wezterm.gui/index.md

View File

@ -358,7 +358,7 @@ TOC = [
Page("object: ExecDomain", "config/lua/ExecDomain.md"),
Page("object: LocalProcessInfo", "config/lua/LocalProcessInfo.md"),
Gen("object: MuxWindow", "config/lua/mux-window"),
Page("object: MuxTab", "config/lua/MuxTab.md"),
Gen("object: MuxTab", "config/lua/MuxTab"),
Page("object: MuxPane", "config/lua/MuxPane.md"),
Page("object: PaneInformation", "config/lua/PaneInformation.md"),
Page("object: TabInformation", "config/lua/TabInformation.md"),

View File

@ -364,6 +364,7 @@ pub enum KeyAssignment {
ActivatePaneDirection(PaneDirection),
ActivatePaneByIndex(usize),
TogglePaneZoomState,
SetPaneZoomState(bool),
CloseCurrentPane {
confirm: bool,
},

View File

@ -31,6 +31,7 @@ As features stabilize some brief notes about them will accumulate here.
* Hundreds of new color schemes have been imported from [base16](https://github.com/chriskempson/base16-schemes-source), [Gogh](https://gogh-co.github.io/Gogh/) and [terminal.sexy](https://terminal.sexy/). [Browse the schemes](colorschemes/index.md) and look for themes with `(base16)`, `(Gogh)` and `(terminal.sexy)` in the name to discover them!
* [pane:is_alt_screen_active()](config/lua/pane/is_alt_screen_active.md) for testing whether the alt screen is active. Thanks to [@Funami580](https://github.com/Funami580)! [#2234](https://github.com/wez/wezterm/issues/2234)
* X11/Wayland: [XDG desktop portal](https://flatpak.github.io/xdg-desktop-portal/) is now used to determine whether dark mode is in use [#2258](https://github.com/wez/wezterm/issues/2258)
* [SetPaneZoomState](config/lua/keyassignment/SetPaneZoomState.md) key assignment and [MuxTab:set_zoomed()](config/lua/MuxTab/set_zoomed.md) for explicitly setting the zoom state of a pane. [#2284](https://github.com/wez/wezterm/discussions/2284)
#### Fixed
* [ActivateKeyTable](config/lua/keyassignment/ActivateKeyTable.md)'s `replace_current` field was not actually optional. Made it optional. [#2179](https://github.com/wez/wezterm/issues/2179)

View File

@ -135,4 +135,4 @@ Returns the [MuxWindow](mux-window/index.md) that contains the tab that contains
*Since: nightly builds only*
Returns the [MuxTab](MuxTab.md) that contains this pane.
Returns the [MuxTab](MuxTab/index.md) that contains this pane.

View File

@ -0,0 +1,7 @@
# tab:get_title()
*Since: nightly builds only*
Returns the tab title as set by `tab:set_title()`.

View File

@ -0,0 +1,8 @@
# MuxTab
*Since: 20220624-141144-bd1b7c5d*
`MuxTab` represents a tab that is managed by the multiplexer.
It has the following methods:

View File

@ -0,0 +1,8 @@
# tab:panes()
*Since: nightly builds only*
Returns an array table containing the set of [MuxPane](../MuxPane.md) objects
contained by this tab.

View File

@ -1,46 +1,4 @@
# MuxTab
*Since: 20220624-141144-bd1b7c5d*
`MuxTab` represents a tab that is managed by the multiplexer.
It has the following methods:
## `tab:tab_id()`
Returns the tab id
## tab:get_title()
*Since: nightly builds only*
Returns the tab title as set by `tab:set_title()`.
## tab:set_title(TITLE)
*Since: nightly builds only*
Sets the tab title to the provided string.
```lua
tab:set_title("my title")
```
## tab:window()
*Since: nightly builds only*
Returns the [MuxWindow](mux-window/index.md) object that contains this tab.
## tab:panes()
*Since: nightly builds only*
Returns an array table containing the set of [MuxPane](MuxPane.md) objects
contained by this tab.
## tab:panes_with_info()
# tab:panes_with_info()
*Since: nightly builds only*
@ -58,5 +16,6 @@ Each element is a lua table with the following fields:
* `height` - The height of this pane in cells
* `pixel_width` - The width of this pane in pixels
* `pixel_height` - The height of this pane in pixels
* `pane` - The [MuxPane](MuxPane.md) object
* `pane` - The [MuxPane](../MuxPane.md) object

View File

@ -0,0 +1,11 @@
# tab:set_title(TITLE)
*Since: nightly builds only*
Sets the tab title to the provided string.
```lua
tab:set_title("my title")
```

View File

@ -0,0 +1,17 @@
# tab:set_zoomed(bool)
*Since: nightly builds only*
Sets the zoomed state for the active pane within this tab.
A zoomed pane takes up all available space in the tab, hiding all other panes
while it is zoomed. Switching its zoom state off will restore the prior split
arrangement.
Setting the zoom state to true zooms the pane if it wasn't already zoomed.
Setting the zoom state to false un-zooms the pane if it was zoomed.
Returns the prior zoom state.
See also: [`unzoom_on_switch_pane`](../config/unzoom_on_switch_pane.md),
[SetPaneZoomState](../keyassignment/SetPaneZoomState.md).

View File

@ -0,0 +1,6 @@
# `tab:tab_id()`
*Since: 20220624-141144-bd1b7c5d*
Returns the tab id

View File

@ -0,0 +1,6 @@
# tab:window()
*Since: nightly builds only*
Returns the [MuxWindow](../mux-window/index.md) object that contains this tab.

View File

@ -0,0 +1,14 @@
# SetPaneZoomState(bool)
*Since: nightly builds only*
Sets the zoom state of the current pane. A Zoomed pane takes up
all available space in the tab, hiding all other panes while it is zoomed.
Switching its zoom state off will restore the prior split arrangement.
Setting the zoom state to true zooms the pane if it wasn't already zoomed.
Setting the zoom state to false un-zooms the pane if it was zoomed.
See also: [`unzoom_on_switch_pane`](../config/unzoom_on_switch_pane.md),
[TogglePaneZoomState](TogglePaneZoomState.md),
[MuxTab:set_zoomed()](../MuxTab/set_zoomed.md).

View File

@ -16,4 +16,4 @@ return {
}
```
See also: [`unzoom_on_switch_pane`](../config/unzoom_on_switch_pane.md)
See also: [`unzoom_on_switch_pane`](../config/unzoom_on_switch_pane.md), [SetPaneZoomState](SetPaneZoomState.md).

View File

@ -3,7 +3,7 @@
*Since: 20220624-141144-bd1b7c5d*
Spawns a program into a new tab within this window, returning the
[MuxTab](../MuxTab.md), [MuxPane](../MuxPane.md) and
[MuxTab](../MuxTab/index.md), [MuxPane](../MuxPane.md) and
[MuxWindow](index.md) objects associated with it:
```lua

View File

@ -2,7 +2,7 @@
*Since: nightly builds only*
Returns an array table holding each of the [MuxTab](../MuxTab.md) objects
Returns an array table holding each of the [MuxTab](../MuxTab/index.md) objects
contained within this window.

View File

@ -9,5 +9,5 @@ Each element is a lua table with the following fields:
* `index` - the 0-based tab index
* `is_active` - a boolean indicating whether this is the active tab within the window
* `tab` - the [MuxTab](../MuxTab.md) object
* `tab` - the [MuxTab](../MuxTab/index.md) object

View File

@ -3,7 +3,7 @@
*Since: 20220624-141144-bd1b7c5d*
Given a tab ID, verifies that the ID is a valid tab known to the mux
and returns a [MuxTab](../MuxTab.md) object that can be used to
and returns a [MuxTab](../MuxTab/index.md) object that can be used to
operate on the tab.
This is useful for situations where you have obtained a tab id from

View File

@ -2,7 +2,7 @@
*Since: 20220624-141144-bd1b7c5d*
Spawns a program into a new window, returning the [MuxTab](../MuxTab.md),
Spawns a program into a new window, returning the [MuxTab](../MuxTab/index.md),
[MuxPane](../MuxPane.md) and [MuxWindow](../mux-window/index.md) objects
associated with it:

View File

@ -524,6 +524,14 @@ impl UserData for MuxTab {
.map(|info| MuxPane(info.pane.pane_id()))
.collect::<Vec<MuxPane>>())
});
methods.add_method("set_zoomed", |_, this, zoomed: bool| {
let mux = get_mux()?;
let tab = this.resolve(&mux)?;
let was_zoomed = tab.set_zoomed(zoomed);
Ok(was_zoomed)
});
methods.add_method("panes_with_info", |lua, this, _: ()| {
let mux = get_mux()?;
let tab = this.resolve(&mux)?;

View File

@ -593,13 +593,15 @@ impl Tab {
}
}
pub fn set_zoomed(&self, zoomed: bool) {
/// Sets the zoom state, returns the prior state
pub fn set_zoomed(&self, zoomed: bool) -> bool {
if self.zoomed.borrow().is_some() == zoomed {
// Current zoom state matches intended zoom state,
// so we have nothing to do.
return;
return zoomed;
}
self.toggle_zoom();
!zoomed
}
pub fn toggle_zoom(&self) {

View File

@ -2388,6 +2388,14 @@ impl TermWindow {
};
tab.toggle_zoom();
}
SetPaneZoomState(zoomed) => {
let mux = Mux::get().unwrap();
let tab = match mux.get_active_tab_for_window(self.mux_window_id) {
Some(tab) => tab,
None => return Ok(()),
};
tab.set_zoomed(*zoomed);
}
SwitchWorkspaceRelative(delta) => {
let mux = Mux::get().unwrap();
let workspace = mux.active_workspace();