diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-12 00:24:13 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-05-12 00:24:13 +0300 |
| commit | 520f4272d0f332f2a98a2a7486be1797feb86dcf (patch) | |
| tree | f53830efc04e6961d7b0cd003bc453b95a714fe1 /src/app/input/navigate.rs | |
| parent | 8d5dca8cfe2d580835d3392d0ebdff57f7de7298 (diff) | |
feat: add agent cycling and tab wheel switching
fixes #92
Diffstat (limited to 'src/app/input/navigate.rs')
| -rw-r--r-- | src/app/input/navigate.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/app/input/navigate.rs b/src/app/input/navigate.rs index ce3d9cf4..6dfaf475 100644 --- a/src/app/input/navigate.rs +++ b/src/app/input/navigate.rs @@ -31,6 +31,18 @@ pub(crate) fn terminal_direct_navigation_action( return Some(NavigateAction::NextWorkspace); } if kb + .previous_agent + .is_some_and(|(code, mods)| key_matches(key, code, mods)) + { + return Some(NavigateAction::PreviousAgent); + } + if kb + .next_agent + .is_some_and(|(code, mods)| key_matches(key, code, mods)) + { + return Some(NavigateAction::NextAgent); + } + if kb .previous_tab .is_some_and(|(code, mods)| key_matches(key, code, mods)) { @@ -363,6 +375,8 @@ pub(crate) enum NavigateAction { CloseWorkspace, PreviousWorkspace, NextWorkspace, + PreviousAgent, + NextAgent, NewTab, RenameTab, PreviousTab, @@ -407,6 +421,18 @@ fn navigate_action_for_key(state: &AppState, key: &KeyEvent) -> Option<NavigateA { return Some(NavigateAction::NextWorkspace); } + if kb + .previous_agent + .is_some_and(|(code, mods)| key_matches(key, code, mods)) + { + return Some(NavigateAction::PreviousAgent); + } + if kb + .next_agent + .is_some_and(|(code, mods)| key_matches(key, code, mods)) + { + return Some(NavigateAction::NextAgent); + } if key_matches(key, kb.new_tab.0, kb.new_tab.1) { return Some(NavigateAction::NewTab); } @@ -508,6 +534,14 @@ pub(super) fn execute_navigate_action(state: &mut AppState, action: NavigateActi state.next_workspace(); leave_navigate_mode(state); } + NavigateAction::PreviousAgent => { + state.previous_agent(); + leave_navigate_mode(state); + } + NavigateAction::NextAgent => { + state.next_agent(); + leave_navigate_mode(state); + } NavigateAction::NewTab => super::modal::open_new_tab_dialog(state), NavigateAction::RenameTab => super::modal::open_rename_active_tab(state, false), NavigateAction::PreviousTab => { @@ -730,6 +764,20 @@ mod tests { } #[test] + fn terminal_direct_agent_shortcut_maps_to_navigation_action() { + let mut state = state_with_workspaces(&["test"]); + state.keybinds.next_agent = Some((KeyCode::Char('a'), KeyModifiers::ALT)); + state.keybinds.next_agent_label = Some("alt+a".into()); + + let action = terminal_direct_navigation_action( + &state, + &KeyEvent::new(KeyCode::Char('a'), KeyModifiers::ALT), + ); + + assert_eq!(action, Some(NavigateAction::NextAgent)); + } + + #[test] fn terminal_direct_focus_pane_shortcut_maps_to_navigation_action() { let mut state = state_with_workspaces(&["test"]); state.keybinds.focus_pane_left = Some((KeyCode::Left, KeyModifiers::ALT)); |
