libvt.contrib.tmux.window¶
Multi-pane tmux window layout, scene compositing, and capture bundles.
Format string passed to
tmux display-message -pfor window layout state.
Format string passed to
tmux list-panes -Ffor per-pane geometry & styles.
-
class libvt.contrib.tmux.window.TmuxWindowCaptureCommand¶class libvt.contrib.tmux.window.TmuxWindowCaptureCommand¶
Bases:
objectStateless
tmuxcommand capturing all panes in a window.
-
class libvt.contrib.tmux.window.TmuxWindowCaptureResult¶class libvt.contrib.tmux.window.TmuxWindowCaptureResult¶
Bases:
objectDecoded
tmuxwindow capture of pane application screens.
-
class libvt.contrib.tmux.window.TmuxWindowLayout¶class libvt.contrib.tmux.window.TmuxWindowLayout¶
Bases:
objectWindow geometry, border options, and pane descriptors for a
tmuxwindow.
-
class libvt.contrib.tmux.window.TmuxWindowListCommand¶class libvt.contrib.tmux.window.TmuxWindowListCommand¶
Bases:
objectStateless Step 1
tmuxcommand querying window geometry and panes.
-
class libvt.contrib.tmux.window.TmuxWindowPane¶class libvt.contrib.tmux.window.TmuxWindowPane¶
Bases:
objectGeometry and border styling metadata for one pane inside a
tmuxwindow.
-
libvt.contrib.tmux.window.build_tmux_window_capture_command(layout, *, tmux_version='3.8a', include_saved_primary=False, history_lines=0, include_layout=False, nonce=None)¶libvt.contrib.tmux.window.build_tmux_window_capture_command(layout, *, tmux_version='3.8a', include_saved_primary=False, history_lines=0, include_layout=False, nonce=None)¶
Build an atomic
tmuxcommand capturing every pane in layout.Chains per-pane
build_tmux_capture_command()invocations separated by";"inside a singletmuxcommand batch, optionally prepending an inlinebuild_tmux_window_list_command()header wheninclude_layout=True(for 1-round-trip capture fromparse_tmux_window_layout()), and appends aWIN_POSTlayout stability check.- Parameters:
layout (
TmuxWindowLayout) – Window descriptor frombuild_tmux_window_list_command()orparse_tmux_window_layout().tmux_version (
tuple[int, int] | str, default “3.8a”) – Targettmuxversion string or(major, minor)tuple.include_saved_primary (
bool, default False) – Whether each per-pane capture includescapture-pane -a -qprimary history whenalternate_onis active.history_lines (
int | None, default 0) – Scrollback lines captured per pane (0for viewport-only,Nonefor full history, orN > 0for-S -N).include_layout (
bool, default False) – WhenTrue, query live window metadata, client theme colors, border styles, andpane-border-formatinline in the sametmuxbatch.nonce (
str|None,optional) – Explicit ASCII boundary token matching[0-9A-Za-z_-]{8,80}; generated viasecrets.token_hex()whenNone.
- Returns:
- Return type:
- Raises:
TypeError– If history_lines is not anintorNone.ValueError– If tmux_version, history_lines, or nonce is invalid.
Examples
>>> from libvt.contrib.tmux.window import ( ... TmuxWindowLayout, ... TmuxWindowPane, ... build_tmux_window_capture_command, ... ) >>> layout = TmuxWindowLayout( ... panes=(TmuxWindowPane("%0"), TmuxWindowPane("%1", active=True)), ... ) >>> cmd = build_tmux_window_capture_command(layout, nonce="WCAP_1234") >>> len(cmd.pane_commands) 2
-
libvt.contrib.tmux.window.build_tmux_window_list_command(target=None, *, nonce=None)¶libvt.contrib.tmux.window.build_tmux_window_list_command(target=None, *, nonce=None)¶
Build Step 1
tmuxcommand querying window layout and pane descriptors.Chains
display-messageandlist-panesin one atomictmuxcommand-queue batch so window dimensions, zoom state, client theme colors, border styles, and expandedpane-border-formatstrings come from a single server tick.- Parameters:
target (
str|None,optional) – Optionaltmuxtarget window (e.g."@0"or"mysess:0");Nonetargets the current window.nonce (
str|None,optional) – Explicit ASCII boundary token matching[0-9A-Za-z_-]{8,96}; generated viasecrets.token_hex()whenNone.
- Returns:
- Return type:
- Raises:
ValueError– If target or nonce is invalid.
Examples
>>> from libvt.contrib.tmux.window import build_tmux_window_list_command >>> cmd = build_tmux_window_list_command("@0", nonce="WIN_LIST_1") >>> "list-panes" in cmd.argv True
-
libvt.contrib.tmux.window.composite_tmux_window(layout, panes, *, tmux_version='3.8a', profile=None)¶libvt.contrib.tmux.window.composite_tmux_window(layout, panes, *, tmux_version='3.8a', profile=None)¶
Composite a multi-pane
tmuxwindow into one immutableSnapshot.Pure sans-I/O compositor built on
blit(),put_text(), andsnapshot(), matchingtmux’sscreen-redraw.cscene builder across perimeterL|R|U|Djunctions,pane-border-lines, two-pane half-colored active borders,pane-border-statusformat lines,themecolor tables, full-width soft-wrap flags, zoomed windows, and active-pane cursor positioning.- Parameters:
layout (
TmuxWindowLayout) – Window dimensions, border options, and pane geometry descriptors.panes (
Mapping[str,TmuxPaneSource]) – Mapping frompane_id(e.g."%0") to each pane’sSnapshot,Screen,Terminal,TmuxCaptureResult, or liveTmuxPaneSynchandle.tmux_version (
tuple[int, int] | str, default “3.8a”) – Targettmuxversion governing right-edgepending_wrapcursor visibility (tmux >= 3.7hides apending_wrapcursor at the window right margin viascreen_redraw_get_visible_ranges, whereastmux <= 3.6keeps it visible atcols - 1).profile (
Profile | None, default None) – Terminal compatibility profile for width calculations and the returnedSnapshot.
- Returns:
Composited window snapshot with active-pane cursor and metadata.
- Return type:
References
Examples
>>> from libvt.contrib.tmux.window import ( ... TmuxWindowLayout, ... TmuxWindowPane, ... composite_tmux_window, ... ) >>> from libvt.terminal import Terminal >>> from libvt.testing import format_screen_box >>> left, right = Terminal(rows=2, cols=4), Terminal(rows=2, cols=4) >>> left.feed(b"LEFT") >>> right.feed(b"RGHT") >>> win_layout = TmuxWindowLayout( ... width=9, ... height=2, ... panes=( ... TmuxWindowPane("%0", left=0, top=0, width=4, height=2, index=0), ... TmuxWindowPane( ... "%1", left=5, top=0, width=4, height=2, active=True, index=1 ... ), ... ), ... ) >>> snap = composite_tmux_window(win_layout, {"%0": left, "%1": right}) >>> print(format_screen_box(snap)) ┌─────────┐ │LEFT│RGHT│ │ │ │ └─────────┘
-
libvt.contrib.tmux.window.parse_tmux_window_layout(window_layout, *, window_id='@0', width=None, height=None, zoomed=False, border_lines='single', border_status='off', border_indicators='colour', border_style='fg=themelightgrey', active_pane_id=None)¶libvt.contrib.tmux.window.parse_tmux_window_layout(window_layout, *, window_id='@0', width=None, height=None, zoomed=False, border_lines='single', border_status='off', border_indicators='colour', border_style='fg=themelightgrey', active_pane_id=None)¶
Parse a
tmux#{window_layout}descriptor intoTmuxWindowLayout.Accepts both
tmux >= 3.8V2 JSON layouts ({"V":2,"L":{...}}) and legacy V1 checksum tree strings ("b25f,20x6,0,0{10x6,0,0,0,9x6,11,0,1}"), allowing callers such aslibtmuxthat already holdwindow_layoutto build a single-invocationbuild_tmux_window_capture_command()withinclude_layout=Trueor composite pane handles directly.- Parameters:
window_layout (
str) – Raw#{window_layout}or#{window_visible_layout}string.window_id (
str, default “@0”) –tmuxwindow identifier stored on the returned layout.width (
int|None,optional) – Explicit window width override; inferred from root cell whenNone.height (
int|None,optional) – Explicit window height override; inferred from root cell whenNone.zoomed (
bool, default False) – Whether the window is currently zoomed.border_lines (
str, default “single”) – Windowpane-border-linessetting.border_status (
str, default “off”) – Windowpane-border-statussetting.border_indicators (
str, default “colour”) – Windowpane-border-indicatorssetting.border_style (
str, default “fg=themelightgrey”) – Window fallbackpane-border-style.active_pane_id (
str|None,optional) – Explicit activepane_id(used for V1 strings which omit active flags).
- Returns:
Parsed window dimensions and
TmuxWindowPanegeometries.- Return type:
- Raises:
ValueError– If window_layout is empty or malformed.
References
Examples
>>> from libvt.contrib.tmux.window import parse_tmux_window_layout >>> v1 = parse_tmux_window_layout( ... "b25f,20x6,0,0{10x6,0,0,0,9x6,11,0,1}", active_pane_id="%1" ... ) >>> (v1.width, v1.height, [p.pane_id for p in v1.panes], v1.active_pane.pane_id) (20, 6, ['%0', '%1'], '%1') >>> v2 = parse_tmux_window_layout( ... '{"V":2,"L":{"t":"h","w":20,"h":6,"x":0,"y":0,"c":[' ... '{"t":"p","w":10,"h":6,"x":0,"y":0,"i":0,"I":"%0"},' ... '{"t":"p","w":9,"h":6,"x":11,"y":0,"a":true,"i":1,"I":"%1"}]}}' ... ) >>> (v2.width, v2.height, v2.panes[1].left, v2.panes[1].active) (20, 6, 11, True)
-
Accepted per-pane state source for
composite_tmux_window().