2024-05-10 12:03:38 +02:00
|
|
|
use hyperlog_core::log::GraphItem;
|
|
|
|
|
2024-05-09 00:15:42 +02:00
|
|
|
use crate::commands::{Command, IntoCommand};
|
|
|
|
|
2024-05-02 23:47:47 +02:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Msg {
|
|
|
|
MoveRight,
|
|
|
|
MoveLeft,
|
|
|
|
MoveDown,
|
|
|
|
MoveUp,
|
2024-05-10 12:20:43 +02:00
|
|
|
QuitApp,
|
2024-05-07 23:21:13 +02:00
|
|
|
OpenCreateItemDialog,
|
2024-05-10 12:03:38 +02:00
|
|
|
OpenEditItemDialog { item: GraphItem },
|
2024-05-09 15:26:58 +02:00
|
|
|
Interact,
|
2024-05-07 23:21:13 +02:00
|
|
|
|
|
|
|
EnterInsertMode,
|
2024-05-09 00:15:42 +02:00
|
|
|
EnterViewMode,
|
2024-05-07 23:21:13 +02:00
|
|
|
EnterCommandMode,
|
2024-05-09 00:15:42 +02:00
|
|
|
|
2024-05-09 12:07:23 +02:00
|
|
|
SubmitCommand { command: String },
|
2024-05-09 00:15:42 +02:00
|
|
|
|
2024-05-07 23:21:13 +02:00
|
|
|
Edit(EditMsg),
|
2024-05-12 14:29:14 +02:00
|
|
|
|
|
|
|
GraphUpdated(GraphUpdatedEvent),
|
2024-05-12 21:07:21 +02:00
|
|
|
|
|
|
|
ItemCreated(IOEvent<()>),
|
|
|
|
ItemUpdated(IOEvent<()>),
|
|
|
|
SectionCreated(IOEvent<()>),
|
|
|
|
ItemToggled(IOEvent<()>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum IOEvent<T> {
|
|
|
|
Initialized,
|
|
|
|
Optimistic(T),
|
|
|
|
Success(T),
|
|
|
|
Failure(String),
|
2024-05-12 14:29:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum GraphUpdatedEvent {
|
|
|
|
Initiated,
|
2024-05-12 14:35:35 +02:00
|
|
|
Optimistic(GraphItem),
|
2024-05-12 14:29:14 +02:00
|
|
|
Success(GraphItem),
|
|
|
|
Failure(String),
|
2024-05-07 23:21:13 +02:00
|
|
|
}
|
|
|
|
|
2024-05-09 00:15:42 +02:00
|
|
|
impl IntoCommand for Msg {
|
|
|
|
fn into_command(self) -> crate::commands::Command {
|
2024-05-12 12:58:54 +02:00
|
|
|
Command::new(|_| Some(self))
|
2024-05-09 00:15:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-07 23:21:13 +02:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum EditMsg {
|
|
|
|
Delete,
|
|
|
|
InsertNewLine,
|
|
|
|
InsertTab,
|
|
|
|
DeleteNext,
|
|
|
|
InsertChar(char),
|
|
|
|
MoveLeft,
|
|
|
|
MoveRight,
|
2024-05-02 23:47:47 +02:00
|
|
|
}
|