Skip to main content

tui/
scroll.rs

1//! The scroll intents of the report table and the read-only overlays, applied to their window.
2
3use tvui::RowWindow;
4
5use crate::event::Intent;
6
7/// Scrolls `window` by the intent; other intents are not scrolling.
8#[must_use]
9pub fn apply(window: &RowWindow, intent: Intent) -> bool {
10    match intent {
11        Intent::ScrollLineUp => window.scroll_up(1),
12        Intent::ScrollLineDown => window.scroll_down(1),
13        Intent::ScrollPageUp => window.page_up(),
14        Intent::ScrollPageDown => window.page_down(),
15        Intent::ScrollTop => window.to_start(),
16        Intent::ScrollEnd => window.to_end(),
17        _ => return false,
18    }
19    true
20}
21
22#[cfg(test)]
23mod tests;