local Element = require("element") local Text = Element:new{ text = "" } function Text:new(o) o.width = nil o.height = nil return Element.new(self, o) end function Text:setText(text) local current = self:getText() if current ~= text then self:setDirty() local needReload = #current ~= #text self.text = text if needReload then self:_reload() end end end function Text:getText() return self.text end function Text:draw() Element.draw(self) self:_getWindow().write(self:getText()) end function Text:getHeight() return 1 end function Text:getWidth() return #self:getText() end function Text:setWidth() error("Dimensions are derived from content") end function Text:setHeight() error("Dimensions are derived from content") end function Text:resize() error("Dimensions are derived from content") end return Text