From 62796c1a31a8babd2edf16054852f00bab0557df Mon Sep 17 00:00:00 2001 From: Dante Pippi <6619666+dantepippi@users.noreply.github.com> Date: Sun, 9 May 2021 17:24:15 -0300 Subject: [PATCH] After rebase --- src/client/tab.rs | 4 ++-- src/common/screen.rs | 20 ++++++++++++++++++++ src/server/route.rs | 8 ++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/client/tab.rs b/src/client/tab.rs index 7636be39..f0ec0869 100644 --- a/src/client/tab.rs +++ b/src/client/tab.rs @@ -1848,7 +1848,7 @@ impl Tab { } self.render(); } - // returns a boolean to allow the caller to know if the move happened or not + // returns a boolean that indicates whether the focus moved pub fn move_focus_left(&mut self) -> bool { if !self.has_selectable_panes() { return false; @@ -1941,7 +1941,7 @@ impl Tab { } self.render(); } - // returns a boolean to allow the caller to know if the move happened or not + // returns a boolean that indicates whether the focus moved pub fn move_focus_right(&mut self) -> bool { if !self.has_selectable_panes() { return false; diff --git a/src/common/screen.rs b/src/common/screen.rs index 525575bf..44cfe3ba 100644 --- a/src/common/screen.rs +++ b/src/common/screen.rs @@ -424,12 +424,32 @@ pub fn screen_thread_main( ScreenInstruction::MoveFocusLeft => { screen.get_active_tab_mut().unwrap().move_focus_left(); } + ScreenInstruction::MoveFocusLeftOrPreviousTab => { + if !screen.get_active_tab_mut().unwrap().move_focus_left() { + screen.switch_tab_prev(); + } + screen + .bus + .senders + .send_to_server(ServerInstruction::UnblockInputThread) + .unwrap(); + } ScreenInstruction::MoveFocusDown => { screen.get_active_tab_mut().unwrap().move_focus_down(); } ScreenInstruction::MoveFocusRight => { screen.get_active_tab_mut().unwrap().move_focus_right(); } + ScreenInstruction::MoveFocusRightOrNextTab => { + if !screen.get_active_tab_mut().unwrap().move_focus_right() { + screen.switch_tab_next(); + } + screen + .bus + .senders + .send_to_server(ServerInstruction::UnblockInputThread) + .unwrap(); + } ScreenInstruction::MoveFocusUp => { screen.get_active_tab_mut().unwrap().move_focus_up(); } diff --git a/src/server/route.rs b/src/server/route.rs index 1fa5825a..668cdfbd 100644 --- a/src/server/route.rs +++ b/src/server/route.rs @@ -78,6 +78,14 @@ fn route_action(action: Action, session: &SessionMetaData, os_input: &dyn Server }; session.senders.send_to_screen(screen_instr).unwrap(); } + Action::MoveFocusOrTab(direction) => { + let screen_instr = match direction { + Direction::Left => ScreenInstruction::MoveFocusLeftOrPreviousTab, + Direction::Right => ScreenInstruction::MoveFocusRightOrNextTab, + _ => unreachable!(), + }; + session.senders.send_to_screen(screen_instr).unwrap(); + } Action::ScrollUp => { session .senders