Skip to main content

romm_cli/tui/screens/setup_wizard/
event.rs

1//! Setup wizard event → action mapping.
2
3use crossterm::event::KeyEvent;
4
5/// Raw input for the setup wizard loop.
6#[derive(Debug)]
7pub enum SetupEvent {
8    Key(KeyEvent),
9    Paste(String),
10}
11
12/// Semantic intents for [`super::SetupWizard::update`].
13#[derive(Debug)]
14pub enum SetupAction {
15    Key(KeyEvent),
16    Paste(String),
17}
18
19pub fn map_setup_event(event: SetupEvent) -> SetupAction {
20    match event {
21        SetupEvent::Key(key) => SetupAction::Key(key),
22        SetupEvent::Paste(text) => SetupAction::Paste(text),
23    }
24}
25
26impl super::SetupWizard {
27    /// Returns `true` when the wizard should exit (cancelled).
28    pub fn update(&mut self, action: SetupAction) -> anyhow::Result<bool> {
29        match action {
30            SetupAction::Key(key) => self.handle_key(&key),
31            SetupAction::Paste(text) => {
32                self.handle_paste(&text);
33                Ok(false)
34            }
35        }
36    }
37}