Core LibraryalphaAPI 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.

API reference

Browse the C++ types and operations for working with tmux. Start with the core objects below, or search for a type or member.

Server 4 types, 4 functions and constants
Server class 58 members

One tmux server, addressed by the socket it listens on.

ServerImplementation enum 3 members

Which server answered: tmux, a compatible reimplementation, or not yet determined.

ServerFeature enum 12 members

Coarse-grained promises callers choose around.

ServerCapabilities struct 4 members

What this server is known to support, decided without asking it.

Reads LIBTMUX_SOCKET_PATH, then LIBTMUX_SOCKET.

-L name: a single component resolved under the socket directory.

-S path: used verbatim, so the address limit applies to it directly.

Session 3 types, 12 functions and constants
Session class 33 members

One session, as one listing saw it.

An entity formats as it prints.

Hashing an entity uses exactly what its equality compares, so values from separate listings key an unordered container consistently.

SessionId type alias

Distinct types, not aliases of one: Kind is only ever named here.

attached attribute
client_count attribute
created attribute In libtmux::session

tmux renders a timestamp as epoch seconds, which is what a filter compares and what -f would compare on the server.

group attribute
grouped attribute
id attribute In libtmux::session
name attribute In libtmux::session
path attribute In libtmux::session
window_count attribute
is_session_id function

A session target is its id, or its validated name.

Window 3 types, 17 functions and constants
Window class 44 members

One window, as one listing saw it.

Hashing a window, on the same terms as its equality.

WindowId type alias
active attribute In libtmux::window
activity attribute
bell attribute
height attribute In libtmux::window
id attribute In libtmux::window
index attribute In libtmux::window
layout attribute
name attribute In libtmux::window
pane_count attribute
session_id attribute In libtmux::window
session_name attribute In libtmux::window
width attribute In libtmux::window
zoomed attribute
is_window_id function
window_target function

A window target is its id, which needs no session, or session:window.

Pane 3 types, 26 functions and constants
Pane class 58 members

One pane, as one listing saw it.

Hashing a pane, on the same terms as its equality.

PaneId type alias
active attribute In libtmux::pane
at_bottom attribute
at_left attribute
at_right attribute
at_top attribute
command attribute
dead attribute
exit_status attribute

A pane that has not exited reads -1, which tmux cannot report: the field is WEXITSTATUS and so is 0 through 255, or empty.

height attribute In libtmux::pane
id attribute In libtmux::pane
in_mode attribute
index attribute In libtmux::pane
left attribute
path attribute In libtmux::pane
pid attribute In libtmux::pane
piping attribute
session_id attribute In libtmux::pane
session_name attribute In libtmux::pane
title attribute
top attribute
tty attribute In libtmux::pane
width attribute In libtmux::pane
window_id attribute In libtmux::pane
is_pane_id function

Whether a value is written as an id, which is what decides that it needs no separator validation below — not whether tmux would resolve it.

pane_target function

A pane target is its id, or session:window.pane.

Client 3 types, 14 functions and constants
Client class 21 members

One attached client, as one listing saw it.

Hashing a client, on the same terms as its equality.

active_pane_id attribute
control_mode attribute
created attribute In libtmux::client
flags attribute
height attribute In libtmux::client
last_activity attribute
name attribute In libtmux::client
pid attribute In libtmux::client
read_only attribute
session_name attribute In libtmux::client
terminal attribute
tty attribute In libtmux::client
width attribute In libtmux::client
window_id attribute In libtmux::client
Options 2 types
EnvironmentEntry struct 2 members

One name in the environment tmux gives processes it starts.

OptionEntry struct 4 members

One option as tmux reports it: its name, its value, and the array index it sits at when it is an array option.

Options — Functions 3 functions and constants
parse_option function

Parse one line.

parse_options function
unquote function

Undo the quoting tmux applies when it prints a value.

Keys and bindings 4 functions and constants
kNamedKeys attribute

Named keys tmux accepts, taken from the table in its own key-string.c at the oldest supported release.

is_key_name function

Accept a key with any number of C-, M-, or S- modifiers.

Send text exactly as written: the flag, the end of flags, and the text.

Buffers 1 type, 4 functions and constants
Buffer class 9 members

A named piece of text the server holds, outliving the pane it came from.

created attribute In libtmux::buffer

Epoch seconds, as tmux renders it and as -f would compare it; the accessor beside this one answers sys_seconds because that is what a caller holds.

name attribute In libtmux::buffer
sample attribute
size attribute
Layout and geometry 1 type, 1 function or constant
LayoutFailure struct 2 members

Check names, v1 saved-layout checksum, v1/v2 tree grammar and minimum cell count without I/O.

Environment 1 type
EnvironmentSocket struct 3 members

The socket the environment selects, or none.

Terminal capabilities 1 function or constant
to_string function
Versions 1 type, 9 functions and constants
Version struct 6 members

A tmux version, ordered so a feature gate can compare against a literal.

The oldest release this library supports: 3.3a.

The floor as the messages name it; parse_version() reads it back as kMinimumSupported.

The same version, available to the preprocessor.

is_supported function

This package's own version, not tmux's.

parse_version function

Parse the first line of tmux -V, with or without its trailing newline.

Commands 16 types, 5 functions and constants
AttachCommand class 3 members

An attach argv and the private route selecting this server incarnation.

Command class 6 members

One command this tmux understands.

CommandArgument class 6 members

One argument, carrying whether any part of it is a secret.

CommandBatch class 6 members

The argv a chain becomes: commands joined by tmux's separator.

CommandExecutor class 3 members

A transport a caller supplies.

CommandOperation class 7 members

Move-only result handle for one admitted command; its methods are not concurrent.

CommandRuntime class 11 members

Move-only owner of the transport threads, admission bound, and observations.

ReadyStatus enum 3 members
ArgumentSensitivity enum 2 members

Whether an argument may appear in a diagnostic, a log, or an error message.

WaitPath enum 6 members

Which path answered the wait.

CommandFailure struct 4 members

A command that did not produce an answer, and how far it got.

CommandReport struct 4 members

Told about every command, as it finishes.

CommandRuntimeConfig struct 1 member

The maximum number of accepted commands retaining any lifecycle leg.

CommandRuntimeShutdown struct 5 members

The first successful close() report; every later call returns this value.

ExecutionPolicy struct 3 members

What a call waits and holds when the caller did not say.

Formatting a failure is how it reaches a log line, so the type every call can return knows how to write itself.

CommandObserver type alias

Every member expires on return; a caller keeping any of it copies it.

alias attribute
name attribute In libtmux::command
usage attribute
Control mode 10 types, 4 functions and constants
Connection class 15 members

One held-open control client.

NotificationRange class 3 members

Everything tmux says, until the deadline, as one loop.

iterator class 4 members

Single-pass, and the value it yields is borrowed: advancing invalidates the notification the previous dereference viewed.

NotificationWatch class 6 members

One independent view of outside-block events emitted after opening.

Parser class 3 members

The control-mode wire format, decoded into whole events.

ControlTerminal enum 2 members

How tmux closed a reply block: normally, or reporting a failure.

ControlBlock struct 8 members

One reply block, framed between tmux's begin and its terminator.

ControlCommand struct 1 member

One command as argv, before it is joined into a control-mode line.

Notification struct 1 member

One control event tmux sent unprompted, still as bytes.

ParsedNotification struct 8 members

A notification's arguments, as views into the notification it was read from.

How much of one reply a decoder holds, and how long a single line may grow before the stream is called broken.

Whether pane_id (%N) is still part of a window's arrangement, reading a NotificationKind::layout_change notification's own text — window_layout followed by window_visible_layout and the window's flags (control-notify.c) — for its first, whitespace-delimited token.

parse function
Formats 2 types, 4 functions and constants
FormatBuilder class 3 members

Build a format from alternating literal and variable pieces so a caller never hand-concatenates and forgets to escape one of them.

FormatArgument enum 2 members

Where a tmux subcommand wants its format string.

kFormatEscape attribute

A separator absent from every format name is not absent from every format value, which is the whole difficulty.

tmux joins requested formats with a separator that cannot appear in a format name.

Escape literal text for inclusion in a format string.

variable function

Wrap a variable name as a substitution.

Queries 1 type, 21 functions and constants
Group struct 2 members

Several expressions combined, all of them or any of them.

Referenced type alias

A borrowed element of a range, rather than a copy of it.

RelatedMany type alias

The related entity is whatever the accessor yields, so a bare flag field can stand in for a predicate here exactly as it does in matching().

RelatedOne type alias

The entity on the far side of a to-one link, with the accessor's indirection and qualifiers stripped away.

all_of function
any_of function
children_of function

Join two listings on the id one of them carries.

exactly_one function

exactly_one() states that several is a caller error, and says which one.

A forward range's iterator can be copied and advanced independently of the original, so a second element rules the range out before the first is materialized.

first function

first() states that a caller tolerates extras; it never reports several.

first_owned function

Copies referenced elements; moves when an iterator yields an rvalue.

is function

An absent to-one link never satisfies is(): a window with no active pane is not a window whose active pane runs an editor.

lookup_of function

eq is the implicit lookup, matching Python's bare field=value.

lower function

A sink receives one call per node in prefix order.

matching function In libtmux

matching(expr) is a range adaptor closure so it composes with std views.

matching function In libtmux::tmuxq

matching(expr) is a range adaptor closure so it composes with std views.

name_of function
none_of function
parent_of function

The same join read the other way: the one row a child points at, or none.

parse_lookup function

Parse one field[__lookup]=value term against a caller-supplied field table.

quantified function

To-many and to-one links take different accessors, so they get different builders rather than one that has to compile both shapes.

replay function

Replay an already-lowered child into a sink.

Queries — Fields 6 types
BoolField struct 2 members

A flag on an entity, named for the expression and read through a function pointer rather than a member pointer so the same descriptor works for a field computed from several tmux tokens.

BoolFieldHandle struct 1 member

The value a flag's name resolves to in an expression.

NumberField struct 2 members

A numeric field on an entity, read as a number rather than as the text tmux sends, so 9 orders before 10.

NumberFieldHandle struct 1 member

The value a numeric field name resolves to in an expression, whose comparison operators build the node rather than comparing anything.

StringField struct 2 members

A field is a named accessor: the name is what a future tmux-format lowering needs, the accessor is what in-memory evaluation needs.

StringFieldHandle struct 5 members

A typed field handle.

Queries — Operators 5 types
StringOp enum 5 members

How a text field is compared. StringOp::iequals folds case; the rest do not.

NumberOp enum 6 members

tmux renders a count, a size and an index as text.

Combine enum 2 members

Whether a group's operands must all hold or any one of them.

Quantifier enum 4 members

How a filter applies across a relation.

Negation struct 1 member

One expression inverted.

Queries — Expressions 2 types, 1 function or constant
FilterExpr class 4 members

A filter over one entity type, as a value.

LoweredNode struct 9 members

One node of a filter after it has been reduced to what tmux's -f format language can express.

A whole lowered filter, flat: children are referenced by index rather than owned, so the vector can be walked without recursion.

Snapshots 2 types, 6 functions and constants
Snapshot class 8 members

Owning row storage, shared by every entity taken from it.

CommandRuntimeSnapshot struct 8 members

A lock-consistent instant; values may change immediately after it is read.

capture_lines function

The lines are views into the text, so text that dies at the semicolon takes them with it — and pane.capture() returns its output by value, which makes capture_lines(*pane.capture()) the natural thing to write and a use-after-free to run.

decode_value function

Undo that escaping, in place.

Build the format argument for one entity's fields, terminating every field so a trailing empty value is still a value rather than a missing column.

Whether wanted appears in captured text as something the pane produced, rather than as text that is merely on screen.

split_row function

Split one tmux output line into its field values.

Drop the blank rows a pane pads its height with, keeping blank lines that have content below them.

Requests 3 types
CommandRequest class 8 members

One tmux command as argv, with no shell between it and tmux.

ControlRequest struct 1 member

The commands sent as one group, which tmux runs until one fails.

LayoutRequest struct 2 members
Errors 7 types, 9 functions and constants
CardinalityError enum 2 members

Why a lookup that required exactly one match did not get one.

KeyError enum 2 members

Why a key name could not be resolved to something tmux accepts.

LookupParseError enum 3 members

Why a legacy lookup string could not be read.

SocketError enum 4 members

Why a socket name or path was rejected before any server was contacted.

TargetError enum 2 members

Why a target could not be built from a name.

VersionError enum 2 members

Why a tmux version string could not be read.

ProtocolError struct 2 members

Why a control operation stopped.

Which error types name a validation reason rather than a runtime failure.

A control-wire failure as a command failure, keeping what it says about delivery — the one thing a caller cannot reconstruct.

The other direction, for a caller handing a command failure to a surface that speaks the wire's type.

Constants and enums 11 types, 1 function or constant
BackendKind enum 3 members

How commands reach the server: by spawning a process, or through a backend the caller supplied.

FailureKind enum 11 members

Why a command did not produce an answer, in the order a caller would diagnose them: bad before it left, then how it left, then what came back.

NotificationKind enum 26 members

What a notification is, once its name and arguments have been read.

CaptureOptions struct 7 members

Which part of a pane's screen and scrollback a capture reads.

ConnectionOptions struct 9 members

How to start a control-mode connection, and what it is allowed to buffer.

ControlRequestResult struct 2 members

What one request produced: its reply blocks, and the connection error that ended the exchange if one did.

ExecutorOptions struct 3 members

What a caller-supplied transport tells the library about itself.

RespawnOptions struct 2 members
SplitOptions struct 8 members

What a creation command can be told.

WaitOptions struct 8 members
WaitResult struct 10 members
Event type alias

Anything the parser produces: a reply to something asked, or something tmux said on its own.

Constants and enums — Session 1 type
NewSessionOptions struct 7 members

What a new session is created as, including its first window.

Constants and enums — Window 1 type
NewWindowOptions struct 7 members

What a new window is created as, and where it lands.

Testing utilities 10 types, 9 functions and constants
EnvironmentGuard class 2 members

Environment variables set for the lifetime of this value and restored on destruction, including the ones that were previously unset.

ScopedTmuxServer class 13 members

A tmux server that exists for the lifetime of this value.

SocketMode enum 2 members

Whether the test server is addressed by tmux -L name or tmux -S path.

BoolTest struct 2 members

A flag compared against an expected value.

NumberTest struct 3 members

A numeric field compared against a number.

RelationTest struct 4 members

A relation crosses to another entity type, so its child expression cannot live in this variant.

StringTest struct 3 members

A text field compared against an operand this node owns.

ScopedTmuxServerOptions struct 7 members

How the test server is started and how long teardown may take.

SocketNamespace struct 3 members

Names the private tree, the socket and the tmux -L name, so concurrent suites cannot collide and a leftover directory identifies its owner.

TeardownReport struct 1 member

What teardown could not clean up, so a suite can fail loudly rather than leave a server behind quietly.

Skip unless tmux is at least the release major.minor, naming what is missing below it.

Skip while tmux is inside a closed range of releases with a known defect.

Build and edit a NAME=VALUE block for a child process.

What tmux -V printed, verbatim, or "unknown".

lacks_tmux function

Whether running ranks below the release major.minor.

running_tmux function

Resolved once per distinct binary and cached.

Whether two paths name the same socket.

Internal 14 functions and constants
expected type alias

A value or the reason there is not one.

unexpected_t type alias

The error side of expected, named for the rare declaration that has to spell it.

What value() throws when there is none.

is_word_byte function
server_over function

Declared so the private constructor has exactly one way in.

to_flag function

tmux renders flag formats as "1" or "0"; anything else is not the flag.

to_number function

tmux renders every value as text.

to_time function
unexpected function

A factory rather than an alias: an alias template cannot deduce its argument, so unexpected(error) would stop compiling at every call site.

Other 6 types, 1 function or constant
Chain class 9 members

Several commands built up and sent as one tmux invocation.

EntityId class 3 members

A tmux object id, typed by what it names.

NodeCollector class 11 members

Collects a lowered expression.

Row class 3 members

The storage every entity has, in one place: the snapshot that owns the bytes and which of its rows this entity is.

DeliveryStatus enum 4 members

How far a command is known to have got before something stopped it.

SocketSource enum 3 members

What chose a socket when the caller named none.

Validate one path component.

By module 20 modules

Esc

Type to search.

Reference previewOpen reference