From 45eb3d17e30bd2aa066f701ae3e5a3b4a4078ecb Mon Sep 17 00:00:00 2001 From: sammyette Date: Sat, 18 Feb 2023 17:57:03 -0400 Subject: [PATCH] fix(nature/greenhouse): draw pager body properly --- nature/greenhouse.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nature/greenhouse.lua b/nature/greenhouse.lua index 44947da..fb090c1 100644 --- a/nature/greenhouse.lua +++ b/nature/greenhouse.lua @@ -14,7 +14,7 @@ function Greenhouse:new(sink) local size = terminal.size() self.region = size self.start = 1 - self.offset = 0 + self.offset = 1 self.sink = sink return self @@ -27,11 +27,9 @@ end function Greenhouse:draw() self.sink:write(ansikit.getCSI(self.start .. ';1', 'H')) - for i = 1, #self.lines do - if i > self.region.height - 1 then break end - if not self.lines[i + self.offset] then break end - - self.sink:writeln(self.lines[i + self.offset]:gsub('\t', ' '):sub(0, self.region.width - 2)) + for i = self.offset, self.offset + (self.region.height - self.start) - 1 do + self.sink:write(ansikit.getCSI(2, 'K')) + self.sink:writeln(self.lines[i]:gsub('\t', ' '):sub(0, self.region.width - 2)) end end