pub fn printf(msg: impl Into<String>) -> CmdExpand description
Print a formatted line above the program’s TUI output.
This works like std::format! but prints above the TUI.
Output is unmanaged by the program and will persist across renders.
Unlike std::print!, the message is printed on its own line (similar to log::info!).
Note: If the alternate screen is active, no output will be printed. This is because alternate screen mode uses a separate buffer that doesn’t support this kind of unmanaged output.
§Example
ⓘ
use bubbletea::{Model, Message, Cmd, printf};
impl Model for MyModel {
fn update(&mut self, msg: Message) -> Option<Cmd> {
if let Some(size) = msg.downcast_ref::<WindowSizeMsg>() {
return Some(printf(format!("Window size: {}x{}", size.width, size.height)));
}
None
}
}For more complex formatting, use std::format! with [println]:
ⓘ
println(format!("Processing {} of {} items", current, total))