Skip to content

Commit

Permalink
Multiplexer: Add new command: FocusTab
Browse files Browse the repository at this point in the history
  • Loading branch information
algon-320 committed Jan 2, 2024
1 parent 59bd16d commit 64191f9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/multiplexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ enum Command {
FocusRight,
FocusNextTab,
FocusPrevTab,
FocusTab(usize),
SplitVertical,
SplitHorizontal,
ResizeIncreaseLeft,
Expand Down Expand Up @@ -469,6 +470,12 @@ impl TabbedLayout {
self.focused_mut().focused_window_mut().focus_changed(true);
true
}
Command::FocusTab(n) => {
self.focused_mut().focused_window_mut().focus_changed(false);
self.focus = n % self.tabs.len();
self.focused_mut().focused_window_mut().focus_changed(true);
true
}

Command::SaveLayout | Command::RestoreLayout => {
for tab in self.tabs.iter_mut().flatten() {
Expand Down Expand Up @@ -992,7 +999,10 @@ impl Multiplexer {
self.main_layout.process_command(&self.display, cmd);
}

Command::FocusNextTab | Command::FocusPrevTab | Command::AddNewTab => {
Command::FocusNextTab
| Command::FocusPrevTab
| Command::FocusTab(_)
| Command::AddNewTab => {
self.main_layout.process_command(&self.display, cmd);
self.update_status_bar();
}
Expand Down Expand Up @@ -1091,6 +1101,10 @@ impl Controller {
'c' => Some(Command::AddNewTab),
'n' => Some(Command::FocusNextTab),
'p' => Some(Command::FocusPrevTab),
digit @ ('0'..='9') => {
let n = digit as u32 - '0' as u32;
Some(Command::FocusTab(n as usize))
}
'%' => Some(Command::SplitVertical),
'"' => Some(Command::SplitHorizontal),
's' => Some(Command::SaveLayout),
Expand Down

0 comments on commit 64191f9

Please sign in to comment.