Expand description
A module implementing a terminal user interface capable of visualizing all information stored in progress trees.
Please note that it is behind the render-tui
feature toggle, which is enabled by default.
Example
ⓘ
use futures::task::{LocalSpawnExt, SpawnExt};
use prodash::render::tui::ticker;
use prodash::Root;
// obtain a progress tree
let root = prodash::tree::Root::new();
// Configure the gui, provide it with a handle to the ever-changing tree
let render_fut = prodash::render::tui::render(
std::io::stdout(),
root.downgrade(),
prodash::render::tui::Options {
title: "minimal example".into(),
..Default::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, None);
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);
Re-exports
pub use tui as tui_export;
Structs
- Configure the terminal user interface
Enums
- An event to be sent in the
tui::render_with_input(…events)
stream. - The variants represented here allow the user to control when the GUI can be shutdown.
- A line as used in
Event::SetInformation
Functions
- An easy-to-use version of
render_with_input(…)
that does not allow state manipulation via an event stream. - Returns a future that draws the terminal user interface indefinitely.
- Returns a stream of ‘ticks’, each being duration
dur
apart.