pixbar 0.2.0

Sub-cell-precision two-value progress bar for narrow terminal widths (Unicode 1/8 block, no font patching required).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use pixbar::{Bar, Capability};
use std::{thread::sleep, time::Duration};

fn main() {
    let cap = Capability::EighthBlock;
    print!("\x1b[?25l"); // hide cursor
    for tick in 0..=100u32 {
        let p1 = tick as f64 / 100.0;
        let p2 = (p1 + 0.12).min(1.0);
        print!("\r{}", Bar::new(40).primary(p1).secondary(p2).capability(cap).render());
        std::io::Write::flush(&mut std::io::stdout()).ok();
        sleep(Duration::from_millis(40));
    }
    println!("\x1b[?25h");
}