Skip to content

Commit

Permalink
Derive Display for Reflection Events
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Reiter committed Sep 28, 2024
1 parent a0b4844 commit 98047d3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions wireman/src/events/selection/reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,17 @@ pub enum ReflectionDialogEvents {

pub enum ReflectionEvents {
CloseDialog,
TriggerReflection,
ReflectServer,
}

impl std::fmt::Display for ReflectionEvents {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let display_str = match self {
ReflectionEvents::ReflectServer => "Reflect server",
ReflectionEvents::CloseDialog => "Close dialog",
};
write!(f, "{display_str}")
}
}

pub struct ReflectionDialogEventHandler;
Expand All @@ -39,7 +49,7 @@ impl EventHandler for ReflectionDialogEventHandler {
ServicesSelectionEventsHandler::handle_event(event, ctx)
}
ReflectionDialogEvents::ReflectionEvents(events) => match events {
ReflectionEvents::TriggerReflection => {
ReflectionEvents::ReflectServer => {
ctx.reflection.borrow_mut().dispatch_reflection()
}
ReflectionEvents::CloseDialog => {
Expand Down Expand Up @@ -74,7 +84,7 @@ impl EventHandler for ReflectionDialogEventHandler {
),
(
KeyEvent::new(KeyCode::Enter),
ReflectionDialogEvents::ReflectionEvents(ReflectionEvents::TriggerReflection),
ReflectionDialogEvents::ReflectionEvents(ReflectionEvents::ReflectServer),
),
(
KeyEvent::ctrl(KeyCode::Char('r')),
Expand Down

0 comments on commit 98047d3

Please sign in to comment.