1use bitflags::bitflags;
2use crossterm::event::MouseEvent;
3use ratatui::layout::Rect;
4
5use crate::{
6 action::{Action, ActionExt},
7 ui::HeaderTable,
8};
9
10bitflags! {
11 #[derive(bitflags_derive::FlagsDisplay, bitflags_derive::FlagsFromStr, Debug, PartialEq, Eq, Hash, Clone, Copy, Default, PartialOrd, Ord)]
12 pub struct Event: u32 {
13 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; }
31}
32
33#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
36#[repr(u8)]
37pub enum Interrupt {
38 #[default]
39 None,
40 Become,
41 Execute,
42 Print,
43 Reload,
44 Custom,
45}
46
47#[non_exhaustive]
50#[derive(Debug, strum_macros::Display, Clone)]
51pub enum RenderCommand<A: ActionExt> {
52 Action(Action<A>),
53 Mouse(MouseEvent),
54 Resize(Rect),
55 #[cfg(feature = "bracketed-paste")]
56 Paste(String),
57 HeaderTable(HeaderTable),
58 Ack,
59 Tick,
60 Refresh,
61 QuitEmpty,
62}
63
64impl<A: ActionExt> From<&Action<A>> for RenderCommand<A> {
65 fn from(action: &Action<A>) -> Self {
66 RenderCommand::Action(action.clone())
67 }
68}
69
70impl<A: ActionExt> RenderCommand<A> {
71 pub fn quit() -> Self {
72 RenderCommand::Action(Action::Quit(1))
73 }
74}