rite_tui/msg.rs
1//! `Msg` and `Cmd`, the inputs and outputs of `update`.
2
3use crossterm::event::{KeyEvent, MouseEvent};
4use rite_runtime::{ExecEvent, UiCommand};
5
6/// Input to the pure [`update`] function.
7///
8/// Every state transition in the UI corresponds to exactly one `Msg`,
9/// which makes the audit surface a single enum.
10///
11/// [`update`]: crate::update::update
12#[derive(Debug)]
13pub enum Msg {
14 /// Key press from the terminal.
15 Key(KeyEvent),
16 /// Mouse event from the terminal (currently unused, reserved).
17 Mouse(MouseEvent),
18 /// Terminal resize.
19 Resize {
20 /// New width in cells.
21 cols: u16,
22 /// New height in cells.
23 rows: u16,
24 },
25 /// Timer tick for spinners and time-driven redraws.
26 Tick,
27 /// Event from the runtime executor.
28 Exec(ExecEvent),
29 /// Explicit quit signal.
30 Quit,
31}
32
33/// Side effect produced by [`update`]. The runtime loop interprets these
34/// after every `update` call.
35///
36/// [`update`]: crate::update::update
37#[derive(Debug)]
38pub enum Cmd {
39 /// Send a command back to the executor thread.
40 SendCommand(UiCommand),
41 /// Stop the loop.
42 Quit,
43}