aboutsummaryrefslogtreecommitdiffstats
path: root/examples/process_full.rs
blob: c62bcb2dbf68686068a6b14d80f678dbd09f1ca2 (plain) (blame)
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
use std::io::{Read as _, Write as _};

fn read_frames() -> impl Iterator<Item = Vec<u8>> {
    (1..=7625).map(|i| {
        let mut file =
            std::fs::File::open(format!("tests/data/crawl/crawl{}", i))
                .unwrap();
        let mut frame = vec![];
        file.read_to_end(&mut frame).unwrap();
        frame
    })
}

fn draw_frames(frames: &[Vec<u8>]) {
    let mut stdout = std::io::stdout();
    let mut parser = vt100::Parser::new(24, 80);
    for frame in frames {
        parser.process(&frame);
        let contents = parser.screen().contents_formatted();
        stdout.write_all(&contents).unwrap();
    }
}

fn main() {
    let frames: Vec<Vec<u8>> = read_frames().collect();
    for _ in 1..10 {
        draw_frames(&frames);
    }
}