Skip to content

Commit

Permalink
fix(greenhouse): draws/updates after exit by resize
Browse files Browse the repository at this point in the history
  • Loading branch information
TorchedSammy committed Apr 27, 2024
1 parent 5212987 commit fb9d305
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions nature/greenhouse/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ end
function Greenhouse:input(char)
end

local function read()
terminal.saveState()
terminal.setRaw()
local c = hilbish.editor.readChar()

terminal.restoreState()
return c
end

function Greenhouse:initUi()
local ansikit = require 'ansikit'
local bait = require 'bait'
Expand All @@ -280,14 +289,17 @@ function Greenhouse:initUi()
local Page = require 'nature.greenhouse.page'
local done = false

bait.catch('signal.sigint', function()
local function sigint()
ansikit.clear()
done = true
end)
end

bait.catch('signal.resize', function()
local function resize()
self:update()
end)
end
bait.catch('signal.sigint', sigint)

bait.catch('signal.resize', resize)

ansikit.screenAlt()
ansikit.clear(true)
Expand All @@ -311,15 +323,10 @@ function Greenhouse:initUi()

ansikit.showCursor()
ansikit.screenMain()
end

function read()
terminal.saveState()
terminal.setRaw()
local c = hilbish.editor.readChar()

terminal.restoreState()
return c
self = nil
bait.release('signal.sigint', sigint)
bait.release('signal.resize', resize)
end

return Greenhouse

0 comments on commit fb9d305

Please sign in to comment.