Skip to content

Commit cd05b51

Browse files
committed
Add support for arrow keys
1 parent d0f3cad commit cd05b51

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ main
66

77
- Introduce eval feature
88
- Improve scrolling performance on large files and contexts
9+
- Add support for arrow key scrolling
910
- Fix position of closing braces in context view
1011
- Show historic inline values
1112
- Do not show "undefined" variables

src/view/session.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::app::ListenStatus;
1212
use crate::app::SelectedView;
1313
use crate::event::input::AppEvent;
1414
use crossterm::event::KeyCode;
15+
use crossterm::event::KeyModifiers;
1516
use ratatui::layout::Constraint;
1617
use ratatui::layout::Layout;
1718
use ratatui::layout::Rect;
@@ -35,11 +36,17 @@ impl View for SessionView {
3536
return delegate_event_to_pane(app, event);
3637
}
3738

39+
let multiplier = if KeyModifiers::SHIFT == input_event.modifiers & KeyModifiers::SHIFT { 10 } else { 1 };
40+
3841
// handle global session events
3942
match input_event.code {
4043
KeyCode::Tab => return Some(AppEvent::NextPane),
4144
KeyCode::BackTab => return Some(AppEvent::PreviousPane),
4245
KeyCode::Enter => return Some(AppEvent::ToggleFullscreen),
46+
KeyCode::Left => return Some(AppEvent::Scroll((0, -1 * multiplier))),
47+
KeyCode::Right => return Some(AppEvent::Scroll((0, 1 * multiplier))),
48+
KeyCode::Up => return Some(AppEvent::Scroll((-1 * multiplier, 0))),
49+
KeyCode::Down => return Some(AppEvent::Scroll((1 * multiplier, 0))),
4350
KeyCode::Char(char) => match char {
4451
'e' => return Some(AppEvent::EvalStart),
4552
'j' => return Some(AppEvent::Scroll((1, 0))),

0 commit comments

Comments
 (0)