INNER CODE UNIT · Rust

run

atanunq/viu · src/app.rs:14

pub fn run(mut conf: Config) -> ViuResult {
    //create two channels so that ctrlc-handler and the main thread can pass messages in order to
    // communicate when printing must be stopped without distorting the current frame
    let (tx_ctrlc, rx_print) = mpsc::channel();
    let (tx_print, rx_ctrlc) = mpsc::channel();

    //handle Ctrl-C in order to clean up after ourselves
    ctrlc::set_handler(move || {
        //if ctrlc is received tell the infinite gif loop to stop drawing
        // or stop the next file from being drawn
        tx_ctrlc
            .send(true)
            .expect("Could not send signal to stop drawing.");
        //a message will be received when that has happened so we can clear leftover symbols
        let _ = rx_ctrlc
            .recv()
            .expect("Could not receive signal to clean up terminal.");

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…