pane.Pane.wait_for_text
Rust
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift Unavailable
- Module
- pane
- Declared in
- Pane
- Package
- libtmux
- Source
- crates/libtmux/src/pane/observe.rs
-
-
Wait until this pane's output contains
needle.Pane::wait_untiltakes a predicate over the lines instead.Polls rather than streams, so it needs no feature: a caller who dispatches a command needs to know when it finished, and
Pane::send_keyswithout that is half an operation. A control-mode subscription would answer sooner and is not available in a default build.A look costs one
capture-paneand looks are 120ms apart, which keeps a wait under ten dispatches a second and answers within an interval of the text appearing. The first look comes before the first sleep, so text already there when the wait begins is answered at once, and awithinshorter than one interval buys exactly one look.Each look reads the scrollback rather than the visible screen, and joins lines tmux wrapped. Both matter for correctness rather than completeness: text that scrolled off before the look would otherwise be missed and reported as absent, and a line wider than the pane arrives split, so a needle spanning the wrap point would never match.
A pane whose process ends answers
PaneWait::Deadrather than running to the deadline, because waiting longer cannot change it.A
Pane::capturecalled immediately after this returns can occasionally miss the very output that satisfied the wait: tmux's own redraw of the screen a fast, multi-byte-heavy write produced can still be in flight when the nextcapture-panereads it, independent of this crate. Raw tmux shows the same gap running the equivalentsend-keys/capture-panesequence directly. A caller sensitive to this should retry the capture rather than trust it on the first look.Errors
Returns an error when tmux cannot be reached or refuses a capture. Running out of time is
PaneWait::TimedOut, not an error.Cancel safety
Nothing happened. A look only reads, so output a dropped wait missed stays in the scrollback, up to
history-limit, for the next wait.Examples
use libtmux::PaneWait;use std::time::Duration;pane.send_line("printf 'ready\\n'").await?;let seen = pane.wait_for_text("ready", Duration::from_secs(10)).await?;assert_eq!(seen, PaneWait::Arrived);Discussed in Capture pane output · Testing with libtmux
0 declared, 0 inherited