Implement event/response roundtrip (#49)

This commit is contained in:
TrueDoctor
2021-03-28 00:23:41 +01:00
committed by GitHub
parent 04dc05e575
commit 0e553adb32
9 changed files with 112 additions and 26 deletions
+14 -2
View File
@@ -1,6 +1,6 @@
mod color;
mod dispatcher;
mod error;
mod scheduler;
pub mod tools;
pub mod workspace;
@@ -10,6 +10,13 @@ pub use error::EditorError;
#[doc(inline)]
pub use color::Color;
#[doc(inline)]
pub use dispatcher::events;
#[doc(inline)]
pub use dispatcher::Callback;
use dispatcher::Dispatcher;
use tools::ToolState;
use workspace::Workspace;
@@ -17,13 +24,18 @@ use workspace::Workspace;
pub struct Editor {
pub tools: ToolState,
workspace: Workspace,
dispatcher: Dispatcher,
}
impl Editor {
pub fn new() -> Self {
pub fn new(callback: Callback) -> Self {
Self {
tools: ToolState::new(),
workspace: Workspace::new(),
dispatcher: Dispatcher::new(callback),
}
}
pub fn handle_event(&mut self, event: events::Event) -> Result<(), EditorError> {
self.dispatcher.handle_event(event)
}
}