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 afb6a28
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions default-plugins/session-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod new_session_info;
mod resurrectable_sessions;
mod session_list;
mod ui;
use plugin_api::key::ProtobufKeyModifier;
use std::collections::BTreeMap;
use uuid::Uuid;
use zellij_tile::prelude::*;
Expand Down Expand Up @@ -218,7 +219,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 +377,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 +429,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 +527,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 afb6a28

Please sign in to comment.