stdout

Function stdout 

Source
pub fn stdout(do_style: DoStyle) -> Box<dyn LockableStream>
Expand description

A LockableStream wrapping stdout.

Examples found in repository?
examples/progress_bar.rs (line 21)
20fn draw_progress(completion: f32) {
21    let mut stream = stijl::stdout(DoStyle::Auto);
22    let sz = stream.get_size();
23    // Use (cols - 1) for Windows 7 compatibility.
24    stream.write_all(&progress_str((sz.cols - 1) as usize, completion));
25    stream.rewind_lines(1);
26}
More examples
Hide additional examples
examples/thread_write.rs (line 15)
12fn main() {
13    let t1 = thread::spawn(|| {
14        let five_millis = time::Duration::from_millis(5);
15        let stream = stijl::stdout(DoStyle::Auto);
16        let mut stream = stream.lock();
17        stream.fg(Blue);
18        write!(stream, "ONE ");
19        thread::sleep(five_millis);
20        write!(stream, "TWO ");
21        thread::sleep(five_millis);
22        stream.em();
23        writeln!(stream, "THREE");
24        stream.reset();
25    });
26    let t2 = thread::spawn(|| {
27        let five_millis = time::Duration::from_millis(5);
28        let stream = stijl::stdout(DoStyle::Auto);
29        let mut stream = stream.lock();
30        stream.fg(Green);
31        write!(stream, "1 ");
32        thread::sleep(five_millis);
33        write!(stream, "2 ");
34        thread::sleep(five_millis);
35        stream.em();
36        writeln!(stream, "3");
37        stream.reset();
38    });
39    let t3 = thread::spawn(|| {
40        let five_millis = time::Duration::from_millis(5);
41        let stream = stijl::stdout(DoStyle::Auto);
42        let mut stream = stream.lock();
43        stream.fg(Red);
44        write!(stream, "I ");
45        thread::sleep(five_millis);
46        write!(stream, "II ");
47        thread::sleep(five_millis);
48        stream.em();
49        writeln!(stream, "III");
50        stream.reset();
51    });
52
53    t1.join().unwrap();
54    t2.join().unwrap();
55    t3.join().unwrap();
56}