diff --git a/src/lib/ui/elements/TextElement.hx b/src/lib/ui/elements/TextElement.hx index f351268..8aafdf0 100644 --- a/src/lib/ui/elements/TextElement.hx +++ b/src/lib/ui/elements/TextElement.hx @@ -28,9 +28,19 @@ class TextElement implements UIElement { public function render(bounds:Pos):Canvas { var canvas = new Canvas(); + + var x = 0; + var y = 0; + for (i in 0...this.text.length) { var c = this.text.charAt(i); - canvas.set({x: i, y: 0}, {bg: style.bgColor ?? Black, textColor: style.fgColor ?? White, char: c}); + if (c == "\n") { + x = 0; + y++; + } else { + canvas.set({x: x, y: y}, {bg: style.bgColor ?? Black, textColor: style.fgColor ?? White, char: c}); + x++; + } } return canvas;