Skip to content

Commit 2a4d869

Browse files
trepidityclaude
andcommitted
Add keybindings for switching between connection tabs
Wire up Ctrl+Right/Left for tab cycling and Ctrl+W for closing the active tab. Adds configurable next_tab/prev_tab/close_tab fields, a parameterless CloseCurrentTab action, and help popup entries. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c4a5df0 commit 2a4d869

5 files changed

Lines changed: 48 additions & 0 deletions

File tree

crates/loom-tui/src/action.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub enum Action {
4848
PrevTab,
4949
NewTab,
5050
CloseTab(ConnectionId),
51+
CloseCurrentTab,
5152
SwitchTab(ConnectionId),
5253

5354
// Connection

crates/loom-tui/src/app.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,17 @@ impl App {
17431743
self.connection_form.view_folder(&path, &description);
17441744
}
17451745

1746+
Action::CloseCurrentTab => {
1747+
if let Some(id) = self.active_tab_id {
1748+
self.tabs.retain(|t| t.id != id);
1749+
self.tab_bar.remove_tab(id);
1750+
self.active_tab_id = self.tab_bar.active_tab;
1751+
self.detail_panel.clear();
1752+
if self.active_tab_id.is_none() {
1753+
self.status_bar.set_disconnected();
1754+
}
1755+
}
1756+
}
17461757
Action::CloseTab(id) => {
17471758
self.tabs.retain(|t| t.id != id);
17481759
self.tab_bar.remove_tab(id);

crates/loom-tui/src/components/help_popup.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ fn build_sections(keymap: &Keymap) -> Vec<HelpSection> {
209209
keymap.hint("focus_prev").to_string(),
210210
"Previous panel".to_string(),
211211
),
212+
(
213+
keymap.hint("next_tab").to_string(),
214+
"Next tab".to_string(),
215+
),
216+
(
217+
keymap.hint("prev_tab").to_string(),
218+
"Previous tab".to_string(),
219+
),
220+
(
221+
keymap.hint("close_tab").to_string(),
222+
"Close tab".to_string(),
223+
),
212224
(keymap.hint("quit").to_string(), "Quit".to_string()),
213225
(
214226
keymap.hint("force_quit").to_string(),

crates/loom-tui/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ pub struct KeybindingConfig {
9191
pub save_connection: String,
9292
pub switch_to_browser: String,
9393
pub switch_to_profiles: String,
94+
pub next_tab: String,
95+
pub prev_tab: String,
96+
pub close_tab: String,
9497
}
9598

9699
impl Default for KeybindingConfig {
@@ -110,6 +113,9 @@ impl Default for KeybindingConfig {
110113
save_connection: "F10".to_string(),
111114
switch_to_browser: "F1".to_string(),
112115
switch_to_profiles: "F2".to_string(),
116+
next_tab: "Ctrl+Right".to_string(),
117+
prev_tab: "Ctrl+Left".to_string(),
118+
close_tab: "Ctrl+w".to_string(),
113119
}
114120
}
115121
}

crates/loom-tui/src/keymap.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,24 @@ impl Keymap {
199199
&defaults.switch_to_profiles,
200200
Action::SwitchLayout(ActiveLayout::Profiles),
201201
),
202+
(
203+
"next_tab",
204+
&config.next_tab,
205+
&defaults.next_tab,
206+
Action::NextTab,
207+
),
208+
(
209+
"prev_tab",
210+
&config.prev_tab,
211+
&defaults.prev_tab,
212+
Action::PrevTab,
213+
),
214+
(
215+
"close_tab",
216+
&config.close_tab,
217+
&defaults.close_tab,
218+
Action::CloseCurrentTab,
219+
),
202220
];
203221

204222
for (name, user_str, default_str, action) in bindings {

0 commit comments

Comments
 (0)