Core LibraryunreleasedConcepts

Choose documentation 3

latest

Current version

latest
English

Unreleased LibTmux has not been released. Its API may change during development. This site's structure and URLs may change too.

MoreLess about this notice

Captured queries

snapshot acquires finite observations. panes(snap) contains unique physical panes; paneoccurrences(snap) follows each session/window link and may contain the same pane more than once. Filtering preserves the source’s order and multiplicity.

To inspect one exact session or window, pass its reference to snapshot(server, ref) or snapshot(connection, ref). The returned captured view supports local navigation, such as panes(snapshot(server, window_ref)). A session capture includes its window links and panes. A window capture includes its panes, all links to sessions, and those sessions’ scalar fields. Neither form acquires attached clients.

snapshotof(view) retains that partial graph. Its server-wide collections raise SnapshotCoverageError. A session capture cannot prove a shared window’s links to other sessions; a window capture cannot prove each linked session’s other windows. Criteria that need those uncaptured relations raise the same error. Use a full snapshot(server) when the query needs them.

PaneWhere, WindowWhere, SessionWhere, WindowLinkWhere and ClientWhere are callable criteria. Use them with Base filter, count, any, all, findall and Iterators.filter. Ordinary closures and downstream callable values work where Base accepts them. findall returns collection positions; those are one-based Julia indices, independent of tmux’s configured indices.

filter preserves a Selection. collect and row projections give ordinary Julia collections. A selection pins its snapshot; keeping one pane can therefore retain the whole captured graph. Refreshing acquires a new snapshot and never changes existing selections.

Use snap[reference] to look up a captured session, window, pane or client. get(snap, reference, nothing) returns nothing for proven absence. Both validate the reference against the captured server identity; they do not contact the current daemon. Indexing a proven missing key raises KeyError. A missing key in a partial graph raises SnapshotCoverageError because its absence was not observed. Client references also retain their incarnation.

The complete shared-window example is included directly from its tested source:

shared_windows.jl
using LibTmux
import LibTmux.Filters as F
function main()
snap = with_server() do server
dev = new_session(server; name="dev", command=["/bin/cat"])
initial = snapshot(server)
api = only(windows(initial)).ref
rename_window(server, api, "api")
split_window(server, only(panes(initial)).ref; command=["/bin/cat"])
new_window(server, dev; name="build", command=["/bin/cat"])
ops = new_session(server; name="ops", command=["/bin/cat"])
captured = snapshot(server)
placeholder =
only(windows(onlymatch(SessionWhere(name="ops"), sessions(captured)))).ref
source = onlymatch(
WindowLinkWhere(window=WindowWhere(name="api")),
windowlinks(captured),
)
link_window(server, WindowLinkRef(source), ops; index=4)
kill_window(server, placeholder)
snapshot(server)
end
@assert length(sessions(snap)) == 2
@assert length(windows(snap)) == 2
@assert length(windowlinks(snap)) == 3
@assert length(panes(snap)) == 3
@assert length(paneoccurrences(snap)) == 5
reference = first(panes(snap)).ref
@assert snap[reference].ref == reference
@assert snapshotof(get(snap, reference, nothing)) === snap
# The captured snapshot stays readable after the private server stops.
has_api = SessionWhere(windows=F.AnyRelated(WindowWhere(name="api")))
@assert count(has_api, sessions(snap)) == 2
selected = filter(PaneWhere(active=true, window=WindowWhere(name="api")), panes(snap))
@assert length(selected) == 1
@assert only(selected).ref ==
only(Iterators.filter(p -> p.active && p.window.name == "api", panes(snap))).ref
println("2 sessions, 2 windows, 3 links, 3 panes, 5 occurrences")
snap
end
main()

Fields in one criterion are conjoined. Nested relations preserve correlation: conditions within one AnyRelated(WindowWhere(...)) concern the same window. Two separate AnyRelated clauses can match different windows. On a captured empty relation, any/all/none evaluates to false/true/true. Uncaptured membership raises SnapshotCoverageError, including in short-circuited branches.

only keeps Base’s zero/multiple-result errors. onlymatch adds distinct NoMatchError and MultipleMatchesError diagnostics.

Portable criteria use encode_where and decode_where. Closures are local code and cannot be encoded. TypeScript and Rust adapters are separately named and reject semantics outside their verified intersection. JSON and Tables are optional extensions, not mandatory core dependencies. Lua consumers can author the Julia-owned wire profile directly.

The Lua producer record describes its common meanings and refusal boundaries. Lua-native wire envelopes remain separate.

Criterion construction and wire conversion are pure and can be checked without a tmux executable:

julia> using LibTmux
julia> criterion = PaneWhere(active=true);
julia> criterion isa Function
true
julia> encode_where(decode_where(encode_where(criterion))) == encode_where(criterion)
true
Esc
Search in

Type to search.

Reference previewOpen reference