1use bitflags::bitflags;
2use crossterm::event::MouseEvent;
3use ratatui::layout::Rect;
4
5use crate::action::{Action, ActionExt};
6
7bitflags! {
8 #[derive(bitflags_derive::FlagsDisplay, bitflags_derive::FlagsFromStr, Debug, PartialEq, Eq, Hash, Clone, Copy, Default, PartialOrd, Ord)]
9 pub struct Event: u32 {
10 const Start = 1 << 0; const Complete = 1 << 1; const Synced = 1 << 7; const Resynced = 1 << 8; const QueryChange = 1 << 2; const CursorChange = 1 << 3; const PreviewChange = 1 << 4; const OverlayChange = 1 << 5; const PreviewSet = 1 << 6; const Resize = 1 << 9; const Refresh = 1 << 10; const Pause = 1 << 11; const Resume = 1 << 12; }
28}
29
30#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
33#[repr(u8)]
34pub enum Interrupt {
35 #[default]
36 None,
37 Become,
38 Execute,
39 Print,
40 Reload,
41 Custom,
42}
43
44#[non_exhaustive]
47#[derive(Debug, strum_macros::Display, Clone)]
48pub enum RenderCommand<A: ActionExt> {
49 Action(Action<A>),
50 Mouse(MouseEvent),
51 Resize(Rect),
52 #[cfg(feature = "bracketed-paste")]
53 Paste(String),
54 HeaderColumns(Vec<ratatui::text::Text<'static>>),
55 Ack,
56 Tick,
57 Refresh,
58 QuitEmpty,
59}
60
61impl<A: ActionExt> From<&Action<A>> for RenderCommand<A> {
62 fn from(action: &Action<A>) -> Self {
63 RenderCommand::Action(action.clone())
64 }
65}
66
67impl<A: ActionExt> RenderCommand<A> {
68 pub fn quit() -> Self {
69 RenderCommand::Action(Action::Quit(1))
70 }
71}