Skip to content

Commit 0d38597

Browse files
feat: add trackpad scroll support for navigation
Handle mouse scroll events to allow vertical and horizontal scrolling with trackpad gestures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 0bea6e9 commit 0d38597

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use ratatui::{
2323
Terminal,
2424
backend::CrosstermBackend,
2525
crossterm::{
26-
event::{self, DisableMouseCapture, EnableMouseCapture, Event},
26+
event::{self, DisableMouseCapture, EnableMouseCapture, Event, MouseEventKind},
2727
execute,
2828
terminal::{EnterAlternateScreen, LeaveAlternateScreen, disable_raw_mode, enable_raw_mode},
2929
},
@@ -243,10 +243,18 @@ fn run_app(terminal: &mut Terminal<CrosstermBackend<io::Stdout>>, app: &mut App)
243243
terminal.draw(|f| ui::render(f, app))?;
244244

245245
// Handle events
246-
if event::poll(Duration::from_millis(100))?
247-
&& let Event::Key(key) = event::read()?
248-
{
249-
input::handle_key(app, key, visible_rows);
246+
if event::poll(Duration::from_millis(100))? {
247+
match event::read()? {
248+
Event::Key(key) => input::handle_key(app, key, visible_rows),
249+
Event::Mouse(mouse) => match mouse.kind {
250+
MouseEventKind::ScrollUp => app.cursor_up(),
251+
MouseEventKind::ScrollDown => app.cursor_down(),
252+
MouseEventKind::ScrollLeft => app.cursor_left(),
253+
MouseEventKind::ScrollRight => app.cursor_right(),
254+
_ => {}
255+
},
256+
_ => {}
257+
}
250258
}
251259

252260
if app.should_quit {

0 commit comments

Comments
 (0)