appcui 0.4.8

A feature-rich and cross-platform TUI/CUI framework for Rust, enabling modern terminal-based applications on Windows, Linux, and macOS. Includes built-in UI components like buttons, menus, list views, tree views, checkboxes, and more. Perfect for building fast and interactive CLI tools and text-based interfaces.
Documentation
use crate::system::SystemEvent;
use std::{sync::mpsc::Sender, thread};

#[allow(dead_code)]
pub(crate) trait SystemEventReader {
    fn read(&mut self) -> Option<SystemEvent>;
    fn start(mut self, sender: Sender<SystemEvent>)
    where
        Self: Sized + Send + 'static,
    {
        thread::spawn(move || {
            let mut should_close = false;
            while !should_close {
                if let Some(ev) = self.read() {
                    should_close = ev.should_close();
                    if sender.send(ev).is_err() {
                        should_close = true
                    }
                }
            }
        });
    }
}