Core Library0.xAPI 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.

MoreLess about this notice

method libtmux-dotnet

Server.GetPaneAsync

Reads one pane by identifier, throwing when it is absent.

Source and package
Qualified name
LibTmux.Server.GetPaneAsync
Namespace
LibTmux
Declared in
Server
Package
LibTmux
Source
src/LibTmux/Server.Identity.cs

Description

A handle that has not found a live server yet discovers one first.

Parameters
Returns

A materialized pane carrying captured scalar state.

Errors

Examples

Use typed required lookups, nullable absence and explicit errors. Cancellation, invalid input and a stopped server remain exceptions. Use Linux or macOS with tmux 3.3a or newer, the .NET 10 SDK or newer, and the .NET 8 and 10 runtimes. In an empty directory, save this project as Example.csproj. It references the 0.1.1 release of LibTmux on NuGet: View source

Example.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<AnalysisLevel>10-recommended</AnalysisLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<PackageReference Include="LibTmux" Version="[0.1.1]" />
</ItemGroup>
</Project>

Save this complete program as Program.cs. It creates a private server; await using disposes its owned scopes after success, cancellation or failure. The complete file contains explicit imports, a top-level async entry point and a cancellation deadline. View source

Program.csComplete program
using System;
using System.IO;
using System.Linq;
using System.Threading;
using LibTmux;
if (OperatingSystem.IsWindows())
{
throw new PlatformNotSupportedException("This example requires tmux on Linux or macOS.");
}
using CancellationTokenSource deadline = new(TimeSpan.FromSeconds(10));
CancellationToken token = deadline.Token;
string? testTmux = Environment.GetEnvironmentVariable("LIBTMUX_TEST_TMUX");
string? configured = !string.IsNullOrWhiteSpace(testTmux)
? testTmux
: Environment.GetEnvironmentVariable("LIBTMUX_TMUX");
string binary = string.IsNullOrWhiteSpace(configured) ? "tmux" : configured;
using TemporaryDirectory socketRoot = new();
ServerConnectionOptions options = new()
{
SocketPath = Path.Combine(socketRoot.FullName, "tmux.sock"),
ConfigurationFile = "/dev/null",
TmuxBinaryPath = binary,
};
Server stoppedServer;
await using (OwnedServerScope owned = await Server.CreateOwnedAsync(options, token))
{
await using OwnedSessionScope session = await owned.Value.CreateOwnedSessionAsync(
new NewSessionRequest { Name = "demo", Command = "/bin/cat" }, token);
Server server = await Server.ConnectAsync(options, token);
Session found = await server.GetSessionAsync(session.Value.Id, token);
Window listedWindow = (await found.GetWindowsAsync(token)).Single();
Window window = await server.GetWindowAsync(listedWindow.Id, token);
Pane listedPane = (await window.GetPanesAsync(token)).Single();
Pane pane = await server.GetPaneAsync(listedPane.Id, token);
if (found.Id != session.Value.Id || pane.Id != listedPane.Id)
{
throw new InvalidOperationException("Typed lookup returned an unexpected entity.");
}
SessionId missingId = new(int.MaxValue);
Session? missing = await server.FindSessionAsync(missingId, token);
if (missing is not null)
{
throw new InvalidOperationException("The absent session unexpectedly exists.");
}
Console.WriteLine("A successful lookup can return null.");
try
{
_ = await server.GetSessionAsync(missingId, token);
throw new InvalidOperationException("GetSessionAsync must throw for an absent session.");
}
catch (TmuxObjectNotFoundException)
{
Console.WriteLine("Required lookup reports TmuxObjectNotFoundException.");
}
using CancellationTokenSource cancelled = new();
cancelled.Cancel();
try
{
_ = await server.FindSessionAsync(session.Value.Id, cancelled.Token);
throw new InvalidOperationException("Cancelled lookup must throw.");
}
catch (OperationCanceledException)
{
Console.WriteLine("Cancellation remains OperationCanceledException.");
}
try
{
_ = await window.FindPaneAsync(" ", token);
throw new InvalidOperationException("A blank pane target must be rejected.");
}
catch (ArgumentException)
{
Console.WriteLine("A blank pane target remains ArgumentException.");
}
stoppedServer = server;
}
try
{
_ = await stoppedServer.FindSessionAsync(new SessionId(int.MaxValue), token);
throw new InvalidOperationException("A failed read must not become null.");
}
catch (LibTmuxException)
{
Console.WriteLine("A stopped server remains a LibTmuxException.");
}
internal sealed class TemporaryDirectory : IDisposable
{
private readonly DirectoryInfo _directory = Directory.CreateTempSubdirectory("libtmux-example-");
public string FullName => _directory.FullName;
public void Dispose() => _directory.Delete(recursive: true);
}

Build the project and run both supported frameworks. Each program checks its result and exits unsuccessfully after an unhandled error:

Terminal window
$ dotnet build Example.csproj --configuration Release && \
dotnet bin/Release/net8.0/Example.dll && \
dotnet bin/Release/net10.0/Example.dll

Expected program output from each framework:

A successful lookup can return null.
Required lookup reports TmuxObjectNotFoundException.
Cancellation remains OperationCanceledException.
A blank pane target remains ArgumentException.
A stopped server remains a LibTmuxException.

Recorded calls

source calls
No call edges in the C# model.

The C# reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls LibTmux.Server.GetPaneAsync.

tmux command

task material

The tmux commands behind GetPaneAsync.

tmux C API

task material

The C declarations in tmux that implement these commands.

In other ports

task equivalence 7 other ports mapped

Source-verified mappings for Look one pane up by target. A mapping says these APIs perform the same task. It does not say they share defaults, errors or completion: check each page.

Look one pane up by target in each port
PortAPIDiffers from C#
C# LibTmux.Server.GetPaneAsync
Reads one pane by identifier, throwing when it is absent.
This page
Ruby LibTmux::Server#pane
Behavior: Live handles.
None recorded in the model
Erlang tmux_pane:get/2
Read fresh fields for a physical pane ID. Performs I/O and returns target_gone for a vanished pane. A captured PID remains an observation, not a live-process guarantee.
free function
Rust server.Server.pane_by_id
Find the pane with this id.
None recorded in the model
Go tmux.Server.Pane
Pane performs a canonical live lookup of id using tmux's canonical session and returns a newly materialized record. It does not preserve a linked-session view; use Pane.ResolveWindow for that exact relationship.
None recorded in the model
C++ libtmux::Server::pane readonly
OCaml Libtmux.Snapshot.find_pane free function
Exact opaque-ID lookup in an existing snapshot, without I/O.
Perl LibTmux::Snapshot::pane_by_id
pane_by_id('%3') returns a LibTmux::Pane or undef. The returned handle retains the captured graph after this wrapper goes out of scope.
on Snapshot
No Python equivalent.

no equivalent on Server

No Haskell equivalent.

No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.

No TypeScript equivalent.

no equivalent on Server

No Java equivalent.

no equivalent on Server

No Swift equivalent.

no equivalent on Server

No Raku equivalent.

No direct Raku mapping is recorded for this operation; consult the native API reference.

No equivalent is recorded in Lua, PowerShell, Julia, Elixir, Common Lisp, Clojure, Kotlin, Scala or F#.

Esc
Search in

Type to search.

Reference previewOpen reference