From 265208db3a948b9b940e31d626407c617979c3cb Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Thu, 26 Oct 2023 12:07:00 +0200 Subject: [PATCH] Fix autoscroll --- src/tile.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tile.rs b/src/tile.rs index fde6f88..8b4204b 100644 --- a/src/tile.rs +++ b/src/tile.rs @@ -289,7 +289,7 @@ impl Tile { } // Autoscroll whene content arrives on stdout - self.scroll = self.stdout.len() as isize - 2 - (self.inner_size.1 as isize); + self.scroll = self.stdout.len() as isize - 1 - (self.inner_size.1 as isize); if self.scroll < 0 { self.scroll = 0; } @@ -497,7 +497,7 @@ impl Tile { } } - if last_line_index <= h { + if last_line_index as u16 - scroll <= h { let mut spaces = format!( "{}", cursor::Goto(x + max_char_index, y + last_line_index as u16 - scroll) @@ -522,7 +522,7 @@ impl Tile { /// Scrolls down one line. pub fn scroll_down(&mut self) { - if self.scroll + (self.inner_size.1 as isize) < self.stdout.len() as isize - 2 { + if self.scroll + (self.inner_size.1 as isize) < self.stdout.len() as isize - 1 { self.scroll += 1; } } @@ -534,7 +534,7 @@ impl Tile { /// Scrolls down one line. pub fn scroll_full_down(&mut self) { - self.scroll = self.stdout.len() as isize - self.inner_size.1 as isize - 2; + self.scroll = self.stdout.len() as isize - self.inner_size.1 as isize - 1; if self.scroll < 0 { self.scroll = 0; }