# LibTmux.Window

- **Module:** LibTmux
- **Package:** libtmux
- **Language:** Elixir
- **Kind:** struct
- **Source:** https://github.com/libtmux/libtmux-elixir/blob/5bacf40788b43a5af27bb3656e727a921ba2db40/lib/libtmux/entities.ex#L217
- **Page:** https://libtmux.org/en/elixir/pr-173/reference/libtmux-window/

An immutable physical window with explicit actions, independent of session membership and index.

## What is on here

A Window is a physical window captured in a `LibTmux.Snapshot`. Its session
index and active state belong to a `LibTmux.WindowLink`, so one Window can
belong to several sessions. Start with these groups:

**Finding the window.** Select windows from a captured snapshot, or look one
up by its exact ID. Neither contacts tmux. An ID that was not captured returns
`{:error, error}` with kind `:not_found`. Turn the window into a reference
tied to the server incarnation that supplied it, ready for an action.

- Select: `LibTmux.Snapshot.windows/1`
- By ID: `LibTmux.Snapshot.fetch/3`
- Reference: `LibTmux.Ref.from_observation/1`

**Looking inside a window.** Read its panes from the snapshot, in numeric
pane-ID order and without I/O. An invalid or stale identity, or a relationship
the snapshot did not capture, raises `LibTmux.Error`. To find the sessions
that hold the window, select its links.

- Panes: `panes/2`
- Links: `LibTmux.Snapshot.window_links/1`

**Renaming.** Rename the window across all its memberships through a Server or
a Control connection. A name holds 1..1024 UTF-8 bytes with no control
characters, and tmux still normalizes it. The optional `session:` reference
requires membership in that session; it does not pick a link index.

- Rename: `rename/4`
- Raise on failure: `rename!/4`

**Sharing.** Link this physical window at a specific session index through
a Server. Use `LibTmux.WindowLink.unlink/3` to remove one membership.

- Link: `link/5`
- Raise on failure: `link!/5`

**Resizing.** Set this physical window's width or height in cells through
either transport. Read a fresh snapshot to observe the result.

- Resize: `resize/3`
- Raise on failure: `resize!/3`

**Killing.** Kill the window, with its panes, in every session that links it,
through a Server. A Control connection returns `unsupported_transport`.

- Kill: `kill/3`
- Raise on failure: `kill!/3`

## Members

### Collections and queries

- [`panes/2`](/en/elixir/pr-173/reference/libtmux-window-panes-2/) (function): Returns a selection of captured physical panes in numeric pane-ID order.

### Common operations

- [`id`](/en/elixir/pr-173/reference/libtmux-window-id/) (property): Required: building the struct without this key is an error.
- [`name`](/en/elixir/pr-173/reference/libtmux-window-name/) (property)
- [`height`](/en/elixir/pr-173/reference/libtmux-window-height/) (property)
- [`width`](/en/elixir/pr-173/reference/libtmux-window-width/) (property)
- [`layout`](/en/elixir/pr-173/reference/libtmux-window-layout/) (property)
- [`rename!/4`](/en/elixir/pr-173/reference/libtmux-window-rename-bang-4/) (function): Returns `:ok` when `rename/4` completes; raises API errors or `LibTmux.Action.CompletionError` otherwise.
- [`rename/4`](/en/elixir/pr-173/reference/libtmux-window-rename-4/) (function): Renames an exact physical window across all its memberships.
- [`zoomed`](/en/elixir/pr-173/reference/libtmux-window-zoomed/) (property)

### Other members

- [`kill!/3`](/en/elixir/pr-173/reference/libtmux-window-kill-bang-3/) (function): Returns `:ok` when `kill/3` completes; raises API errors or `LibTmux.Action.CompletionError` otherwise.
- [`kill/3`](/en/elixir/pr-173/reference/libtmux-window-kill-3/) (function): Kills an exact window through one-shot execution.
- [`link!/5`](/en/elixir/pr-173/reference/libtmux-window-link-bang-5/) (function): Returns `:ok` for a completed link or raises the action error.
- [`link/5`](/en/elixir/pr-173/reference/libtmux-window-link-5/) (function): Links an exact physical window at the given index in an exact session.
- [`resize!/3`](/en/elixir/pr-173/reference/libtmux-window-resize-bang-3/) (function): Returns `:ok` for a completed window resize or raises the action error.
- [`resize/3`](/en/elixir/pr-173/reference/libtmux-window-resize-3/) (function): Requests an absolute width, height or both for an exact physical window.
- [`server_instance`](/en/elixir/pr-173/reference/libtmux-window-server_instance/) (property): Required: building the struct without this key is an error.
- [`t/0`](/en/elixir/pr-173/reference/libtmux-window-t-0/) (typealias): A physical window; session index and active-window state belong to a WindowLink.

## In other ports

A tmux window

| Port | API | Differs from Elixir |
| --- | --- | --- |
| Elixir | `LibTmux.Window`. An immutable physical window with explicit actions, independent of session membership and index. | This page |
| Python | [`libtmux.Window`](/en/py/latest/reference/libtmux-window/) (class). tmux(1) Window [window_manual]. | None recorded in the model |
| Ruby | [`LibTmux::Window`](/en/ruby/latest/reference/libtmux-window-1vfx/) (class). A physical window on one server, reached through a handle that wraps an EntityRef. Its index and whether it is current belong to a WindowLink, so one window can sit in several sessions. Methods take timeout: and cancel:, and raise CommandError when tmux rejects the command. | None recorded in the model |
| Lua | [`libtmux.Window`](/en/lua/latest/reference/libtmux-window/) (class) | None recorded in the model |
| PowerShell | [`LibTmux\Get-TmuxWindow`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/) (cmdlet). Read contextual windows from a server or session. | 2 overloads. This cmdlet reads shared .NET `LibTmux.Window` placements. Use [`-Server`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/#LibTmux%5CGet-TmuxWindow.parameter.Server) for all sessions or [`-Session`](/en/powershell/latest/reference/libtmux-get-tmuxwindow/#LibTmux%5CGet-TmuxWindow.parameter.Session) for one session. |
| Julia | [`LibTmux.WindowSnapshot`](/en/julia/latest/reference/libtmux-windowsnapshot/) (struct) | 2 overloads. `WindowSnapshot` holds captured physical-window data. `WindowLink` records a placement in a session; actions use `WindowRef`. |
| Erlang | [`#tmux_model:window{}`](/en/erlang/latest/reference/tmux_model-window/) (struct) | A physical window can have several session memberships. `window_link` holds the session-relative index and active flag. |
| Haskell | [`LibTmux.Snapshot.Window`](/en/haskell/latest/reference/libtmux-snapshot-t-window/) (data-type). Detached physical window, independent of its session and index appearances. | `Window` is a detached physical window, independent of its session placements. `WindowLink` records each session, index and window binding, and operations take a generation-bound `WindowRef`. |
| Common Lisp | [`libtmux:window`](/en/lisp/latest/reference/libtmux-window-type/) (class). A physical window shared by zero or more captured links. | `window` is a physical captured window. `window-link` preserves each session placement. |
| TypeScript | [`window.Window`](/en/ts/latest/reference/window-window/) (class). One window on one tmux server, as a handle rather than a copy of it. | None recorded in the model |
| Rust | [`window.Window`](/en/rs/latest/reference/window-window/) (struct). One tmux window, as reached through one session that links it. | None recorded in the model |
| Go | [`tmux.Window`](/en/go/latest/reference/tmux-window/) (struct). Window is one materialized (session, index, window) winlink record. It is normally returned by Server.Snapshot, Server.Window, or Window.Refresh. A zero Window is not a usable tmux target. | None recorded in the model |
| Java | [`io.github.libtmux.Window`](/en/java/latest/reference/io-github-libtmux-window-window/) (class). One tmux window at one of its positions, as one capture saw it. | readonly |
| Clojure | [`libtmux.data/windows`](/en/clojure/latest/reference/libtmux-data-windows/) (function). Returns the captured window occurrences in a snapshot or session. | Traverses captured window-placement maps without I/O; the window value is a map with an explicit Java reference for effects. |
| Kotlin | [`io.github.libtmux.kotlin.Window`](/en/kotlin/latest/reference/io-github-libtmux-kotlin-window/) (class). A tmux window at a specific position in a session. | None recorded in the model |
| Scala | [`io.github.libtmux.scaladsl.Window`](/en/scala/latest/reference/io-github-libtmux-scaladsl-window/) (typealias). One captured window placement, opaque over the Java handle. Equality includes its session and index, since a window linked into more than one session has more than one placement. Every operation beyond equality is an extension, generated from the operation catalog or handwritten where the catalog marks it WAIT, STREAM or LIFECYCLE. | 2 overloads |
| C# | [`LibTmux.Window`](/en/csharp/latest/reference/libtmux-window/) (class). Represents an immutable window handle and snapshot. | None recorded in the model |
| F# | [`LibTmux.FSharp.Window`](/en/fsharp/latest/reference/libtmux-fsharp-window/) (module). Identifies window placements and starts queries confined to one window. | This F# module identifies shared .NET `LibTmux.Window` placements and builds deferred pane queries. `Query.list` acquires their results from tmux. |
| C++ | [`libtmux::Window`](/en/cxx/latest/reference/libtmux-window/) (class). One window, as one listing saw it. | None recorded in the model |
| Swift | [`Window`](/en/swift/latest/reference/window/) (struct). One tmux window, independent of every session that links it. | None recorded in the model |
| OCaml | [`Libtmux.Window.t`](/en/ocaml/latest/reference/libtmux-window-t/) (typealias) | A global window can have several session placements. Window_link holds the session, index and current flag. |
| Perl | [`LibTmux::Window`](/en/perl/latest/reference/libtmux-window/) (class). Captured window entity | Physical window identity. WindowLink owns each session/index placement. |
| Raku | [`LibTmux::Model::Window`](/en/raku/latest/reference/libtmux-model-window/) (class). Captured physical window; session-relative indices belong to WindowLink. | A physical window may have multiple WindowLink placements, including distinct indexes in one session. |
