(&mut self, state: &mut AppState, event: Event)
| 313 | } |
| 314 | |
| 315 | fn handle_event(&mut self, state: &mut AppState, event: Event) -> EventControlFlow { |
| 316 | let mut result = EventResult::default(); |
| 317 | match event { |
| 318 | Event::Key(event) |
| 319 | if matches!(event.kind, KeyEventKind::Press | KeyEventKind::Repeat) => |
| 320 | { |
| 321 | match event.code { |
| 322 | // Quit |
| 323 | KeyCode::Esc | KeyCode::Char('q') => return EventControlFlow::Break, |
| 324 | // Page up |
| 325 | KeyCode::PageUp => { |
| 326 | self.page_up(false); |
| 327 | result.redraw = true; |
| 328 | } |
| 329 | // Page up (shift + space) |
| 330 | KeyCode::Char(' ') if event.modifiers.contains(KeyModifiers::SHIFT) => { |
| 331 | self.page_up(false); |
| 332 | result.redraw = true; |
| 333 | } |
| 334 | // Page down |
| 335 | KeyCode::Char(' ') | KeyCode::PageDown => { |
| 336 | self.page_down(false); |
| 337 | result.redraw = true; |
| 338 | } |
| 339 | // Page down (ctrl + f) |
| 340 | KeyCode::Char('f') if event.modifiers.contains(KeyModifiers::CONTROL) => { |
| 341 | self.page_down(false); |
| 342 | result.redraw = true; |
| 343 | } |
| 344 | // Page up (ctrl + b) |
| 345 | KeyCode::Char('b') if event.modifiers.contains(KeyModifiers::CONTROL) => { |
| 346 | self.page_up(false); |
| 347 | result.redraw = true; |
| 348 | } |
| 349 | // Half page down (ctrl + d) |
| 350 | KeyCode::Char('d') if event.modifiers.contains(KeyModifiers::CONTROL) => { |
| 351 | self.page_down(true); |
| 352 | result.redraw = true; |
| 353 | } |
| 354 | // Half page up (ctrl + u) |
| 355 | KeyCode::Char('u') if event.modifiers.contains(KeyModifiers::CONTROL) => { |
| 356 | self.page_up(true); |
| 357 | result.redraw = true; |
| 358 | } |
| 359 | // Scroll down |
| 360 | KeyCode::Down | KeyCode::Char('j') => { |
| 361 | self.scroll_y += 1; |
| 362 | result.redraw = true; |
| 363 | } |
| 364 | // Scroll up |
| 365 | KeyCode::Up | KeyCode::Char('k') => { |
| 366 | self.scroll_y = self.scroll_y.saturating_sub(1); |
| 367 | result.redraw = true; |
| 368 | } |
| 369 | // Scroll to start |
| 370 | KeyCode::Char('g') => { |
| 371 | self.scroll_y = 0; |
| 372 | result.redraw = true; |
no test coverage detected