Skip to content

Commit 4a545d5

Browse files
committed
Back-tab
1 parent 167d0aa commit 4a545d5

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/app.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,11 @@ impl App {
321321
self.session_view.next_pane();
322322
}
323323
}
324+
AppEvent::PreviousPane => {
325+
for _ in 0..self.take_motion() {
326+
self.session_view.prev_pane();
327+
}
328+
}
324329
AppEvent::Panic(message) => {
325330
terminal.clear().unwrap();
326331
terminal

src/event/input.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub enum AppEvent {
3838
UpdateSourceContext(String, String, u32),
3939
UpdateStatus(ContinuationStatus),
4040
NextPane,
41+
PreviousPane,
4142
Scroll(Scroll),
4243
ScrollSource(Scroll),
4344
ScrollContext(Scroll),

src/view/session.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::app::App;
88
use crate::app::CurrentView;
99
use crate::event::input::AppEvent;
1010
use crossterm::event::KeyCode;
11+
use crossterm::event::KeyModifiers;
1112
use ratatui::layout::Constraint;
1213
use ratatui::layout::Layout;
1314
use ratatui::layout::Rect;
@@ -24,10 +25,11 @@ impl View for SessionView {
2425
AppEvent::Input(key_event) => key_event,
2526
_ => return delegate_event_to_pane(app, event),
2627
};
27-
28+
2829
// handle global session events
2930
match input_event.code {
3031
KeyCode::Tab => return Some(AppEvent::NextPane),
32+
KeyCode::BackTab => return Some(AppEvent::PreviousPane),
3133
KeyCode::Enter => return Some(AppEvent::ToggleFullscreen),
3234
KeyCode::Char(char) => match char {
3335
'j' => return Some(AppEvent::Scroll((1, 0))),
@@ -209,6 +211,15 @@ impl SessionViewState {
209211
self.current_pane = next % self.panes.len();
210212
}
211213

214+
pub(crate) fn prev_pane(&mut self) {
215+
if self.current_pane == 0 {
216+
self.current_pane = self.panes.len() - 1;
217+
} else {
218+
let next = self.current_pane - 1;
219+
self.current_pane = next % self.panes.len();
220+
}
221+
}
222+
212223
fn current_pane(&self) -> &Pane {
213224
self.panes.get(self.current_pane).unwrap()
214225
}

0 commit comments

Comments
 (0)