1use ratatui::layout::Rect;
2use strum_macros::{Display, EnumString};
3
4use crate::action::{Action, Exit};
5
6#[derive(Debug, Hash, PartialEq, Eq, EnumString, Clone, Display)]
7#[strum(serialize_all = "lowercase")]
8#[non_exhaustive]
9pub enum Event {
10 Start,
11 Complete,
12 QueryChange,
13 CursorChange,
14 PreviewChange,
15 PreviewSet,
16 Resize,
17 Refresh,
18 Pause,
19 Resume,
20}
21
22#[derive(Default, Debug, Clone)]
23#[non_exhaustive]
24pub enum Interrupt {
25 #[default]
26 None,
27 Become(String),
28 Execute(String),
29 Print(String),
30 Reload(String),
31}
32
33impl PartialEq for Interrupt {
34 fn eq(&self, other: &Self) -> bool {
35 std::mem::discriminant(self) == std::mem::discriminant(other)
36 }
37}
38
39impl Eq for Interrupt {}
40
41#[non_exhaustive]
42#[derive(Debug, strum_macros::Display, Clone)]
43pub enum RenderCommand {
44 Bind,
45 Action(Action),
46 Input(char),
47 Resize(Rect),
48 Ack,
49 Tick,
50 Refresh
51}
52
53impl From<&Action> for RenderCommand {
54 fn from(action: &Action) -> Self {
55 RenderCommand::Action(action.clone())
56 }
57}
58
59impl RenderCommand {
60 pub fn quit() -> Self {
61 RenderCommand::Action(Action::Quit(Exit::default()))
62 }
63}