newline support for TextElement
This commit is contained in:
parent
7f8c0d154c
commit
9bb6b8bf2b
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user