On this page
libtmux.neo._best_winlink
- Module
- libtmux.neo
- Package
- libtmux
- Source
- src/libtmux/neo.py
- _best_winlink ( rows : OutputsRaw ) OutputRaw
-
Pick the winlink row tmux would select.
A
list-windowslisting enumerates winlinks --(session, index, window)edges -- not windows.link-windowcan attach one window to a session at several indexes at once, so the samewindow_idmay appear on several rows, each with a differentwindow_index.tmux selects the current winlink when it contains the window, otherwise the first.
#{window_active}identifies the current row, and the lowestwindow_indexis tmux's first -- chosen explicitly here, so the caller need not pre-sort the rows.Examples
One row is the whole answer:
>>> from libtmux.neo import _best_winlink >>> _best_winlink([{"window_id": "@0", "window_index": "1"}])["window_index"] '1'A window linked into one session twice gives two rows. When the session is sitting on the higher-indexed link, that is the one tmux acts on:
>>> _best_winlink([ ... {"window_id": "@0", "window_index": "1", "window_active": "0"}, ... {"window_id": "@0", "window_index": "5", "window_active": "1"}, ... ])["window_index"] '5'When the session is sitting on some *other* window, neither link is current, and tmux falls back to the first:
>>> _best_winlink([ ... {"window_id": "@0", "window_index": "1", "window_active": "0"}, ... {"window_id": "@0", "window_index": "5", "window_active": "0"}, ... ])["window_index"] '1'The fallback reads the lowest index, not the first row, so a listing that happened to arrive high-index-first still answers tmux's first:
>>> _best_winlink([ ... {"window_id": "@0", "window_index": "5", "window_active": "0"}, ... {"window_id": "@0", "window_index": "1", "window_active": "0"}, ... ])["window_index"] '1'- Parameters
-
-
rows ( OutputsRaw ) – Non-empty rows for one object id in one session. Order does not matter: the current winlink wins, otherwise the lowest
window_index.
-
- Returns
-
OutputRaw The row naming the winlink tmux would act on.
0 declared, 0 inherited