diff options
author | Stephan Dilly <dilly.stephan@gmail.com> | 2021-05-24 01:12:34 +0200 |
---|---|---|
committer | Stephan Dilly <dilly.stephan@gmail.com> | 2021-05-24 01:12:34 +0200 |
commit | 13b346b8b1a91595390c193179c4d7afb1f4d158 (patch) | |
tree | 9aa1ef2340dd43886c5f23b3e9f44d47207d4264 /src/ui | |
parent | 6ace7f8eeac8e9b70fbfb1d7865626330a6c7f10 (diff) |
fix scrolling bounds (#725)
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/stateful_paragraph.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ui/stateful_paragraph.rs b/src/ui/stateful_paragraph.rs index 089a7c4e..f785c60b 100644 --- a/src/ui/stateful_paragraph.rs +++ b/src/ui/stateful_paragraph.rs @@ -45,8 +45,8 @@ pub struct StatefulParagraph<'a> { #[derive(Debug, Default, Clone, Copy)] pub struct ScrollPos { - x: u16, - y: u16, + pub x: u16, + pub y: u16, } impl ScrollPos { @@ -61,6 +61,8 @@ pub struct ParagraphState { scroll: ScrollPos, /// after all wrapping this is the amount of lines lines: u16, + /// last visible height + height: u16, } impl ParagraphState { @@ -68,6 +70,10 @@ impl ParagraphState { self.lines } + pub const fn height(self) -> u16 { + self.height + } + pub const fn scroll(self) -> ScrollPos { self.scroll } @@ -202,5 +208,6 @@ impl<'a> StatefulWidget for StatefulParagraph<'a> { } state.lines = y; + state.height = area.height; } } |