Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): allow to navigate session manager tabs in reversed order #3544

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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