Skip to main content

Module tui

Module tui 

Source
Expand description

The picker, drawn here instead of by fzf.

Step 1 answered the questions this depends on, inside a real tmux display-popup -E, and the answers are worth keeping written down:

  • The alternate screen nests inside a popup and unwinds cleanly. That was the one genuine unknown, since fzf runs --height=100% here and so says nothing about it.
  • Bracketed paste arrives as Event::Paste, one event carrying its own text, embedded line break included. This is the structural fix for the bug that put ~/.tmux.conf.local into live agent sessions: fzf reads a pasted line break as Enter, and every guard against that is a heuristic. Here there is nothing left to defeat. A pasted line break arrives as CR, not LF.
  • Resize is an event, not a reload.
  • The window is sized by the POPUP, 126x34 inside an 80% popup of a 160x45 terminal, so the rows are fitted to what they are actually drawn in rather than to tput cols less a guess at fzf’s chrome.

Drawing goes to /dev/tty and input comes from there too (crossterm’s use-dev-tty), which leaves stdout carrying exactly one line, the chosen pane id. atuin swaps file descriptors in its shell widget to get the same effect.

Owning the state is most of what this buys. fzf has no state store, so the bash picker keeps its mode in the BORDER LABEL and reads it back out by matching words in it, carries the mode and the search flag through every reload as quoted arguments because a child spawned by a reload cannot be relied on to see the new label yet, and needs --track --id-nth=2 so a reload does not drop the cursor. All of that is a field here.

Structs§

Source
Where rows come from, and what does not change while the picker is open.
State
Everything the picker has to carry across a reopen, so a resize costs you your popup’s geometry and nothing else.

Enums§

Mode
Which list is on screen. Tab steps round the cycle.
Outcome
How the picker finished.

Functions§

ended_source
The ended-sessions list, or nothing where the sessions cache is turned off. Source.ended being None is what takes that mode out of the Tab cycle, so the decision is made once, here.
run
Returns the row that was chosen, an abort, or a request to be reopened at a new size.