From d4703fb725dfd845b0ec9f60a2dc83f7ef9b33b7 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Mon, 28 Feb 2022 20:57:40 +0100 Subject: [PATCH] TermIO scroll fix --- src/lib/TermIO.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/TermIO.hx b/src/lib/TermIO.hx index a3c37d9..365999e 100644 --- a/src/lib/TermIO.hx +++ b/src/lib/TermIO.hx @@ -22,6 +22,11 @@ class TermIO { } var size = output.getSize(); + var cPos = output.getCursorPos(); + + if (cPos.y >= size.y){ + newLine(); + } for (i in 0...Math.floor(text.length / size.x) + 1) { output.write(text.substr(i * size.x, size.x)); @@ -38,7 +43,7 @@ class TermIO { if (cPos.y == output.getSize().y) { output.scroll(1); - output.setCursorPos(0, cPos.y); + output.setCursorPos(0, cPos.y - 1); } else { output.setCursorPos(0, cPos.y + 1); }