Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

pane.Pane.wait_until

Rust
  • Python Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
pane
Declared in
Pane
Package
libtmux
Source
crates/libtmux/src/pane/observe.rs
wait_until ( self , within : Duration , settled : impl FnMut(&[TmuxText]) -> bool ) → Result<PaneWait, Error>
method [source]
method [source]
wait_until

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

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;
pane.send_line("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);

0 declared, 0 inherited

Esc

Type to search.