fix(greenhouse): fix toc disappearing on any key press

pull/240/head
sammyette 2023-07-10 18:00:49 -04:00
parent 1f5ab90586
commit ade14a6238
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 19 additions and 5 deletions

View File

@ -89,7 +89,7 @@ commander.register('greenhouse', function(args, sinks)
gh:keybind('Enter', function(self) gh:keybind('Enter', function(self)
if self.isSpecial then if self.isSpecial then
self:jump(self.specialPageIdx) self:jump(self.specialPageIdx)
self:special(true) self:special(false)
else else
if buffer:len() < 2 then return end if buffer:len() < 2 then return end
@ -118,5 +118,6 @@ commander.register('greenhouse', function(args, sinks)
gh:addPage(page) gh:addPage(page)
end end
ansikit.hideCursor()
gh:initUi() gh:initUi()
end) end)

View File

@ -93,14 +93,25 @@ end
function Greenhouse:update() function Greenhouse:update()
self:resize() self:resize()
if self.isSpecial then if self.isSpecial then
self:special() self:updateSpecial()
end end
self:draw() self:draw()
end end
function Greenhouse:special()
self.isSpecial = not self.isSpecial function Greenhouse:special(val)
self.isSpecial = val
self:update()
end
function Greenhouse:toggleSpecial()
self:special(not self.isSpecial)
end
--- This function will be called when the special page
--- is on and needs to be updated.
function Greenhouse:updateSpecial()
end end
function Greenhouse:toc(toggle) function Greenhouse:toc(toggle)
@ -128,6 +139,9 @@ function Greenhouse:toc(toggle)
tocText = tocText .. title .. '\n' tocText = tocText .. title .. '\n'
end end
self.specialPage = Page('TOC', tocText) self.specialPage = Page('TOC', tocText)
function self:updateSpecial()
self:toc()
end
self:draw() self:draw()
end end
@ -202,7 +216,6 @@ function Greenhouse:initUi()
end) end)
ansikit.screenAlt() ansikit.screenAlt()
ansikit.hideCursor()
ansikit.clear(true) ansikit.clear(true)
self:draw() self:draw()