pub struct Reveal<'a> { /* private fields */ }Expand description
A live terminal reveal session.
Construct it, call render with each new progress value as
your task advances, then finish. The terminal is restored
on drop even if you forget, and everything degrades to a no-op when stdout is
not a TTY (piped, redirected, CI), so the same code is safe everywhere.
Progress may move backwards as well as forwards; the reveal is seekable.
use inkling::{Art, ordering::{Ordering, Geodesic}, render::{Reveal, Style}};
let art = Art::parse(include_str!("../assets/dragon.txt"));
let ranks = Geodesic::default().rank(&art);
let mut reveal = Reveal::new(&art, &ranks, Style::default())?;
for done in 0..=100 {
reveal.render(done as f32 / 100.0)?;
// ... do a slice of real work ...
}
reveal.finish()?;Implementations§
Source§impl<'a> Reveal<'a>
impl<'a> Reveal<'a>
Sourcepub fn new(art: &'a Art, ranks: &'a RankMap, style: Style) -> Result<Self>
pub fn new(art: &'a Art, ranks: &'a RankMap, style: Style) -> Result<Self>
Begin a reveal session. On a TTY this switches to the alternate screen and
hides the cursor; otherwise it is inert until finish.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Reveal<'a>
impl<'a> RefUnwindSafe for Reveal<'a>
impl<'a> Send for Reveal<'a>
impl<'a> Sync for Reveal<'a>
impl<'a> Unpin for Reveal<'a>
impl<'a> UnsafeUnpin for Reveal<'a>
impl<'a> UnwindSafe for Reveal<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more