diff options
author | Canop <cano.petrole@gmail.com> | 2021-04-21 21:35:34 +0200 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2021-04-21 21:35:34 +0200 |
commit | 7c01fa61994445038801d7da763ca48030088dde (patch) | |
tree | 4369105274c4f490291e11c48b7c0a040c227b89 /src/command | |
parent | 69371b95f19e186ec3c6c8396f88697590ee8705 (diff) |
scrolling in staging area
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/scroll.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/command/scroll.rs b/src/command/scroll.rs index 0f3c448..73928bf 100644 --- a/src/command/scroll.rs +++ b/src/command/scroll.rs @@ -13,10 +13,23 @@ impl ScrollCommand { } } /// compute the new scroll value - pub fn apply(self, scroll: usize, content_height: usize, page_height: usize) -> usize { + pub fn apply( + self, + scroll: usize, + content_height: usize, + page_height: usize, + ) -> usize { (scroll as i32 + self.to_lines(page_height)) .min(content_height as i32 - page_height as i32 + 1) .max(0) as usize } + pub fn is_thumb(y: u16, scrollbar: Option<(u16, u16)>) -> bool { + if let Some((sctop, scbottom)) = scrollbar { + if sctop <= y && y <= scbottom { + return true; + } + } + false + } } |