1use bitflags::bitflags;
2use crossterm::event::MouseEvent;
3use ratatui::layout::Rect;
4
5use crate::{
6 Actions,
7 action::{Action, ActionExt},
8 binds::Trigger,
9 ui::HeaderTable,
10};
11
12bitflags! {
13 #[derive(bitflags_derive::FlagsDisplay, bitflags_derive::FlagsFromStr, Debug, PartialEq, Eq, Hash, Clone, Copy, Default, PartialOrd, Ord)]
14 pub struct Event: u32 {
15 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; }
33}
34
35#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]
38#[repr(u8)]
39pub enum Interrupt {
40 #[default]
41 None,
42 Become,
43 Execute,
44 ExecuteSilent,
45 Print,
46 Reload,
47 Custom,
48}
49
50#[non_exhaustive]
53#[derive(Debug, strum_macros::Display, Clone)]
54pub enum RenderCommand<A: ActionExt> {
55 Action(Action<A>),
56 Mouse(MouseEvent),
57 Resize(Rect),
58 #[cfg(feature = "bracketed-paste")]
59 Paste(String),
60 HeaderTable(HeaderTable),
61 Ack,
62 Tick,
63 Refresh,
64 QuitEmpty,
65}
66
67impl<A: ActionExt> From<Action<A>> for RenderCommand<A> {
68 fn from(action: Action<A>) -> Self {
69 RenderCommand::Action(action)
70 }
71}
72
73impl<A: ActionExt> RenderCommand<A> {
74 pub fn quit() -> Self {
75 RenderCommand::Action(Action::Quit(1))
76 }
77}
78
79#[derive(Debug)]
81pub enum BindDirective<A: ActionExt> {
82 Bind(Trigger, Actions<A>),
83 PushBind(Trigger, Actions<A>),
84 Unbind(Trigger),
85 PopBind(Trigger),
86}