From 1108eab4036436698866cd54c0c74e74c15da671 Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Wed, 8 May 2024 15:33:40 +0200 Subject: [PATCH] fixed line printing in Terminal --- src/bin/Terminal.hx | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/bin/Terminal.hx b/src/bin/Terminal.hx index d16be44..298e392 100644 --- a/src/bin/Terminal.hx +++ b/src/bin/Terminal.hx @@ -62,6 +62,8 @@ class Terminal implements IProcess { if (this.runningPID > 0) return; this.backlog.push("> " + this.input); + this.backlog.push(""); + var command = this.input; this.input = ""; this.scrollBack = 0; @@ -91,6 +93,8 @@ class Terminal implements IProcess { var arg1 = handle.args[0]; this.backlog.push("> " + arg1); + this.backlog.push(""); + EndOfLoop.endOfLoop(() -> { this.invokeCommand(arg1); }); @@ -177,24 +181,13 @@ class Terminal implements IProcess { return; } - var mfunc = NativeStringTools.gmatch(s, "(.-)(\n)"); + var splits = s.split("\n"); - while (true) { - var found = mfunc(); - - if (found == null) { - break; - } - - if (found == "\n") { - this.backlog.push(""); + for (i => split in splits) { + if (i == 0) { + this.backlog[this.backlog.length - 1] += split; } else { - this.backlog.push(found); - } - - // Trim the backlog if it's too long - if (this.backlog.length > MAX_BACKLOG) { - this.backlog.shift(); + this.backlog.push(split); } }