diff options
author | Canop <cano.petrole@gmail.com> | 2019-02-01 21:42:35 +0100 |
---|---|---|
committer | Canop <cano.petrole@gmail.com> | 2019-02-01 21:42:35 +0100 |
commit | cd97c2bb5d8efd65db56c7e6cc93601505a996cf (patch) | |
tree | 47dccf6578c903a08b5163da625170edcb52ff63 /src/screens.rs | |
parent | 6881cb8e153c7fe866e3ed45b1f394db82f7e5bf (diff) |
a few sacrifices to the Clippy god
Diffstat (limited to 'src/screens.rs')
-rw-r--r-- | src/screens.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/screens.rs b/src/screens.rs index c622a51..8fe4dfe 100644 --- a/src/screens.rs +++ b/src/screens.rs @@ -23,6 +23,7 @@ impl Screen { let stdout = AlternateScreen::from(stdout().into_raw_mode()?); let mut screen = Screen { w:0, h:0, stdout }; screen.read_size()?; + write!(screen.stdout, "{}", termion::cursor::Hide)?; Ok(screen) } pub fn read_size(&mut self) -> io::Result<()> { @@ -82,10 +83,10 @@ impl ScreenArea { // (note that this may lead to flickering) #[allow(dead_code)] pub fn draw_scrollbar(&self, screen: &mut Screen) -> io::Result<()> { - let h = (self.bottom as i32) - (self.top as i32) + 1; + let h = i32::from(self.bottom) - i32::from(self.top) + 1; if self.content_length > h { let sbh = h * h / self.content_length; - let sc = self.top as i32 + self.scroll * h / self.content_length; + let sc = i32::from(self.top) + self.scroll * h / self.content_length; write!( screen.stdout, "{}", @@ -109,7 +110,10 @@ impl ScreenArea { return None; } let sbh = h * h / self.content_length; - let sc = self.top as i32 + self.scroll * h / self.content_length; - Some((sc as u16, (sc + sbh).min(self.bottom as i32 - 1) as u16)) + let sc = i32::from(self.top) + self.scroll * h / self.content_length; + Some(( + sc as u16, + (sc + sbh).min(i32::from(self.bottom) - 1) as u16, + )) } } |