From be6eed684ddca8140f3aeb9e6dab0b58b727a481 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sun, 24 Jul 2022 10:37:15 +0900 Subject: [PATCH] rename parameters of `TextArea::scroll` --- src/textarea.rs | 13 +++++++------ src/widget.rs | 6 +++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/textarea.rs b/src/textarea.rs index 0152301..9ca070c 100644 --- a/src/textarea.rs +++ b/src/textarea.rs @@ -481,6 +481,7 @@ impl<'a> TextArea<'a> { } /// Handle a key input without default key mappings. This method handles only + /// /// - Single character input without modifier keys /// - Tab /// - Enter @@ -1492,10 +1493,10 @@ impl<'a> TextArea<'a> { self.search.style = style; } - /// Scroll the textarea by `delta_row` rows (vertically) and `delta_col` columns (horizontally). Positive scroll - /// amount means scrolling down or right. And negative scroll amount means scrolling up or left. The cursor will not - /// move until it goes out the viewport. When the cursor position is outside the viewport after scroll, the cursor - /// position will be adjusted to stay in the viewport using the same logic as [`CursorMove::InViewport`]. + /// Scroll the textarea by `rows` lines (vertically) and `cols` columns (horizontally). Positive scroll amount means + /// scrolling down or right. And negative scroll amount means scrolling up or left. The cursor will not move until + /// it goes out the viewport. When the cursor position is outside the viewport after scroll, the cursor position will + /// be adjusted to stay in the viewport using the same logic as [`CursorMove::InViewport`]. /// /// ``` /// # use tui::buffer::Buffer; @@ -1531,8 +1532,8 @@ impl<'a> TextArea<'a> { /// textarea.scroll(-5, 0); /// assert_eq!(textarea.cursor(), (12, 0)); /// ``` - pub fn scroll(&mut self, delta_row: i16, delta_col: i16) { - self.viewport.scroll(delta_row, delta_col); + pub fn scroll(&mut self, rows: i16, cols: i16) { + self.viewport.scroll(rows, cols); self.move_cursor(CursorMove::InViewport); } } diff --git a/src/widget.rs b/src/widget.rs index 23e2348..4278183 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -56,7 +56,7 @@ impl Viewport { self.0.store(u, Ordering::Relaxed); } - pub fn scroll(&mut self, delta_row: i16, delta_col: i16) { + pub fn scroll(&mut self, rows: i16, cols: i16) { fn apply_scroll(pos: u16, delta: i16) -> u16 { if delta >= 0 { pos.saturating_add(delta as u16) @@ -66,8 +66,8 @@ impl Viewport { } let u = self.0.get_mut(); - let row = apply_scroll((*u >> 16) as u16, delta_row); - let col = apply_scroll(*u as u16, delta_col); + let row = apply_scroll((*u >> 16) as u16, rows); + let col = apply_scroll(*u as u16, cols); *u = (*u & 0xffff_ffff_0000_0000) | ((row as u64) << 16) | (col as u64); } }