diff --git a/src/command/keymap.rs b/src/command/keymap.rs index b38f97c..14a3090 100644 --- a/src/command/keymap.rs +++ b/src/command/keymap.rs @@ -18,6 +18,8 @@ pub enum KeyPattern { /// Matches any Char key (for text-entry modes). The actual char /// is available in CmdContext::key_code. AnyChar, + /// Matches any key at all (lowest priority fallback). + Any, } /// Identifies which mode a binding applies to. @@ -37,6 +39,7 @@ pub enum ModeKey { ExportPrompt, CommandMode, SearchMode, + ImportWizard, } impl ModeKey { @@ -55,6 +58,7 @@ impl ModeKey { AppMode::ItemAdd { .. } => Some(ModeKey::ItemAdd), AppMode::ExportPrompt { .. } => Some(ModeKey::ExportPrompt), AppMode::CommandMode { .. } => Some(ModeKey::CommandMode), + AppMode::ImportWizard => Some(ModeKey::ImportWizard), _ => None, } } @@ -103,13 +107,13 @@ impl Keymap { self.bindings .get(&KeyPattern::Key(key, mods)) .or_else(|| { - // Fall back to AnyChar for text-entry modes if matches!(key, KeyCode::Char(_)) { self.bindings.get(&KeyPattern::AnyChar) } else { None } }) + .or_else(|| self.bindings.get(&KeyPattern::Any)) .map(|c| c.as_ref()) } @@ -577,8 +581,7 @@ impl KeymapSet { // ── Command mode ───────────────────────────────────────────────── let mut cm = Keymap::new(); cm.bind_cmd(KeyCode::Esc, none, cmd::EnterMode(AppMode::Normal)); - // Enter → execute_command (still handled by old handler for now — - // the complex execute_command logic isn't easily a single Cmd) + cm.bind_cmd(KeyCode::Enter, none, cmd::ExecuteCommand); cm.bind_cmd(KeyCode::Backspace, none, cmd::CommandModeBackspace); cm.bind_any_char(cmd::AppendChar { buffer: "command".to_string(), @@ -593,6 +596,14 @@ impl KeymapSet { sm.bind_any_char(cmd::SearchAppendChar); set.insert(ModeKey::SearchMode, Arc::new(sm)); + // ── Import wizard mode ──────────────────────────────────────────── + let mut wiz = Keymap::new(); + // All keys are dispatched to the wizard effect, which handles + // step-specific behavior internally. + wiz.bindings + .insert(KeyPattern::Any, Arc::new(cmd::HandleWizardKey)); + set.insert(ModeKey::ImportWizard, Arc::new(wiz)); + set } }