Skip to content

Commit

Permalink
feat(ui): allow to navigate session manager tabs in reversed order
Browse files Browse the repository at this point in the history
* navigate session managed tabs in reversed order (rtl) when shift
  modifier is held
  • Loading branch information
lpiepiora committed Aug 6, 2024
1 parent 47caeb6 commit 8a0ecb6
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions default-plugins/session-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ impl State {
should_render = true;
},
BareKey::Tab if key.has_no_modifiers() => {
self.toggle_active_screen();
self.toggle_active_screen_ltr();
should_render = true;
},
BareKey::Tab if key.has_modifiers(&[KeyModifier::Shift]) => {
self.toggle_active_screen_rtl();
should_render = true;
},
BareKey::Char('f') if key.has_modifiers(&[KeyModifier::Ctrl]) => {
Expand Down Expand Up @@ -372,7 +376,11 @@ impl State {
should_render = true;
},
BareKey::Tab if key.has_no_modifiers() => {
self.toggle_active_screen();
self.toggle_active_screen_ltr();
should_render = true;
},
BareKey::Tab if key.has_modifiers(&[KeyModifier::Shift]) => {
self.toggle_active_screen_rtl();
should_render = true;
},
BareKey::Esc if key.has_no_modifiers() => {
Expand Down Expand Up @@ -420,7 +428,11 @@ impl State {
should_render = true;
},
BareKey::Tab if key.has_no_modifiers() => {
self.toggle_active_screen();
self.toggle_active_screen_ltr();
should_render = true;
},
BareKey::Tab if key.has_modifiers(&[KeyModifier::Shift]) => {
self.toggle_active_screen_rtl();
should_render = true;
},
BareKey::Delete if key.has_no_modifiers() => {
Expand Down Expand Up @@ -514,13 +526,20 @@ impl State {
},
}
}
fn toggle_active_screen(&mut self) {
fn toggle_active_screen_ltr(&mut self) {
self.active_screen = match self.active_screen {
ActiveScreen::NewSession => ActiveScreen::AttachToSession,
ActiveScreen::AttachToSession => ActiveScreen::ResurrectSession,
ActiveScreen::ResurrectSession => ActiveScreen::NewSession,
};
}
fn toggle_active_screen_rtl(&mut self) {
self.active_screen = match self.active_screen {
ActiveScreen::NewSession => ActiveScreen::ResurrectSession,
ActiveScreen::AttachToSession => ActiveScreen::NewSession,
ActiveScreen::ResurrectSession => ActiveScreen::AttachToSession,
};
}
fn show_error(&mut self, error_text: &str) {
self.error = Some(error_text.to_owned());
}
Expand Down

0 comments on commit 8a0ecb6

Please sign in to comment.