ratatui_toolkit/widgets/code_diff/widget/methods/
scroll_down.rs

1use crate::widgets::code_diff::code_diff::CodeDiff;
2
3impl CodeDiff {
4    /// Scrolls down by the specified number of lines.
5    ///
6    /// The scroll is clamped to the maximum scrollable position.
7    ///
8    /// # Arguments
9    ///
10    /// * `lines` - Number of lines to scroll down
11    ///
12    /// # Example
13    ///
14    /// ```rust
15    /// use ratatui_toolkit::code_diff::CodeDiff;
16    ///
17    /// let mut diff = CodeDiff::new();
18    /// diff.scroll_down(5);
19    /// // scroll_offset is now 5 (or less if content is shorter)
20    /// ```
21    pub fn scroll_down(&mut self, lines: usize) {
22        let max_scroll = self.total_lines();
23        self.scroll_offset = (self.scroll_offset + lines).min(max_scroll);
24    }
25}