# window.Window

- **Module:** window
- **Package:** libtmux
- **Language:** Rust
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/window.rs#L115
- **Page:** https://libtmux.org/en/rs/latest/reference/window-window/

One tmux window, as reached through one session that links it.

A window is not owned by a single session. `link-window` makes the same
underlying window appear in several sessions at once, so discovery returns
one `Window` per link rather than per window. Two handles for the same
window reached through different sessions are **not** equal: they describe
different places in the hierarchy.

Getters that describe the window itself, such as [`Window::name`], read the
window. Getters that describe its place in a session, such as
[`Window::index`] and [`Window::is_active`], read the link.

## Example

```rust
use libtmux::SplitDirection;

let guard = libtmux::test::TestServer::new().await?;
let session = guard.server().new_session("work").await?;
let window = session.active_window().await?.expect("a session has a window");

// Splitting is detached by default, so focus stays where it was.
window.split(SplitDirection::Below).await?;
assert_eq!(window.panes().await?.len(), 2);

guard.shutdown().await?;
```

## Members

- `from_env` (method): Find the window this process is running in.
- `from_env_value` (method): Find a window from an explicit `TMUX_PANE` value.
- `id` (method): Return the tmux window identity.
- `session_id` (method): Return the session this handle reached the window through.
- `index` (method): Return the window's index within [`Window::session_id`].
- `name` (method): Return the window name.
- `pane_count` (method): Return how many panes the window contains.
- `width` (method): Return the window width in cells.
- `height` (method): Return the window height in cells.
- `layout` (method): Return the window's pane layout string.
- `is_active` (method): Report whether this window is the active one in its session.
- `is_linked` (method): Report whether the window is linked into more than one session.
- `has_activity` (method): Report whether the window has unseen activity in this session.
- `has_bell` (method): Report whether the window rang a bell in this session.
- `last_activity` (method): Return when the window last produced output.
- `is_zoomed` (method): Report whether one of the window's panes is zoomed to fill it.
- `refresh` (method): Replace this handle's snapshot with the window's current state.
- `refreshed` (method): Return a new handle holding the window's current state.
- `split` (method): Split this window and return the new pane.
- `rename` (method): Rename the window and update this handle.
- `select` (method): Make this window active in the session it was reached through.
- `select_layout` (method): Set the window's pane layout.
- `respawn` (method): Restart the window's command in place.
- `next_layout` (method): Move to the next named layout, and return the window.
- `previous_layout` (method): Move to the previous named layout, and return the window.
- `rotate` (method): Move the window's panes round one position, keeping the layout.
- `kill` (method): Kill the window, closing it in every session that links it.
- `unlink` (method): Remove this session's link to the window, leaving other links intact.
- `cmd` (method): Run a raw tmux command against this window.
- `format` (method): Expand a tmux format string in this window's context.
- `display` (method): Show a message on the clients viewing this window.
- `with_pane` (method): Create a pane, run an operation with it, then kill it.
- `swap_with` (method): Swap this window's position with another.
- `move_to` (method): Move this window to an index, possibly in another session.
- `resize_by` (method): Resize the window to an exact size in cells.
- `link_to` (method): Link this window into another session, so both hold the same window.
- `resize` (method): Resize the window to an exact size in cells.
- `get` (method): Read one field of this window's snapshot, named by the handle that filters it.
- `panes` (method): List this window's panes, preserving any failure.
- `search_panes` (method): The panes under this window that a matcher accepts, reporting why if the listing fails.
- `active_pane` (method): Return the window's active pane.
- `focus_direction` (method): Move focus one pane in this direction, and report where it landed.
- `last_pane` (method): Move to the pane that was active before this one, and return it.
- `linked_sessions` (method): The sessions this window is linked into, reporting why if it cannot.
- `session` (method): Return the session this window was reached through.
- `pane_at` (method): Find this window's pane at the given index.
- `option_names` (method): List the option names set at this window's scope.
- `options` (method): Read every option set at this window, decoded by its declared kind.
- `set_option` (method): Set one option to text, unchecked.
- `set_typed_option` (method): Set one option to a typed value, checked before it is sent.
- `append_option` (method): Append to one option rather than replacing it.
- `unset_option` (method): Remove one option, restoring whatever it inherits.
- `set_hook` (method): Set one hook to a tmux command.
- `unset_hook` (method): Remove one hook.
- `set_hooks` (method): Write a whole hook at once.
- `hook` (method): Read one hook's commands, or `None` when it holds nothing.
- `typed_option` (method): Read one option, decoded according to what tmux declares about it.
