From 4e171aabeddf6c77b1e844d8bb7e374f9861b46e Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Tue, 1 Oct 2024 14:55:09 +0000 Subject: [PATCH] Override unusable methods in Text element --- gfx/text.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/gfx/text.lua b/gfx/text.lua index 9c5eee7..a37cd69 100644 --- a/gfx/text.lua +++ b/gfx/text.lua @@ -1,9 +1,41 @@ 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) + self:setDirty() + self.text = text +end + function Text:draw() Element.draw(self) self.render.window.write(self.text) end +function Text:getHeight() + return 1 +end + +function Text:getWidth() + return #self.text +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 \ No newline at end of file