LibTmux.Window (libtmux v0.1.3)

Copy Markdown View Source

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.

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.

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.

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

Summary

Types

t()

A physical window; session index and active-window state belong to a WindowLink.

Functions

Kills an exact window through one-shot execution.

Returns :ok when kill/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.

Returns a selection of captured physical panes in numeric pane-ID order.

Renames an exact physical window across all its memberships.

Returns :ok when rename/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.

Types

t()

@type t() :: %LibTmux.Window{
  height: LibTmux.Schema.observed(non_neg_integer()),
  id: String.t(),
  layout: LibTmux.Schema.observed(String.t()),
  name: LibTmux.Schema.observed(String.t()),
  server_instance: String.t(),
  width: LibTmux.Schema.observed(non_neg_integer()),
  zoomed: LibTmux.Schema.observed(boolean())
}

A physical window; session index and active-window state belong to a WindowLink.

Functions

kill(connection, ref, options \\ [])

Kills an exact window through one-shot execution.

Returns {:ok, result} on command completion. Optional session: session_ref requires membership in that exact session and timeout defaults to 5000ms. Killing a window removes it from every session that links it. The reference is checked against the answering server before dispatch, with the usual one-shot check/use race. A reference to something that is already gone returns {:error, %LibTmux.Action.CompletionError{}} with the original evidence. Control connections return unsupported_transport before any I/O: a connection cannot kill what it is attached to. Observations you already hold keep describing the window.

alias LibTmux.Window

Window.kill(server, window_ref)

kill!(connection, ref, options \\ [])

@spec kill!(LibTmux.Server.t(), LibTmux.Ref.t(), [LibTmux.Action.option()]) :: :ok

Returns :ok when kill/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.

panes(snapshot, window)

Returns a selection of captured physical panes in numeric pane-ID order.

Uses the supplied snapshot and validates the window's ID and incarnation. Identity, coverage, empty-selection and no-I/O behavior follow LibTmux.Session.windows/2.

Examples

iex> alias LibTmux.{Selection, Snapshot, Window}
iex> rows = %{window: [%{id: "@0"}], pane: [
...>   %{id: "%10", window_id: "@0"}, %{id: "%2", window_id: "@0"}]}
iex> {:ok, snapshot} = Snapshot.new(rows,
...>   server_instance: "example", captured_from: 0, captured_until: 0,
...>   complete: [:pane], fields: %{pane: [:id, :window_id]})
iex> {:ok, window} = Snapshot.fetch(snapshot, :window, "@0")
iex> Window.panes(snapshot, window) |> Enum.map(& &1.id)
["%2", "%10"]
iex> {:ok, pane} = Window.panes(snapshot, window)
...> |> Selection.where(id: "%2") |> Selection.one()
iex> pane.id
"%2"

rename(connection, ref, name, options \\ [])

Renames an exact physical window across all its memberships.

Returns {:ok, result} on command completion; unsuccessful outcomes return {:error, %LibTmux.Action.CompletionError{}} with their original evidence.

Names contain 1..1024 UTF-8 bytes without Unicode control characters (Cc), with literal format syntax. tmux still applies name normalization, including dollar/backslash escaping. Control characters fail before I/O on both transports. Optional session: session_ref requires membership in that exact session; it does not select a captured link index. timeout defaults to 5000ms. See LibTmux.Action for transport and outcomes.

alias LibTmux.Window

Window.rename(control, window_ref, "editor")

rename!(connection, ref, name, options \\ [])

Returns :ok when rename/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.