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 Print,
45 Reload,
46 Custom,
47}
48
49#[non_exhaustive]
52#[derive(Debug, strum_macros::Display, Clone)]
53pub enum RenderCommand<A: ActionExt> {
54 Action(Action<A>),
55 Mouse(MouseEvent),
56 Resize(Rect),
57 #[cfg(feature = "bracketed-paste")]
58 Paste(String),
59 HeaderTable(HeaderTable),
60 Ack,
61 Tick,
62 Refresh,
63 QuitEmpty,
64}
65
66impl<A: ActionExt> From<Action<A>> for RenderCommand<A> {
67 fn from(action: Action<A>) -> Self {
68 RenderCommand::Action(action)
69 }
70}
71
72impl<A: ActionExt> RenderCommand<A> {
73 pub fn quit() -> Self {
74 RenderCommand::Action(Action::Quit(1))
75 }
76}
77
78#[derive(Debug)]
80pub enum BindDirective<A: ActionExt> {
81 Bind(Trigger, Actions<A>),
82 PushBind(Trigger, Actions<A>),
83 Unbind(Trigger),
84 PopBind(Trigger),
85}