ferrum_flow/plugins/
history.rs1use crate::plugin::{FlowEvent, Plugin};
2
3pub struct HistoryPlugin;
4
5impl HistoryPlugin {
6 pub fn new() -> Self {
7 Self {}
8 }
9}
10
11impl Plugin for HistoryPlugin {
12 fn name(&self) -> &'static str {
13 "history"
14 }
15 fn setup(&mut self, _ctx: &mut crate::plugin::InitPluginContext) {}
16 fn on_event(
17 &mut self,
18 event: &FlowEvent,
19 ctx: &mut crate::plugin::PluginContext,
20 ) -> crate::plugin::EventResult {
21 if let FlowEvent::Input(crate::plugin::InputEvent::KeyDown(ev)) = event {
22 if ev.keystroke.key == "z"
23 && ev.keystroke.modifiers.platform
24 && ev.keystroke.modifiers.shift
25 {
26 ctx.redo();
27 return crate::plugin::EventResult::Stop;
28 } else if ev.keystroke.key == "z" && ev.keystroke.modifiers.platform {
29 ctx.undo();
30 return crate::plugin::EventResult::Stop;
31 }
32 }
33 crate::plugin::EventResult::Continue
34 }
35}