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.

method libtmux-rs latest

Pane.wait_until

Wait until settled holds for this pane's captured lines.

Source and package
Qualified name
libtmux::pane::Pane::wait_until
Module
pane
Declared in
Pane
Package
libtmux
Source
crates/libtmux/src/pane/observe.rs
pub async fn wait_until( &self, within: Duration, mut settled: impl FnMut(&[TmuxText]) -> bool, ) -> Result<PaneWait, Error>

Description#

For what a literal Pane::wait_for_text() cannot say: a line equal to something rather than containing it, a count, a pattern, the shape of the last line. settled sees what Pane::capture_with() returns for CaptureOptions::history().join_wrapped(): scrollback and screen, one entry per line, a line tmux wrapped joined back into one, and the screen's unused rows as empty lines at the end.

Looks are the ones Pane::wait_for_text() describes: 120ms apart, the first before any sleep, so lines already there answer at once. A pane whose process ends answers PaneWait::Dead rather than running to the deadline. It polls even on a handle routed through Server::over_control_mode(), because that connection's %output belongs to whoever reads its events, so waking on it would attach a second client per wait to save under three milliseconds on a marker (benches/waits.rs).

A query::Matcher over one line fits as |lines| lines.iter().any(|line| matcher.matches(line)).

Errors

Returns an error when tmux cannot be reached or refuses a look, which includes a pane that has been closed. Running out of time is PaneWait::TimedOut, not an error.

Cancel safety

Nothing happened. A look only reads, so a future dropped mid-look leaves tmux as it was, and output produced in the meantime stays in the scrollback, up to history-limit, for the next wait to find.

Examples#

use libtmux::PaneWait;
use std::time::Duration;
// The leading `echo` starts the output on a row of its own: keys sent
// before the shell's first prompt would otherwise print `$ tick`.
pane.send_line("echo; for n in 1 2 3; do echo tick; done").await?;
// The echoed command contains `tick`; only the output is a line equal to it.
let ticked = pane
.wait_until(Duration::from_secs(10), |lines| {
lines.iter().filter(|line| **line == "tick").count() == 3
})
.await?;
assert_eq!(ticked, PaneWait::Arrived);
Parameters

tmux command#

The tmux commands behind wait_until.

tmux C API#

The C declarations in tmux that implement these commands.

Esc

Type to search.

Reference previewOpen reference