1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
/*! * A module implementing a *terminal user interface* capable of visualizing all information stored in * [progress trees](../tree/struct.Root.html). * * **Please note** that it is behind the `tui-renderer` feature toggle, which is enabled by default. * * # Example * * ```should_panic * # fn main() -> Result<(), Box<dyn std::error::Error>> { * use futures::task::{LocalSpawnExt, SpawnExt}; * use prodash::tui::ticker; * // obtain a progress tree * let root = prodash::Tree::new(); * // Configure the gui, provide it with a handle to the ever-changing tree * let render_fut = prodash::tui::render( * root.clone(), * prodash::tui::TuiOptions { * title: "minimal example".into(), * ..prodash::tui::TuiOptions::default() * } * )?; * // As it runs forever, we want a way to stop it. * let (render_fut, abort_handle) = futures::future::abortable(render_fut); * let pool = futures::executor::LocalPool::new(); * // Spawn the gui into the background… * let gui = pool.spawner().spawn_with_handle(async { render_fut.await.ok(); () })?; * // …and run tasks which provide progress * pool.spawner().spawn_local({ * use futures::StreamExt; * let mut progress = root.add_child("task"); * async move { * progress.init(None, Some("items")); * let mut count = 0; * let mut ticks = ticker(std::time::Duration::from_millis(100)); * while let Some(_) = ticks.next().await { * progress.set(count); * count += 1; * } * } * })?; * // …when we are done, tell the GUI to stop * abort_handle.abort(); * //…and wait until it is done * futures::executor::block_on(gui); * # Ok(()) * # } * ``` */ mod draw; mod engine; mod utils; pub use engine::*; pub use utils::ticker; /// Useful for bringing up the TUI without bringing in the `tui` crate yourself pub use tui as tui_export;