local event=require("event") local function components_changed(ename,address,type) local tty=require("tty") local window=tty.window if not window then return end if ename=="component_available"or ename=="component_unavailable"then type=address end if ename=="component_removed"or ename=="component_unavailable"then if type=="gpu"and window.gpu.address==address then window.gpu=nil window.keyboard=nil elseif type=="keyboard"then window.keyboard=nil end if(type=="screen"or type=="gpu")and not tty.isAvailable()then event.push("term_unavailable") end elseif(ename=="component_added"or ename=="component_available")and type=="keyboard"then window.keyboard=nil end end event.listen("component_removed",components_changed) event.listen("component_added",components_changed) event.listen("component_available",components_changed) event.listen("component_unavailable",components_changed)