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-16 10:10:11 +02:00
|
|
|
OpenCreateItemDialogBelow,
|
2024-05-10 12:03:38 +02:00
|
|
|
OpenEditItemDialog { item: GraphItem },
|
2024-06-30 17:31:25 +02:00
|
|
|
OpenEditor { 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
|
|
|
|
2024-05-12 21:11:08 +02:00
|
|
|
GraphUpdated(IOEvent<GraphItem>),
|
2024-05-12 21:07:21 +02:00
|
|
|
ItemCreated(IOEvent<()>),
|
|
|
|
ItemUpdated(IOEvent<()>),
|
|
|
|
SectionCreated(IOEvent<()>),
|
|
|
|
ItemToggled(IOEvent<()>),
|
2024-06-01 13:13:18 +02:00
|
|
|
Archive(IOEvent<()>),
|
2024-05-14 23:30:20 +02:00
|
|
|
|
|
|
|
OpenUpdateItemDialog(IOEvent<()>),
|
2024-06-30 17:31:25 +02:00
|
|
|
|
|
|
|
OpenItem(IOEvent<()>),
|
2024-05-12 21:07:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum IOEvent<T> {
|
|
|
|
Initialized,
|
|
|
|
Optimistic(T),
|
|
|
|
Success(T),
|
|
|
|
Failure(String),
|
2024-05-12 14:29:14 +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
|
|
|
}
|