mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
30 lines
582 B
Rust
30 lines
582 B
Rust
use tokio::sync::mpsc;
|
|
use yazi_shim::cell::RoCell;
|
|
|
|
use super::ActionCow;
|
|
|
|
static TX: RoCell<mpsc::UnboundedSender<Event>> = RoCell::new();
|
|
static RX: RoCell<mpsc::UnboundedReceiver<Event>> = RoCell::new();
|
|
|
|
#[derive(Debug)]
|
|
pub enum Event {
|
|
Call(ActionCow),
|
|
Seq(Vec<ActionCow>),
|
|
Term(yazi_term::event::Event),
|
|
Render(bool),
|
|
}
|
|
|
|
impl Event {
|
|
#[inline]
|
|
pub fn init() {
|
|
let (tx, rx) = mpsc::unbounded_channel();
|
|
TX.init(tx);
|
|
RX.init(rx);
|
|
}
|
|
|
|
#[inline]
|
|
pub fn take() -> mpsc::UnboundedReceiver<Self> { RX.drop() }
|
|
|
|
#[inline]
|
|
pub fn emit(self) { TX.send(self).ok(); }
|
|
}
|