Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

enum libtmux-rs latest

LayoutSpec

What to arrange a window's panes as.

Source and package
Qualified name
libtmux::window::LayoutSpec
Module
window
Package
libtmux
Source
crates/libtmux/src/window.rs
enum window.LayoutSpec

Description#

A Layout names an arrangement tmux computes. A saved string is one tmux already computed: Window::layout() reports one, and handing it back restores the pane sizes, which a named layout cannot express.

From crate::since::JSON_LAYOUTS (3.8) a saved string carries each pane's id, so the restored arrangement is byte-exact, process for process. Below that release the classic checksum-prefixed string carries only sizes and positions: the shape returns, but which pane lands in which cell depends on whether the live pane list happens to already be in the saved cell order, which a mirrored or otherwise asymmetric layout can defeat. A saved string from 3.8+ is refused below it with crate::ErrorKind::UnsupportedVersion, and a value that is none of a preset name, a classic string, or JSON with crate::ErrorKind::InvalidInput, both before dispatch.

Examples#

use libtmux::Layout;
let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("restored").await?;
let mut window = session.active_window().await?.expect("a window");
// Keep what tmux reports, rearrange, then put it back exactly.
let before = window.layout().to_owned();
window.select_layout(Layout::EvenVertical).await?;
window.select_layout(&before).await?;
assert_eq!(window.layout().as_bytes(), before.as_bytes());
guard.shutdown().await?;

Variants2#

LayoutSpec variants
CasePayloadDescription
Named (Layout) An arrangement tmux knows by name.
Saved (OsString) A layout string tmux produced, restoring pane sizes exactly.
Esc

Type to search.

Reference previewOpen reference