aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-05-10 17:24:19 +0200
committerGitHub <noreply@github.com>2021-05-10 17:24:19 +0200
commite2514b411cf168aa970a558c66ee0cb937c0a30c (patch)
tree2dbf111fd1dcdc62d91c3c2eba0b38fa02b9ba39 /src/common
parentFix exit code on `dump-default-config` (diff)
parentdocs(changelog): Switch tabs in normal mode #471 (diff)
downloadsl0ppij-e2514b411cf168aa970a558c66ee0cb937c0a30c.tar.gz
sl0ppij-e2514b411cf168aa970a558c66ee0cb937c0a30c.tar.xz
sl0ppij-e2514b411cf168aa970a558c66ee0cb937c0a30c.zip
Merge branch 'main' into dump-config-exit
Diffstat (limited to 'src/common')
-rw-r--r--src/common/errors.rs6
-rw-r--r--src/common/input/actions.rs3
-rw-r--r--src/common/input/handler.rs3
-rw-r--r--src/common/screen.rs22
4 files changed, 33 insertions, 1 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index 148a3a9e..c2caf19d 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -192,9 +192,11 @@ pub enum ScreenContext {
FocusNextPane,
FocusPreviousPane,
MoveFocusLeft,
+ MoveFocusLeftOrPreviousTab,
MoveFocusDown,
MoveFocusUp,
MoveFocusRight,
+ MoveFocusRightOrNextTab,
Exit,
ScrollUp,
ScrollDown,
@@ -237,9 +239,13 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::FocusNextPane => ScreenContext::FocusNextPane,
ScreenInstruction::FocusPreviousPane => ScreenContext::FocusPreviousPane,
ScreenInstruction::MoveFocusLeft => ScreenContext::MoveFocusLeft,
+ ScreenInstruction::MoveFocusLeftOrPreviousTab => {
+ ScreenContext::MoveFocusLeftOrPreviousTab
+ }
ScreenInstruction::MoveFocusDown => ScreenContext::MoveFocusDown,
ScreenInstruction::MoveFocusUp => ScreenContext::MoveFocusUp,
ScreenInstruction::MoveFocusRight => ScreenContext::MoveFocusRight,
+ ScreenInstruction::MoveFocusRightOrNextTab => ScreenContext::MoveFocusRightOrNextTab,
ScreenInstruction::Exit => ScreenContext::Exit,
ScreenInstruction::ScrollUp => ScreenContext::ScrollUp,
ScreenInstruction::ScrollDown => ScreenContext::ScrollDown,
diff --git a/src/common/input/actions.rs b/src/common/input/actions.rs
index 54cbbcdc..b806aa3f 100644
--- a/src/common/input/actions.rs
+++ b/src/common/input/actions.rs
@@ -29,6 +29,9 @@ pub enum Action {
/// Move the focus pane in specified direction.
SwitchFocus,
MoveFocus(Direction),
+ /// Tries to move the focus pane in specified direction.
+ /// If there is no pane in the direction, move to previous/next Tab.
+ MoveFocusOrTab(Direction),
/// Scroll up in focus pane.
ScrollUp,
/// Scroll down in focus pane.
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 78635237..aa204850 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -119,7 +119,8 @@ impl InputHandler {
| Action::GoToNextTab
| Action::GoToPreviousTab
| Action::CloseTab
- | Action::GoToTab(_) => {
+ | Action::GoToTab(_)
+ | Action::MoveFocusOrTab(_) => {
self.command_is_executing.blocking_input_thread();
self.os_input
.send_to_server(ServerInstruction::Action(action));
diff --git a/src/common/screen.rs b/src/common/screen.rs
index b12578a7..44cfe3ba 100644
--- a/src/common/screen.rs
+++ b/src/common/screen.rs
@@ -33,9 +33,11 @@ pub enum ScreenInstruction {
FocusNextPane,
FocusPreviousPane,
MoveFocusLeft,
+ MoveFocusLeftOrPreviousTab,
MoveFocusDown,
MoveFocusUp,
MoveFocusRight,
+ MoveFocusRightOrNextTab,
Exit,
ScrollUp,
ScrollDown,
@@ -422,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();
}