An immutable physical pane with explicit actions. It belongs to a window; text may be empty.
What is on here
A Pane is a value captured in a LibTmux.Snapshot. Actions take a
LibTmux.Ref and a Server or Control connection. Start with these groups:
Finding the pane. Select panes 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 pane into a reference tied
to the server incarnation that supplied it, ready for an action.
- Select:
LibTmux.Snapshot.panes/1 - By ID:
LibTmux.Snapshot.fetch/3 - Reference:
LibTmux.Ref.from_observation/1
Splitting. Split the pane and get the new pane's ID in the completed value.
A qualified Control connection also returns a bound reference; one-shot
execution returns ref: nil. The defaults are a vertical, detached split at
half size; options set the axis, size, directory and command.
Sending input. Send literal bytes, up to 995 of them, without interpreting
key names, or send named keys such as "Enter" and "C-c". An unknown key
name is rejected. Acknowledgement does not prove the program consumed the
input.
- Literal bytes:
send_text/4,send_text!/4 - Named keys:
send_keys/4,send_keys!/4
Reading the screen. Capture the rendered screen through one-shot
execution; a Control connection returns unsupported_transport. Output over
the byte limit is an error, never a partial screen. This reads screen state,
not the program's original output stream.
- Capture:
capture/3 - Raise on failure:
capture!/3
Killing. Kill the pane through a Server. A Control connection returns
unsupported_transport. Killing the last pane of a window removes the window.
Summary
Types
Bounded one-shot screen capture; line numbers are relative to the visible screen, with negative history offsets.
Split geometry and process arguments.
A created pane ID; ref is bound for qualified control and nil for one-shot.
A physical pane; PID and exit status can be known absent, with separate coverage sentinels.
Functions
Captures bounded screen bytes through explicit one-shot execution.
Returns screen bytes when capture/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
Kills an exact pane through one-shot execution.
Returns :ok when kill/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
Sends 1..128 named keys to an exact pane; unknown names are rejected.
Returns :ok when send_keys/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
Sends 0..995 literal bytes to an exact pane, without interpreting key names.
Returns :ok when send_text/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
Splits an exact pane and returns its ID and optional bound reference as value.
Returns the created pane value when split/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
Types
@type capture_option() :: LibTmux.Action.option() | {:start_line, -32768..32767} | {:end_line, -32768..32767 | :last} | {:join_lines, boolean()} | {:max_bytes, 0..1_048_576}
Bounded one-shot screen capture; line numbers are relative to the visible screen, with negative history offsets.
@type split_option() :: LibTmux.Action.option() | {:axis, :horizontal | :vertical} | {:size, {:cells, 1..32767} | {:percent, 1..99}} | {:before | :detached, boolean()} | {:cwd, binary()} | {:command, :default | :empty | {:shell, binary()} | {:argv, [binary(), ...]}}
Split geometry and process arguments.
@type split_value() :: %{id: String.t(), ref: LibTmux.Ref.t() | nil}
A created pane ID; ref is bound for qualified control and nil for one-shot.
@type t() :: %LibTmux.Pane{ active: LibTmux.Schema.observed(boolean()), current_command: LibTmux.Schema.observed(String.t()), current_path: LibTmux.Schema.observed(String.t()), dead: LibTmux.Schema.observed(boolean()), exit_status: LibTmux.Schema.observed(non_neg_integer() | nil), height: LibTmux.Schema.observed(non_neg_integer()), id: String.t(), index: LibTmux.Schema.observed(non_neg_integer()), pid: LibTmux.Schema.observed(non_neg_integer() | nil), server_instance: String.t(), title: LibTmux.Schema.observed(String.t()), width: LibTmux.Schema.observed(non_neg_integer()), window_id: LibTmux.Schema.observed(String.t()) }
A physical pane; PID and exit status can be known absent, with separate coverage sentinels.
pid is nil when tmux reports no PID. A reported PID or its absence does
not establish process liveness or cleanup.
Functions
@spec capture(LibTmux.Action.connection(), LibTmux.Ref.t(), [capture_option()]) :: {:ok, LibTmux.Action.result(binary())} | {:error, LibTmux.Error.t() | LibTmux.Action.CompletionError.t()}
Captures bounded screen bytes through explicit one-shot execution.
Returns {:ok, result} with bytes as value after acknowledged completion
and native retirement. Failed commands return
{:error, %LibTmux.Action.CompletionError{}} with their original evidence.
Defaults: visible lines 0 through :last, no line joining, 65536 stdout
bytes, 65536 stderr bytes and 5000ms. :last is accepted only for end_line.
Negative line numbers include history;
tmux clamps the requested range to available lines. Output overflow is an
error, never a successful partial screen. This observes rendered screen
state, not the program's original output stream.
A Control argument returns unsupported_transport: arbitrary screen bytes
are not qualified for shared control framing. No fallback occurs.
alias LibTmux.Pane
Pane.capture(server, pane_ref, start_line: -100, max_bytes: 131_072)
@spec capture!(LibTmux.Action.connection(), LibTmux.Ref.t(), [capture_option()]) :: binary()
Returns screen bytes when capture/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
@spec kill(LibTmux.Server.t(), LibTmux.Ref.t(), [LibTmux.Action.option()]) :: {:ok, LibTmux.Action.result(:ok)} | {:error, LibTmux.Action.error()}
Kills an exact pane through one-shot execution.
Returns {:ok, result} on command completion. Optional session: session_ref requires the pane's window to belong to that exact session and timeout defaults to 5000ms. 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 pane.
alias LibTmux.Pane
Pane.kill(server, pane_ref)
@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.
@spec send_keys(LibTmux.Action.connection(), LibTmux.Ref.t(), [String.t()], [ LibTmux.Action.option() ]) :: {:ok, LibTmux.Action.result(:ok)} | {:error, LibTmux.Action.error()}
Sends 1..128 named keys to an exact pane; unknown names are rejected.
Supports Enter, Space, Tab, BTab, BSpace, Escape, arrows, Home, End, PageUp,
PageDown, Insert, Delete and F1..F12. Distinct C-, M- and S- modifiers may
prefix arrows, Home/End, PageUp/PageDown, Insert/Delete and F1..F12. Also
accepts C-a..C-z, conventional ASCII control punctuation, and M- plus one
printable ASCII character. Unsupported combinations such as S-a and C-Enter
fail before admission; tmux could otherwise type their spelling as text.
Options and outcomes follow LibTmux.Action.
alias LibTmux.Pane
Pane.send_keys(control, pane_ref, ["Enter", "C-c"])
@spec send_keys!(LibTmux.Action.connection(), LibTmux.Ref.t(), [String.t()], [ LibTmux.Action.option() ]) :: :ok
Returns :ok when send_keys/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
@spec send_text(LibTmux.Action.connection(), LibTmux.Ref.t(), binary(), [ LibTmux.Action.option() ]) :: {:ok, LibTmux.Action.result(:ok)} | {:error, LibTmux.Action.error()}
Sends 0..995 literal bytes to an exact pane, without interpreting key names.
Hex-key encoding preserves NUL and invalid UTF-8. Empty input sends nothing.
Both transports use the same limit, fitting tmux 3.8's command argument
ceiling. Larger inputs fail validation before I/O; calls are never split.
The terminal's line discipline, active mode and application still determine
how input is handled; acknowledgement does not prove program consumption.
Options and outcomes follow LibTmux.Action. For named keys use send_keys/4.
alias LibTmux.Pane
Pane.send_text(control, pane_ref, "printf 'hello'")
@spec send_text!(LibTmux.Action.connection(), LibTmux.Ref.t(), binary(), [ LibTmux.Action.option() ]) :: :ok
Returns :ok when send_text/4 completes; raises API errors or LibTmux.Action.CompletionError otherwise.
@spec split(LibTmux.Action.connection(), LibTmux.Ref.t(), [split_option()]) :: {:ok, LibTmux.Action.result(split_value())} | {:error, LibTmux.Action.error()}
Splits an exact pane and returns its ID and optional bound reference as value.
A completed value contains id and ref. Qualified control binds the reference.
Use it for another action without recapturing. It identifies the pane in
that server incarnation, contains no fresh fields and does not reserve its
lifetime. Closing the connection does not invalidate the reference while
the pane and server remain. One-shot execution does not establish this
binding and returns ref: nil. Unsuccessful outcomes return
{:error, %LibTmux.Action.CompletionError{}} with the original result.
Defaults: vertical split, half size, detached, after the target, and tmux's
session default shell/command and directory. axis: :horizontal places panes
side by side; size: {:percent, n} uses -l n% on every supported release.
Optional cwd is literal format text. Choose command: :default, :empty,
{:shell, nonempty_bytes} or {:argv, [program | arguments]}. Shell text
uses the session's configured shell; argv uses execvp semantics, including
PATH lookup and executable-text fallback. Empty argv/program and empty
explicit shell text are rejected. At most 64 argv entries and the existing
command byte bounds apply; bytes must be NUL-free.
Singleton argv uses the packaged helper to preserve exactly one argument.
It replaces itself with the pane program. tmux retains the helper path in
pane_start_command; commandless respawn requires that installation to
remain available. See command forms.
Split acknowledgement does not prove program startup or completion.
session: session_ref selects exact membership/context, not a WindowLink
index. timeout defaults to 5000ms. No snapshot is changed; capture again
when a new observation is needed. See LibTmux.Action for outcomes and the
one-shot identity check/use limitation.
alias LibTmux.Pane
{:ok, %{value: %{ref: created}}} =
Pane.split(control, pane_ref, axis: :horizontal, size: {:percent, 30})
Pane.send_text(control, created, "hello")
@spec split!(LibTmux.Action.connection(), LibTmux.Ref.t(), [split_option()]) :: split_value()
Returns the created pane value when split/3 completes; raises API errors or LibTmux.Action.CompletionError otherwise.