1use crossterm::event::{Event as CrosstermEvent, read};
2use tokio::sync::mpsc;
3use tokio::task::spawn_blocking;
4
5pub mod terminal;
6pub use terminal::{MouseCapture, TerminalSession};
7
8pub fn spawn_terminal_event_task() -> mpsc::UnboundedReceiver<CrosstermEvent> {
9 let (tx, rx) = mpsc::unbounded_channel();
10 spawn_blocking(move || {
11 loop {
12 let event = match read() {
13 Ok(event) => event,
14 Err(e) => {
15 eprintln!("Event read error: {e}");
16 continue;
17 }
18 };
19
20 if tx.send(event).is_err() {
21 break;
22 }
23 }
24 });
25 rx
26}