Skip to content

Commit f31a3b5

Browse files
committed
version 0.31.1
1 parent a45f387 commit f31a3b5

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*If you're reading this because you try make sense of some new API or a breaking change, you might also be interested in coming to the chat for explanations or guidance.*
22

3+
<a name="v0.31.1"></a>
4+
### v0.31.1 - 2024-11-17
5+
- TextView::try_scroll_pages now accepts float values (anything `Into<f64>`)
6+
37
<a name="v0.31.0"></a>
48
### v0.31.0 - 2024-10-26
59
- reexport crossbeam

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "termimad"
3-
version = "0.31.0"
3+
version = "0.31.1"
44
authors = ["dystroy <[email protected]>"]
55
repository = "https://github.com/Canop/termimad"
66
description = "Markdown Renderer for the Terminal"

src/views/text_view.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,15 @@ impl<'a, 't> TextView<'a, 't> {
156156

157157
/// change the scroll position
158158
/// pages_count can be negative
159-
pub fn try_scroll_pages(&mut self, pages_count: i32) {
160-
self.try_scroll_lines(pages_count * i32::from(self.area.height))
159+
pub fn try_scroll_pages<C: Into<f64>>(&mut self, pages_count: C) {
160+
let pages_count: f64 = pages_count.into();
161+
let lines: f64 = pages_count * f64::from(self.area.height);
162+
let lines = if lines < 0.0 {
163+
lines.floor()
164+
} else {
165+
lines.ceil()
166+
};
167+
self.try_scroll_lines(lines as i32);
161168
}
162169

163170
pub fn line_up(&mut self) -> bool {

0 commit comments

Comments
 (0)