diff --git a/src/tui/layout.rs b/src/tui/layout.rs index 5ddaab2..4a2edb8 100644 --- a/src/tui/layout.rs +++ b/src/tui/layout.rs @@ -183,7 +183,7 @@ impl App { fn handle_key_event(&mut self, key_event: KeyEvent) -> color_eyre::Result<()> { if self.focused == FocusedArea::StatusExpanded { match key_event.code { - KeyCode::Char('S') | KeyCode::Char('q') | KeyCode::Esc => { + KeyCode::Char('S') | KeyCode::Esc => { self.focused = self.pre_overlay_focused; self.log_scroll = 0; return Ok(()); @@ -204,7 +204,7 @@ impl App { if self.focused == FocusedArea::ConfirmDelete { match key_event.code { - KeyCode::Char('y') | KeyCode::Char('Y') => { + KeyCode::Enter | KeyCode::Char('y') | KeyCode::Char('Y') => { let name = confirm_popup::pending_delete_name(); if !name.is_empty() { match self.instance_manager.delete(&name) { @@ -220,7 +220,7 @@ impl App { self.focused = FocusedArea::Profiles; return Ok(()); } - KeyCode::Char('n') | KeyCode::Char('N') => { + KeyCode::Esc | KeyCode::Char('n') | KeyCode::Char('N') => { confirm_popup::clear_pending(); self.focused = FocusedArea::Profiles; return Ok(()); @@ -362,8 +362,7 @@ impl App { .title_bottom( crate::tui::widgets::popups::keybind_line(&[ ("j/k", " scroll"), - ("S", " close"), - ("q", " close"), + ("S/Esc", " close"), ]) .alignment(Alignment::Right), ) @@ -401,14 +400,14 @@ impl App { let clamped = scroll.min(total.saturating_sub(1)); let list_area = Rect { - width: inner.width.saturating_sub(1), + width: inner.width, ..inner }; let scrollbar_area = Rect { - x: inner.x + inner.width.saturating_sub(1), - y: inner.y, + x: overlay.x + overlay.width.saturating_sub(1), + y: overlay.y + 1, width: 1, - height: inner.height, + height: overlay.height.saturating_sub(2), }; let list = List::new(items); diff --git a/src/tui/widgets/popups/confirm.rs b/src/tui/widgets/popups/confirm.rs index 231251c..87428bf 100644 --- a/src/tui/widgets/popups/confirm.rs +++ b/src/tui/widgets/popups/confirm.rs @@ -69,7 +69,7 @@ impl Widget for ConfirmPopup { .fg(THEME.colors.border_focused) .add_modifier(Modifier::BOLD), )]); - let kb = keybind_line(&[("y", " yes"), ("n", " no")]); + let kb = keybind_line(&[("Enter", " confirm"), ("Esc", " cancel")]); let popup = PopupFrame { title, diff --git a/src/tui/widgets/popups/new_instance.rs b/src/tui/widgets/popups/new_instance.rs index da188b4..7275d9c 100644 --- a/src/tui/widgets/popups/new_instance.rs +++ b/src/tui/widgets/popups/new_instance.rs @@ -168,8 +168,8 @@ pub fn handle_key(key_event: &KeyEvent, profiles_state: &mut profiles::State) { match state.step { WizardStep::Name => handle_name_key(&mut state, key_event, profiles_state), WizardStep::Version => handle_version_key(&mut state, key_event, profiles_state), - WizardStep::Loader => handle_loader_key(&mut state, key_event), - WizardStep::LoaderVersion => handle_loader_version_key(&mut state, key_event), + WizardStep::Loader => handle_loader_key(&mut state, key_event, profiles_state), + WizardStep::LoaderVersion => handle_loader_version_key(&mut state, key_event, profiles_state), WizardStep::Confirm => handle_confirm_key(&mut state, key_event, profiles_state), } } @@ -220,8 +220,10 @@ fn handle_name_key( profiles_state: &mut profiles::State, ) { match key_event.code { - KeyCode::Esc => close_popup(state, profiles_state), - KeyCode::Enter => { + KeyCode::Esc | KeyCode::Left | KeyCode::Char('h') => { + close_popup(state, profiles_state); + } + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') => { if state.name_input.trim().is_empty() { return; } @@ -280,9 +282,12 @@ fn handle_version_key( state.version_search.clear(); clamp_version_index(state); } else { - state.step = WizardStep::Loader; + close_popup(state, profiles_state); } } + KeyCode::Left | KeyCode::Char('h') if !state.version_search_active => { + state.step = WizardStep::Loader; + } KeyCode::Char('j') | KeyCode::Down => { if visible_count > 0 { state.version_idx = (state.version_idx + 1).min(visible_count.saturating_sub(1)); @@ -291,7 +296,7 @@ fn handle_version_key( KeyCode::Char('k') | KeyCode::Up => { state.version_idx = state.version_idx.saturating_sub(1); } - KeyCode::Char('s') => { + KeyCode::Char('s') if !state.version_search_active => { state.show_snapshots = !state.show_snapshots; clamp_version_index(state); } @@ -299,7 +304,7 @@ fn handle_version_key( state.version_search_active = true; state.version_idx = 0; } - KeyCode::Enter => { + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') if !state.version_search_active => { if state.selected_version().is_none() { return; } @@ -316,21 +321,28 @@ fn handle_version_key( } } } - KeyCode::Char('q') => close_popup(state, profiles_state), + KeyCode::Enter if state.version_search_active => { + state.version_search_active = false; + } _ => {} } } -fn handle_loader_key(state: &mut WizardState, key_event: &KeyEvent) { +fn handle_loader_key( + state: &mut WizardState, + key_event: &KeyEvent, + profiles_state: &mut profiles::State, +) { match key_event.code { - KeyCode::Esc => state.step = WizardStep::Name, + KeyCode::Esc => close_popup(state, profiles_state), + KeyCode::Left | KeyCode::Char('h') => state.step = WizardStep::Name, KeyCode::Char('j') | KeyCode::Down => { state.loader_idx = (state.loader_idx + 1).min(4); } KeyCode::Char('k') | KeyCode::Up => { state.loader_idx = state.loader_idx.saturating_sub(1); } - KeyCode::Enter => { + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') => { state.versions = LoadState::Idle; state.version_idx = 0; state.version_search.clear(); @@ -342,7 +354,11 @@ fn handle_loader_key(state: &mut WizardState, key_event: &KeyEvent) { } } -fn handle_loader_version_key(state: &mut WizardState, key_event: &KeyEvent) { +fn handle_loader_version_key( + state: &mut WizardState, + key_event: &KeyEvent, + profiles_state: &mut profiles::State, +) { if state.selected_loader() == ModLoader::Vanilla { state.step = WizardStep::Confirm; return; @@ -354,7 +370,8 @@ fn handle_loader_version_key(state: &mut WizardState, key_event: &KeyEvent) { }; match key_event.code { - KeyCode::Esc => state.step = WizardStep::Version, + KeyCode::Esc => close_popup(state, profiles_state), + KeyCode::Left | KeyCode::Char('h') => state.step = WizardStep::Version, KeyCode::Char('j') | KeyCode::Down => { if version_count > 0 { state.loader_version_idx = @@ -364,7 +381,7 @@ fn handle_loader_version_key(state: &mut WizardState, key_event: &KeyEvent) { KeyCode::Char('k') | KeyCode::Up => { state.loader_version_idx = state.loader_version_idx.saturating_sub(1); } - KeyCode::Enter => { + KeyCode::Enter | KeyCode::Right | KeyCode::Char('l') => { if state.selected_loader_version().is_none() { return; } @@ -380,7 +397,8 @@ fn handle_confirm_key( profiles_state: &mut profiles::State, ) { match key_event.code { - KeyCode::Esc => { + KeyCode::Esc => close_popup(state, profiles_state), + KeyCode::Left | KeyCode::Char('h') => { if state.selected_loader() == ModLoader::Vanilla { state.step = WizardStep::Version; } else { @@ -436,11 +454,11 @@ fn wizard_title(_state: &WizardState) -> Line<'static> { fn step_keybinds(state: &WizardState) -> ratatui::text::Line<'static> { use super::keybind_line; match state.step { - WizardStep::Name => keybind_line(&[("Enter", " continue"), ("Esc", " close")]), - WizardStep::Version => keybind_line(&[("j/k", " move"), ("/", " search"), ("s", " snapshots"), ("Enter", " select"), ("Esc", " back")]), - WizardStep::Loader => keybind_line(&[("j/k", " move"), ("Enter", " select"), ("Esc", " back")]), - WizardStep::LoaderVersion => keybind_line(&[("j/k", " move"), ("Enter", " select"), ("Esc", " back")]), - WizardStep::Confirm => keybind_line(&[("Enter", " create"), ("Esc", " back")]), + WizardStep::Name => keybind_line(&[("Enter", " continue"), ("Esc", " cancel")]), + WizardStep::Loader => keybind_line(&[("j/k", " move"), ("h", " back"), ("l/Enter", " select"), ("Esc", " cancel")]), + WizardStep::Version => keybind_line(&[("j/k", " move"), ("/", " search"), ("s", " snapshots"), ("h", " back"), ("l/Enter", " select"), ("Esc", " cancel")]), + WizardStep::LoaderVersion => keybind_line(&[("j/k", " move"), ("h", " back"), ("l/Enter", " select"), ("Esc", " cancel")]), + WizardStep::Confirm => keybind_line(&[("h", " back"), ("Enter", " create"), ("Esc", " cancel")]), } }